├── README.MD ├── launch.json ├── pinescript.v4.code-snippets └── settings.json /README.MD: -------------------------------------------------------------------------------- 1 | # ***THIS IS DEPRECATED*** 2 | the snippets code provided is for V4 of Pinescript. 3 | 4 | followed this tut: 5 | https://github.blog/2016-02-01-working-with-submodules/ 6 | 7 | 1. from terminal, go to were .vscode is / root of the repository. 8 | 2. git rm -r .vscode 9 | 3. git commit -m "remove vscode(for sub module)" 10 | 4. git submodule add https://github.com/ricardosantos79/vscode_pinescript_snippet .vscode 11 | 5. git commit -m ".vscode submodule" 12 | 6. git submodule update --init --recursive 13 | 14 | and should be set now, gona do a update test to see if its working 15 | -------------------------------------------------------------------------------- /launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Python: Current File (Integrated Terminal)", 9 | "type": "python", 10 | "request": "launch", 11 | "program": "${file}", 12 | "console": "integratedTerminal" 13 | }, 14 | { 15 | "name": "Python: Remote Attach", 16 | "type": "python", 17 | "request": "attach", 18 | "port": 5678, 19 | "host": "localhost", 20 | "pathMappings": [ 21 | { 22 | "localRoot": "${workspaceFolder}", 23 | "remoteRoot": "." 24 | } 25 | ] 26 | }, 27 | { 28 | "name": "Python: Module", 29 | "type": "python", 30 | "request": "launch", 31 | "module": "enter-your-module-name-here", 32 | "console": "integratedTerminal" 33 | }, 34 | { 35 | "name": "Python: Django", 36 | "type": "python", 37 | "request": "launch", 38 | "program": "${workspaceFolder}/manage.py", 39 | "console": "integratedTerminal", 40 | "args": [ 41 | "runserver", 42 | "--noreload", 43 | "--nothreading" 44 | ], 45 | "django": true 46 | }, 47 | { 48 | "name": "Python: Flask", 49 | "type": "python", 50 | "request": "launch", 51 | "module": "flask", 52 | "env": { 53 | "FLASK_APP": "app.py" 54 | }, 55 | "args": [ 56 | "run", 57 | "--no-debugger", 58 | "--no-reload" 59 | ], 60 | "jinja": true 61 | }, 62 | { 63 | "name": "Python: Current File (External Terminal)", 64 | "type": "python", 65 | "request": "launch", 66 | "program": "${file}", 67 | "console": "externalTerminal" 68 | } 69 | ] 70 | } -------------------------------------------------------------------------------- /pinescript.v4.code-snippets: -------------------------------------------------------------------------------- 1 | { 2 | //------------------------------------------------------------------------------- 3 | // Place your pinescript workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and 4 | // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope 5 | // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is 6 | // used to trigger the snippet and the body will be expanded and inserted. Possible variables are: 7 | // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. 8 | // Placeholders with the same ids are connected. 9 | // Example: 10 | // "Print to console": { 11 | // "scope": "javascript,typescript", 12 | // "prefix": "log", 13 | // "body": [ 14 | // "console.log('$1');", 15 | // "$2" 16 | // ], 17 | // "description": "Log output to console" 18 | // } 19 | // for reference: https://code.visualstudio.com/docs/editor/userdefinedsnippets 20 | //------------------------------------------------------------------------------- 21 | //------------------------------------------------------------------------------- 22 | //------------------------------------------------------------------------------- 23 | // Pinescript builtin variables: 24 | //------------------------------------------------------------------------------- 25 | "accdist" : { 26 | "scope": "pine, pinescript", 27 | "prefix": "accdist", 28 | "body": ["accdist"], 29 | "description": "Accumulation/distribution index.\nType: float" 30 | }, 31 | "adjustment.x" : { 32 | "scope": "pine, pinescript", 33 | "prefix": "adjustment.x", 34 | "body": ["adjustment.${1|dividends,none,splits|}"], 35 | "description": "Constant for dividends adjustment type.\nType: string" 36 | }, 37 | "bar_index" : { 38 | "scope": "pine, pinescript", 39 | "prefix": "bar_index", 40 | "body": ["bar_index"], 41 | "description": "Current bar index. Numbering is zero-based, index of the first bar is 0.\nType: integer" 42 | }, 43 | "barmerge.x" : { 44 | "scope": "pine, pinescript", 45 | "prefix": "barmerge.x", 46 | "body": ["barmerge.${1|gaps_off,gaps_on,lookahead_off,lookahead_on|}"], 47 | "description": "Merge strategy for requested data." 48 | }, 49 | "barstate.x" : { 50 | "scope": "pine, pinescript", 51 | "prefix": "barstate.x", 52 | "body": ["barstate.${1|isconfirmed,isfirst,ishisstory,islast,isnew,isrealtime|}"], 53 | "description": "Returns event outcome.\nType: bool" 54 | }, 55 | "close" : { 56 | "scope": "pine, pinescript", 57 | "prefix": "close", 58 | "body": ["close"], 59 | "description": "Returns true if current bar is a real-time bar, false otherwise.\nType: bool" 60 | }, 61 | "color.x" : { 62 | "scope": "pine, pinescript", 63 | "prefix": "color.x", 64 | "body": ["color.${1|aqua,black,silver,gray,white,maroon,red,purple,fuchsia,green,lime,olive,yellow,navy,blue,teal,orange|}"], 65 | "description": "Is a named constant for a color.\nType: color" 66 | }, 67 | "currency.x" : { 68 | "scope": "pine, pinescript", 69 | "prefix": "currency.x", 70 | "body": ["currency.${1|AUD,CAD,CHF,EUR,GBP,HKD,JPY,NOK,NONE,NZD,RUB,SEK,SGD,TRY,USD,ZAR|}"], 71 | "description": "String representing a currency.\nType: string" 72 | }, 73 | "dayofmonth" : { 74 | "scope": "pine, pinescript", 75 | "prefix": "dayofmonth", 76 | "body": ["dayofmonth"], 77 | "description": "Date of current bar time in exchange timezone.\nType: integer" 78 | }, 79 | "dayofweek" : { 80 | "scope": "pine, pinescript", 81 | "prefix": "dayofweek", 82 | "body": ["dayofweek"], 83 | "description": "Day of week for current bar time in exchange timezone.\nType: integer" 84 | }, 85 | "dayofweek.x" : { 86 | "scope": "pine, pinescript", 87 | "prefix": "dayofweek.x", 88 | "body": ["dayofweek.${1|friday,monday,saturday,sunday,thursday,tuesday,wednesday|}"], 89 | "description": "Is a named constant for return value of dayofweek function and value of dayofweek variable.\nType: integer" 90 | }, 91 | "display.x" : { 92 | "scope": "pine, pinescript", 93 | "prefix": "display.x", 94 | "body": ["display.${1|all,none|}"], 95 | "description": "A named constant that specifies where the plot is displayed.\nType: integer" 96 | }, 97 | "extend.x" : { 98 | "scope": "pine, pinescript", 99 | "prefix": "extend.x", 100 | "body": ["extend.${1|both,left,none,right|}"], 101 | "description": "Named constant for line.new and line.set_extend functions.\nType: string" 102 | }, 103 | "format.x" : { 104 | "scope": "pine, pinescript", 105 | "prefix": "format.x", 106 | "body": ["format.${1|inherit,price,volume|}"], 107 | "description": "Named constant for selecting the formatting of the script output values.\nType: string" 108 | }, 109 | "high" : { 110 | "scope": "pine, pinescript", 111 | "prefix": "high", 112 | "body": ["high"], 113 | "description": "Current high price.\nType: float" 114 | }, 115 | "hl2" : { 116 | "scope": "pine, pinescript", 117 | "prefix": "hl2", 118 | "body": ["hl2"], 119 | "description": "Is a shortcut for (high + low)/2.\nType: float" 120 | }, 121 | "hlc3" : { 122 | "scope": "pine, pinescript", 123 | "prefix": "hlc3", 124 | "body": ["hlc3"], 125 | "description": "Is a shortcut for (high + low + close)/3.\nType: float" 126 | }, 127 | "hline.x" : { 128 | "scope": "pine, pinescript", 129 | "prefix": "hline.x", 130 | "body": ["hline.${1|style_dashed,style_dotted,style_solid|}"], 131 | "description": "Named constant for solid linestyle of hline function.\nType: integer" 132 | }, 133 | "hour" : { 134 | "scope": "pine, pinescript", 135 | "prefix": "hour", 136 | "body": ["hour"], 137 | "description": "Current bar hour in exchange timezone.\nType: integer" 138 | }, 139 | "iii" : { 140 | "scope": "pine, pinescript", 141 | "prefix": "iii", 142 | "body": ["iii"], 143 | "description": "Intraday Intensity Index.\nType: float" 144 | }, 145 | "input.x" : { 146 | "scope": "pine, pinescript", 147 | "prefix": "input.x", 148 | "body": ["input.${1|bool,float,integer,resolution,session,source,string,symbol|}"], 149 | "description": "Named constant for input type of input function.\nType: string" 150 | }, 151 | "label.x" : { 152 | "scope": "pine, pinescript", 153 | "prefix": "label.x", 154 | "body": ["label.${1|style_arrowdown,style_arrowup,style_circle,style_cross,style_diamond,style_flag,style_label_center,style_label_down,style_label_left,style_label_right,style_label_up,style_none,style_square,style_triangledown,style_triangleup,style_xcross|}"], 155 | "description": "Label style for label.new and label.set_style functions.\nType: string" 156 | }, 157 | "line.x" : { 158 | "scope": "pine, pinescript", 159 | "prefix": "line.x", 160 | "body": ["line.${1|style_arrow_both,style_arrow_left,style_arrow_right,style_dashed,style_dotted,style_solid|}"], 161 | "description": "Line style for line.new and line.set_style functions.\nType: string" 162 | }, 163 | "location.x" : { 164 | "scope": "pine, pinescript", 165 | "prefix": "location.x", 166 | "body": ["location.${1|abovebar,absolute,belowbar,bottom,top|}"], 167 | "description": "Location value for plotshape, plotchar functions.\nType: string" 168 | }, 169 | "low" : { 170 | "scope": "pine, pinescript", 171 | "prefix": "low", 172 | "body": ["low"], 173 | "description": "Current low price.\nType: float" 174 | }, 175 | "minute" : { 176 | "scope": "pine, pinescript", 177 | "prefix": "minute", 178 | "body": ["minute"], 179 | "description": "Current bar minute in exchange timezone.\nType: integer" 180 | }, 181 | "month" : { 182 | "scope": "pine, pinescript", 183 | "prefix": "month", 184 | "body": ["month"], 185 | "description": "Current bar month in exchange timezone.\nType: integer" 186 | }, 187 | "na" : { 188 | "scope": "pine, pinescript", 189 | "prefix": "na", 190 | "body": ["na"], 191 | "description": "Double. NaN value(Not a number).\nType: na" 192 | }, 193 | "nvi" : { 194 | "scope": "pine, pinescript", 195 | "prefix": "nvi", 196 | "body": ["nvi"], 197 | "description": "Negative Volume Index.\nType: float" 198 | }, 199 | "obv" : { 200 | "scope": "pine, pinescript", 201 | "prefix": "obv", 202 | "body": ["obv"], 203 | "description": "On Balance Volume.\nType: float" 204 | }, 205 | "ohlc4" : { 206 | "scope": "pine, pinescript", 207 | "prefix": "ohlc4", 208 | "body": ["ohlc4"], 209 | "description": "Is a shortcut for (open + high + low + close)/4.\nType: float" 210 | }, 211 | "open" : { 212 | "scope": "pine, pinescript", 213 | "prefix": "open", 214 | "body": ["open"], 215 | "description": "Current open price.\nType: float" 216 | }, 217 | "plot.x" : { 218 | "scope": "pine, pinescript", 219 | "prefix": "plot.x", 220 | "body": ["plot.${1|style_area,style_areabr,style_circles,style_columns,style_cross,style_histogram,style_line,style_linebr,style_stepline|}"], 221 | "description": "Named costant for plot() function property.\nType: string" 222 | }, 223 | "pvi" : { 224 | "scope": "pine, pinescript", 225 | "prefix": "pvi", 226 | "body": ["pvi"], 227 | "description": "Positive Volume Index.\nType: float" 228 | }, 229 | "pvt" : { 230 | "scope": "pine, pinescript", 231 | "prefix": "pvt", 232 | "body": ["pvt"], 233 | "description": "Price Volume Trend.\nType: float" 234 | }, 235 | "scale.x" : { 236 | "scope": "pine, pinescript", 237 | "prefix": "scale.x", 238 | "body": ["scale.${1|left,none,right|}"], 239 | "description": "Scale value for study() function.\nType: integer" 240 | }, 241 | "second" : { 242 | "scope": "pine, pinescript", 243 | "prefix": "second", 244 | "body": ["second"], 245 | "description": "Current bar second in exchange timezone.\nType: integer" 246 | }, 247 | "session.x" : { 248 | "scope": "pine, pinescript", 249 | "prefix": "session.x", 250 | "body": ["session.${1|extended,regular|}"], 251 | "description": "Constant for session type.\nType: string" 252 | }, 253 | "shape.x" : { 254 | "scope": "pine, pinescript", 255 | "prefix": "shape.x", 256 | "body": ["shape.${1|arrowdown,arrowup,circle,cross,diamond,flag,labeldown,labelup,square,triangledown,triangleup,xcross|}"], 257 | "description": "Shape style for plotshape() function.\nType: string" 258 | }, 259 | "size.x" : { 260 | "scope": "pine, pinescript", 261 | "prefix": "size.x", 262 | "body": ["size.${1|auto,huge,large,normal,small,tiny|}"], 263 | "description": "Size value for plotshape() function.\nType: string" 264 | }, 265 | "strategy.x" : { 266 | "scope": "pine, pinescript", 267 | "prefix": "strategy.x", 268 | "body": ["strategy.${1|cash,closedtrades,comission.cash_per_contract,comission.cash_per_order,comission.percent,direction.all,direction.long,direction.short,equity,eventrades,fixed,grossloss,grossprofit,initial_capital,long,losstrades,max_contracts_held_all,max_contracts_held_long,max_contracts_held_short,max_drawdown,netprofit,oca.cancel,oca.none,oca.reduce,openprofit,opentrades,percent_of_equity,position_avg_price,position_entry_name,position_size,short,wintrades|}"], 269 | "description": "Size value for plotshape() function.\nType: string" 270 | }, 271 | "syminfo.x" : { 272 | "scope": "pine, pinescript", 273 | "prefix": "syminfo.x", 274 | "body": ["syminfo.${1|currency,description,mintick,pointvalue,prefix,root,session,ticker,tickerid,timezone,type|}"], 275 | "description": "Properties of the underlying asset.\nType: ---" 276 | }, 277 | "text.x" : { 278 | "scope": "pine, pinescript", 279 | "prefix": "text.x", 280 | "body": ["text.${1|align_center,align_left,align_right|}"], 281 | "description": "Label text alignment for label.new() function.\nType: string" 282 | }, 283 | "time" : { 284 | "scope": "pine, pinescript", 285 | "prefix": "time", 286 | "body": ["time"], 287 | "description": "Current bar time in UNIX format.\nType: integer" 288 | }, 289 | "time_close" : { 290 | "scope": "pine, pinescript", 291 | "prefix": "time_close", 292 | "body": ["time_close"], 293 | "description": "Current bar close time in UNIX format.\nType: integer" 294 | }, 295 | "timeframe.x" : { 296 | "scope": "pine, pinescript", 297 | "prefix": "timeframe.x", 298 | "body": ["timeframe.${1|isdaily,isdwm,isintraday,isminutes,ismonthly,isseconds,isweekly,multiplier,period|}"], 299 | "description": "Properties of timeframe.\nType: ---" 300 | }, 301 | "timenow" : { 302 | "scope": "pine, pinescript", 303 | "prefix": "timenow", 304 | "body": ["timenow"], 305 | "description": "Current time in UNIX format.\nType: integer" 306 | }, 307 | "tr" : { 308 | "scope": "pine, pinescript", 309 | "prefix": "tr", 310 | "body": ["tr"], 311 | "description": "True range. Same as tr(false). It is max(high - low, abs(high - close[1]), abs(low - close[1])).\nType: float" 312 | }, 313 | "volume" : { 314 | "scope": "pine, pinescript", 315 | "prefix": "volume", 316 | "body": ["volume"], 317 | "description": "Current bar volume.\nType: float" 318 | }, 319 | "vwap" : { 320 | "scope": "pine, pinescript", 321 | "prefix": "vwap", 322 | "body": ["vwap"], 323 | "description": "Volume-weighted average price. It uses hlc3 as source.\nType: float" 324 | }, 325 | "wad" : { 326 | "scope": "pine, pinescript", 327 | "prefix": "wad", 328 | "body": ["wad"], 329 | "description": "Williams Accumulation/Distribution.\nType: float" 330 | }, 331 | "weekofyear" : { 332 | "scope": "pine, pinescript", 333 | "prefix": "weekofyear", 334 | "body": ["weekofyear"], 335 | "description": "Week number of current bar time in exchange timezone.\nType: integer" 336 | }, 337 | "wvad" : { 338 | "scope": "pine, pinescript", 339 | "prefix": "wvad", 340 | "body": ["wvad"], 341 | "description": "Williams Variable Accumulation/Distribution.\nType: float" 342 | }, 343 | "xloc.x" : { 344 | "scope": "pine, pinescript", 345 | "prefix": "xloc.x", 346 | "body": ["xloc.${1|bar_index,bar_time|}"], 347 | "description": "A named constant that specifies the algorithm of interpretation of x-value in functions line.new and label.new.\nType: string" 348 | }, 349 | "year" : { 350 | "scope": "pine, pinescript", 351 | "prefix": "year", 352 | "body": ["year"], 353 | "description": "Current bar year in exchange timezone.\nType: integer" 354 | }, 355 | "yloc.x" : { 356 | "scope": "pine, pinescript", 357 | "prefix": "yloc.x", 358 | "body": ["yloc.${1|abovebar,belowbar,price|}"], 359 | "description": "A named constant that specifies the algorithm of interpretation of y-value in function label.new.\nType: string" 360 | }, 361 | //------------------------------------------------------------------------------- 362 | //------------------------------------------------------------------------------- 363 | //------------------------------------------------------------------------------- 364 | // builtin functions: 365 | //------------------------------------------------------------------------------- 366 | "abs()" : { 367 | "scope": "pine, pinescript", 368 | "prefix": "abs()", 369 | "body": ["abs($0)"], 370 | "description": "Absolute value of input value." 371 | }, 372 | "acos()" : { 373 | "scope": "pine, pinescript", 374 | "prefix": "acos()", 375 | "body": ["acos($0)"], 376 | "description": "The acos function returns the arccosine (in radians) of number such that cos(acos(y)) = y for y in range [-1, 1]." 377 | }, 378 | "alertcondition()" : { 379 | "scope": "pine, pinescript", 380 | "prefix": "alertcondition()", 381 | "body": ["alertcondition(condition=${1}, title='${2}', message='${3}')", "${0}"], 382 | "description": "Creates alert condition, that is available in Create Alert dialog. Please note, that alertcondition does NOT create an alert, it just gives you more options in Create Alert dialog. Also, alertcondition effect is invisible on chart." 383 | }, 384 | "alma()" : { 385 | "scope": "pine, pinescript", 386 | "prefix": "alma()", 387 | "body": ["alma(series=${1}, length=${2}, offset=${3}, sigma=${4})${0}"], 388 | "description": "Arnaud Legoux Moving Average. It uses Gaussian distribution as weights for moving average." 389 | }, 390 | "asin()" : { 391 | "scope": "pine, pinescript", 392 | "prefix": "asin()", 393 | "body": ["asin($0)"], 394 | "description": "The asin function returns the arcsine (in radians) of number such that sin(asin(y)) = y for y in range [-1, 1]." 395 | }, 396 | "atan()" : { 397 | "scope": "pine, pinescript", 398 | "prefix": "atan()", 399 | "body": ["atan($0)"], 400 | "description": "The atan function returns the arctangent (in radians) of number such that tan(atan(y)) = y for any y." 401 | }, 402 | "atr()" : { 403 | "scope": "pine, pinescript", 404 | "prefix": "atr()", 405 | "body": ["atr(length=$0)"], 406 | "description": "Function atr (average true range) returns the RMA of true range. True range is max(high - low, abs(high - close[1]), abs(low - close[1]))" 407 | }, 408 | "avg()" : { 409 | "scope": "pine, pinescript", 410 | "prefix": "avg()", 411 | "body": ["avg($0)"], 412 | "description": "Calculates average of all given series (elementwise)." 413 | }, 414 | "barcolor()" : { 415 | "scope": "pine, pinescript", 416 | "prefix": "barcolor()", 417 | "body": ["barcolor(color=${1}, offset=${2}, editable=${3}, show_last=${4}, title=${5})", "${0}"], 418 | "description": "Set color of bars." 419 | }, 420 | "barssince()" : { 421 | "scope": "pine, pinescript", 422 | "prefix": "barssince()", 423 | "body": ["barssince(condition=$0)"], 424 | "description": "Counts the number of bars since condition was true." 425 | }, 426 | "bb()" : { 427 | "scope": "pine, pinescript", 428 | "prefix": "bb()", 429 | "body": ["[${1|_,bb_middle|}, ${2|_,bb_upper|}, ${3|_,bb_lower|}] = bb(series=${4}, length=${5}, mult=${6})", "${0}"], 430 | "description": "Bollinger Bands. A Bollinger Band is a technical analysis tool defined by a set of lines plotted two standard deviations (positively and negatively) away from a simple moving average (SMA) of the security's price, but can be adjusted to user preferences." 431 | }, 432 | "bbw()" : { 433 | "scope": "pine, pinescript", 434 | "prefix": "bbw()", 435 | "body": ["bbw(series=${1}, length=${2}, mult=${3})$0"], 436 | "description": "Bollinger Bands Width. The Bollinger Band Width is the difference between the upper and the lower Bollinger Bands divided by the middle band." 437 | }, 438 | "bgcolor()" : { 439 | "scope": "pine, pinescript", 440 | "prefix": "bgcolor()", 441 | "body": ["bgcolor(color=${1}, transp=${2}, offset=${3}, editable=${4}, show_last=${5}, title=${6})", "${0}"], 442 | "description": "Fill background color of bars with specified color." 443 | }, 444 | "bool()" : { 445 | "scope": "pine, pinescript", 446 | "prefix": "bool()", 447 | "body": ["bool($0)"], 448 | "description": "Casts na to bool." 449 | }, 450 | "cci()" : { 451 | "scope": "pine, pinescript", 452 | "prefix": "cci()", 453 | "body": ["cci(source=${1}, length=${2})$0"], 454 | "description": "The CCI (commodity channel index) is calculated as the difference between the typical price of a commodity and its simple moving average, divided by the mean absolute deviation of the typical price. The index is scaled by an inverse factor of 0.015 to provide more readable numbers." 455 | }, 456 | "ceil()" : { 457 | "scope": "pine, pinescript", 458 | "prefix": "ceil()", 459 | "body": ["ceil($0)"], 460 | "description": "The ceil function returns the smallest (closest to negative infinity) integer that is greater than or equal to the argument." 461 | }, 462 | "change()" : { 463 | "scope": "pine, pinescript", 464 | "prefix": "change()", 465 | "body": ["change(source=${1}${2:, length=})$0"], 466 | "description": "Difference between current value and previous, x - x[y]." 467 | }, 468 | "cmo()" : { 469 | "scope": "pine, pinescript", 470 | "prefix": "cmo()", 471 | "body": ["cmo(series=${1}, length=${2})$0"], 472 | "description": "Chande Momentum Oscillator. Calculates the difference between the sum of recent gains and the sum of recent losses and then divides the result by the sum of all price movement over the same period." 473 | }, 474 | "cog()" : { 475 | "scope": "pine, pinescript", 476 | "prefix": "cog()", 477 | "body": ["cog(source=${1}, length=${2})$0"], 478 | "description": "The cog (center of gravity) is an indicator based on statistics and the Fibonacci golden ratio." 479 | }, 480 | "color()" : { 481 | "scope": "pine, pinescript", 482 | "prefix": "color()", 483 | "body": ["color($0)"], 484 | "description": "Casts na to color." 485 | }, 486 | "color.new()" : { 487 | "scope": "pine, pinescript", 488 | "prefix": "color.new()", 489 | "body": ["color.new(color=${1}, transp=${2})$0"], 490 | "description": "Function color applies the specified transparency to the given color." 491 | }, 492 | "correlation()" : { 493 | "scope": "pine, pinescript", 494 | "prefix": "correlation()", 495 | "body": ["correlation(source_a=${1}, source_b=${2}, length=${3})$0"], 496 | "description": "Correlation coefficient. Describes the degree to which two series tend to deviate from their sma values." 497 | }, 498 | "cos()" : { 499 | "scope": "pine, pinescript", 500 | "prefix": "cos()", 501 | "body": ["cos($0)"], 502 | "description": "The cos function returns the trigonometric cosine of an angle." 503 | }, 504 | "cross()" : { 505 | "scope": "pine, pinescript", 506 | "prefix": "cross()", 507 | "body": ["cross(x=${1}, y=${2})$0"], 508 | "description": "returns 1 if two series have crossed each other, otherwise 0." 509 | }, 510 | "crossover()" : { 511 | "scope": "pine, pinescript", 512 | "prefix": "crossover()", 513 | "body": ["crossover(x=${1}, y=${2})$0"], 514 | "description": "returns 1 if series x have crossed over y, otherwise 0." 515 | }, 516 | "crossunder()" : { 517 | "scope": "pine, pinescript", 518 | "prefix": "crossunder()", 519 | "body": ["crossunder(x=${1}, y=${2})$0"], 520 | "description": "returns 1 if series x have crossed under y, otherwise 0." 521 | }, 522 | "cum()" : { 523 | "scope": "pine, pinescript", 524 | "prefix": "cum()", 525 | "body": ["cum($0)"], 526 | "description": "Cumulative (total) sum of x. In other words it's the sum of all elements of x." 527 | }, 528 | "dayofmonth()" : { 529 | "scope": "pine, pinescript", 530 | "prefix": "dayofmonth()", 531 | "body": ["dayofmonth(time=${1:time})$0"], 532 | "description": "Day of month in exchange timezone for provided UNIX time." 533 | }, 534 | "dayofweek()" : { 535 | "scope": "pine, pinescript", 536 | "prefix": "dayofweek()", 537 | "body": ["dayofweek(time=${1:time})$0"], 538 | "description": "Day of week in exchange timezone for provided UNIX time." 539 | }, 540 | "dev()" : { 541 | "scope": "pine, pinescript", 542 | "prefix": "dev()", 543 | "body": ["dev(source=${1}, length=${2})$0"], 544 | "description": "Measure of difference between the series and it's sma." 545 | }, 546 | "dmi()" : { 547 | "scope": "pine, pinescript", 548 | "prefix": "dmi()", 549 | "body": ["[${1|_,diplus|}, ${2|_,diminus|}, ${3|_,adx|}] = dmi(diLength=${4}, adxSmoothing=${5})$0"], 550 | "description": "Directional Movement Index function." 551 | }, 552 | "ema()" : { 553 | "scope": "pine, pinescript", 554 | "prefix": "ema()", 555 | "body": ["ema(source=${1}, length=${2})$0"], 556 | "description": "The ema function returns the exponentially weighted moving average. In ema weighting factors decrease exponentially. It calculates by sing a formula: EMA = alpha * x + (1 - alpha) * EMA[1], where alpha = 2 / (y + 1)" 557 | }, 558 | "exp()" : { 559 | "scope": "pine, pinescript", 560 | "prefix": "exp()", 561 | "body": ["exp($0)"], 562 | "description": "The exp function of x is e^x, where x is the argument and e is Euler's number." 563 | }, 564 | "falling()" : { 565 | "scope": "pine, pinescript", 566 | "prefix": "falling()", 567 | "body": ["falling(source=${1}, length=${2})$0"], 568 | "description": "Test if the source series is now falling for the number of length in bars long." 569 | }, 570 | "fill()" : { 571 | "scope": "pine, pinescript", 572 | "prefix": "fill()", 573 | "body": ["fill(${1|hline1=,plot1=|}, ${2|hline2=, plot2=|}, color=${3}, transp=${4}, title='${5}', editable=${2})$0"], 574 | "description": "Fills background between two plots or hlines with given color." 575 | }, 576 | "fixnan()" : { 577 | "scope": "pine, pinescript", 578 | "prefix": "fixnan()", 579 | "body": ["fixnan($0)"], 580 | "description": "For a given series replaces NaN values with previous nearest non-NaN value." 581 | }, 582 | "float()" : { 583 | "scope": "pine, pinescript", 584 | "prefix": "float()", 585 | "body": ["float($0)"], 586 | "description": "Casts na to float." 587 | }, 588 | "floor()" : { 589 | "scope": "pine, pinescript", 590 | "prefix": "floor()", 591 | "body": ["floor($0)"], 592 | "description": "Returns the largest integer less than or equal to the given number." 593 | }, 594 | "heikinashi()" : { 595 | "scope": "pine, pinescript", 596 | "prefix": "heikinashi()", 597 | "body": ["heikinashi($0)"], 598 | "description": "Create a ticker identifier for requesting Heikin Ashi bar values." 599 | }, 600 | "highest()" : { 601 | "scope": "pine, pinescript", 602 | "prefix": "highest()", 603 | "body": ["highest${1|(,(source=\\, |}length=${2})$0"], 604 | "description": "Highest value for a given number of bars back." 605 | }, 606 | "highestbars()" : { 607 | "scope": "pine, pinescript", 608 | "prefix": "highestbars()", 609 | "body": ["highestbars${1|(,(source=\\, |}length=${2})$0"], 610 | "description": "Highest value offset for a given number of bars back." 611 | }, 612 | "hline()" : { 613 | "scope": "pine, pinescript", 614 | "prefix": "hline()", 615 | "body": ["hline(price=${1}, title='${2}', color=${3}, linestyle=${4}, linewidth=${5}, editable=${6})$0"], 616 | "description": "Renders a horizontal line at a given fixed price level." 617 | }, 618 | "hma()" : { 619 | "scope": "pine, pinescript", 620 | "prefix": "hma()", 621 | "body": ["hma(source=${1}, length=${2})$0"], 622 | "description": "Returns the Hull Moving Average." 623 | }, 624 | "hour()" : { 625 | "scope": "pine, pinescript", 626 | "prefix": "hour()", 627 | "body": ["hour(time=${1:time})$0"], 628 | "description": "Hour in exchange timezone for provided UNIX time." 629 | }, 630 | "iff()" : { 631 | "scope": "pine, pinescript", 632 | "prefix": "iff()", 633 | "body": ["iff(${1:condition}, ${2:then}, ${3:_else})$0"], 634 | "description": "if true then/else function." 635 | }, 636 | "input()" : { 637 | "scope": "pine, pinescript", 638 | "prefix": "input()", 639 | "body": ["input(defval=${1}, title='${2}', type=${3}, minval=${4}, maxval=${5}, confirm=${6}, step=${7}, options=${8})$0"], 640 | "description": "Adds an input to your script indicator. User can see and edit inputs on the Format Object dialog of the script study. Script inputs look and behave exactly the same as inputs of built-in Technical Analysis indicators." 641 | }, 642 | "int()" : { 643 | "scope": "pine, pinescript", 644 | "prefix": "int()", 645 | "body": ["int($0)"], 646 | "description": "Casts na to int." 647 | }, 648 | "kagi()" : { 649 | "scope": "pine, pinescript", 650 | "prefix": "kagi()", 651 | "body": ["kagi(symbol=${1}, reversal=${2})$0"], 652 | "description": "Creates a ticker identifier for requesting kagi values." 653 | }, 654 | "kc()" : { 655 | "scope": "pine, pinescript", 656 | "prefix": "kc()", 657 | "body": ["[${1:kcmiddle}, ${2:kcupper}, ${3:kclower}] = kc(series=${4}, length=${5}, mult=${6})$0"], 658 | "description": "Keltner Channels. Keltner channel is a technical analysis indicator showing a central moving average line plus channel lines at a distance above and below." 659 | }, 660 | "kcw()" : { 661 | "scope": "pine, pinescript", 662 | "prefix": "kcw()", 663 | "body": ["kcw(series=${1}, length=${2}, mult=${3}${4:, useTrueRange=true})$0"], 664 | "description": "Adds an input to your script indicator. User can see and edit inputs on the Format Object dialog of the script study. Script inputs look and behave exactly the same as inputs of built-in Technical Analysis indicators." 665 | }, 666 | "label()" : { 667 | "scope": "pine, pinescript", 668 | "prefix": "label()", 669 | "body": ["label($0)"], 670 | "description": "Casts na to label." 671 | }, 672 | "label.delete()" : { 673 | "scope": "pine, pinescript", 674 | "prefix": "label.delete()", 675 | "body": ["label.delete(id=${1})$0"], 676 | "description": "Deletes the specified label object. If it has already been deleted, does nothing." 677 | }, 678 | "label.get_text()" : { 679 | "scope": "pine, pinescript", 680 | "prefix": "label.get_text()", 681 | "body": ["label.get_text(id=${1})$0"], 682 | "description": "Returns the text of this label object." 683 | }, 684 | "label.get_x()" : { 685 | "scope": "pine, pinescript", 686 | "prefix": "label.get_x()", 687 | "body": ["label.get_x(id=${1})$0"], 688 | "description": "Returns UNIX time or bar_index(depending on the last xloc value set) of this label's position'." 689 | }, 690 | "label.get_y()" : { 691 | "scope": "pine, pinescript", 692 | "prefix": "label.get_y()", 693 | "body": ["label.get_y(id=${1})$0"], 694 | "description": "Returns price of this label's position." 695 | }, 696 | "label.new()" : { 697 | "scope": "pine, pinescript", 698 | "prefix": "label.new()", 699 | "body": ["label.new(x=${1}, y=${2}, text=${3}${4:, xloc=xloc.bar_time}${5:, yloc=yloc.price}${6:, color=}${7:, style=}${8:, textcolor=}${9:, size=size.small}${10:, textalign=text.align_center})$0"], 700 | "description": "Creates a new label object." 701 | }, 702 | "label.set_color()" : { 703 | "scope": "pine, pinescript", 704 | "prefix": "label.set_color()", 705 | "body": ["label.set_color(id=${1}, color=${2})$0"], 706 | "description": "Sets label border and arrow color." 707 | }, 708 | "label.set_size()" : { 709 | "scope": "pine, pinescript", 710 | "prefix": "label.set_size()", 711 | "body": ["label.set_size(id=${1}, color=${2|size.auto,size.tiny,size.small,size.normal,size.large,size.huge|})$0"], 712 | "description": "Sets label border and arrow color." 713 | }, 714 | "label.set_style()" : { 715 | "scope": "pine, pinescript", 716 | "prefix": "label.set_style()", 717 | "body": ["label.set_style(id=${1}, style=${2|label.style_none,label.style_xcross,label.style_cross,label.style_triangleup,label.style_triangledown,label.style_flag,label.style_circle,label.style_arrowup,label.style_arrowdown,label.style_label_up,label.style_label_down,label.style_label_left,label.style_label_right,label.style_label_center,label.style_square,label.style_diamond|})$0"], 718 | "description": "Sets label style." 719 | }, 720 | "label.set_text()" : { 721 | "scope": "pine, pinescript", 722 | "prefix": "label.set_text()", 723 | "body": ["label.set_text(id=${1}, text=${2})$0"], 724 | "description": "Sets label text." 725 | }, 726 | "label.set_textalign()" : { 727 | "scope": "pine, pinescript", 728 | "prefix": "label.set_textalign()", 729 | "body": ["label.set_textalign(id=${1}, textalign=${2|text.align_left,text.align_center,text.align_right|})$0"], 730 | "description": "Sets the alignment for the label text." 731 | }, 732 | "label.set_textcolor()" : { 733 | "scope": "pine, pinescript", 734 | "prefix": "label.set_textcolor()", 735 | "body": ["label.set_textcolor(id=${1}, textcolor=${2})$0"], 736 | "description": "Sets color of the label text." 737 | }, 738 | "label.set_x()" : { 739 | "scope": "pine, pinescript", 740 | "prefix": "label.set_x()", 741 | "body": ["label.set_x(id=${1}, x=${2})$0"], 742 | "description": "Sets bar index or bar time(depending on the xloc) of the label position." 743 | }, 744 | "label.set_xloc()" : { 745 | "scope": "pine, pinescript", 746 | "prefix": "label.set_xloc()", 747 | "body": ["label.set_xloc(id=${1}, x=${2}, xloc=xloc.${3|bar_index,bar_time|})$0"], 748 | "description": "Sets x-location and new bar index/time value." 749 | }, 750 | "label.set_xy()" : { 751 | "scope": "pine, pinescript", 752 | "prefix": "label.set_xy()", 753 | "body": ["label.set_xy(id=${1}, x=${2}, y=${3})$0"], 754 | "description": "Sets bar index/time of the label position." 755 | }, 756 | "label.set_y()" : { 757 | "scope": "pine, pinescript", 758 | "prefix": "label.set_y()", 759 | "body": ["label.set_y(id=${1}, y=${2})$0"], 760 | "description": "Sets price of the label position." 761 | }, 762 | "label.set_yloc()" : { 763 | "scope": "pine, pinescript", 764 | "prefix": "label.set_yloc()", 765 | "body": ["label.set_yloc(id=${1}, yloc=yloc.${2|price,abovebar,belowbar|})$0"], 766 | "description": "Sets new y-location calculation algorithm." 767 | }, 768 | "line()" : { 769 | "scope": "pine, pinescript", 770 | "prefix": "line()", 771 | "body": ["line($0)"], 772 | "description": "Casts na to line." 773 | }, 774 | "line.delete()" : { 775 | "scope": "pine, pinescript", 776 | "prefix": "line.delete()", 777 | "body": ["line.delete(id=${1})$0"], 778 | "description": "Deletes the specified line object. If it has already been deleted, does nothing." 779 | }, 780 | "line.get_x1()" : { 781 | "scope": "pine, pinescript", 782 | "prefix": "line.get_x1()", 783 | "body": ["line.get_x1(id=${1})$0"], 784 | "description": "Returns UNIX time or bar index (depending on the last xloc value set) of the first point of the line." 785 | }, 786 | "line.get_x2()" : { 787 | "scope": "pine, pinescript", 788 | "prefix": "line.get_x2()", 789 | "body": ["line.get_x2(id=${1})$0"], 790 | "description": "Returns UNIX time or bar index (depending on the last xloc value set) of the second point of the line." 791 | }, 792 | "line.get_y1()" : { 793 | "scope": "pine, pinescript", 794 | "prefix": "line.get_y1()", 795 | "body": ["line.get_y1(id=${1})$0"], 796 | "description": "Returns price of the first point of the line." 797 | }, 798 | "line.get_y2()" : { 799 | "scope": "pine, pinescript", 800 | "prefix": "line.get_y2()", 801 | "body": ["line.get_y2(id=${1})$0"], 802 | "description": "Returns price of the second point of the line." 803 | }, 804 | "line.new()" : { 805 | "scope": "pine, pinescript", 806 | "prefix": "line.new()", 807 | "body": ["line.new(x1=${1}, y1=${2}, x2=${3}, y2=${4}${5:, xloc=xloc.bar_time}${6:, extend=extend.none}${7:, color=color.blue}${8:, style=line.style_solid}${9:, width=1})$0"], 808 | "description": "Creates new line object." 809 | }, 810 | "line.set_color()" : { 811 | "scope": "pine, pinescript", 812 | "prefix": "line.set_color()", 813 | "body": ["line.set_color(id=${1}, color=${2})$0"], 814 | "description": "Sets the line color." 815 | }, 816 | "line.set_extend()" : { 817 | "scope": "pine, pinescript", 818 | "prefix": "line.set_extend()", 819 | "body": ["line.set_extend(id=${1}, extend=extend.${2|none,right,left,both|})$0"], 820 | "description": "Sets the extending type of this line object." 821 | }, 822 | "line.set_style()" : { 823 | "scope": "pine, pinescript", 824 | "prefix": "line.set_style()", 825 | "body": ["line.set_style(id=${1}, style=line.style_${2|solid,dotted,dashed,arrow_left,arrow_right,arrow_both|})$0"], 826 | "description": "Sets the style type of this line object." 827 | }, 828 | "line.set_width()" : { 829 | "scope": "pine, pinescript", 830 | "prefix": "line.set_width()", 831 | "body": ["line.set_width(id=${1}, width=${2})$0"], 832 | "description": "Sets the line width." 833 | }, 834 | "line.set_x1()" : { 835 | "scope": "pine, pinescript", 836 | "prefix": "line.set_x1()", 837 | "body": ["line.set_x1(id=${1}, x=${2})$0"], 838 | "description": "Sets bar index or bar time(depending on the xloc) of the first point." 839 | }, 840 | "line.set_x2()" : { 841 | "scope": "pine, pinescript", 842 | "prefix": "line.set_x2()", 843 | "body": ["line.set_x2(id=${1}, x=${2})$0"], 844 | "description": "Sets bar index or bar time(depending on the xloc) of the second point." 845 | }, 846 | "line.set_xloc()" : { 847 | "scope": "pine, pinescript", 848 | "prefix": "line.set_xloc()", 849 | "body": ["line.set_xloc(id=${1}, x1=${2}, x2=${3}, xloc=xloc.bar_${4|index,time|})$0"], 850 | "description": "Sets the x-location typand new bar index/time values." 851 | }, 852 | "line.set_xy1()" : { 853 | "scope": "pine, pinescript", 854 | "prefix": "line.set_xy1()", 855 | "body": ["line.set_xy1(id=${1}, x=${2}, y=${3})$0"], 856 | "description": "Sets bar index/time and price of the first point." 857 | }, 858 | "line.set_xy2()" : { 859 | "scope": "pine, pinescript", 860 | "prefix": "line.set_xy2()", 861 | "body": ["line.set_xy2(id=${1}, x=${2}, y=${3})$0"], 862 | "description": "Sets bar index/time and price of the second point." 863 | }, 864 | "line.set_y1()" : { 865 | "scope": "pine, pinescript", 866 | "prefix": "line.set_y1()", 867 | "body": ["line.set_y1(id=${1}, y=${2})$0"], 868 | "description": "Sets price of the first point." 869 | }, 870 | "line.set_y2()" : { 871 | "scope": "pine, pinescript", 872 | "prefix": "line.set_y2()", 873 | "body": ["line.set_y2(id=${1}, y=${2})$0"], 874 | "description": "Sets price of the second point." 875 | }, 876 | "linebreak()" : { 877 | "scope": "pine, pinescript", 878 | "prefix": "linebreak()", 879 | "body": ["linebreak(symbol=${1}, number_of_lines=${2})$0"], 880 | "description": "Creates a ticker identifier for requesting line break values." 881 | }, 882 | "linreg()" : { 883 | "scope": "pine, pinescript", 884 | "prefix": "linreg()", 885 | "body": ["linreg(source=${1}, length=${2}, offset=${3})$0"], 886 | "description": "Linear regression curve. A line that best fits the prices specified over a user-defined time period. It is calculated using the least squares method. The result of this function is calculated using the formula: linreg = intercept + slope * (length - 1 - offset), where length is the y argument, offset is the z argument, intercept and slope are the values calculated with the least squares method on source series (x argument)." 887 | }, 888 | "log()" : { 889 | "scope": "pine, pinescript", 890 | "prefix": "log()", 891 | "body": ["log($0)"], 892 | "description": "Natural logarithm of any x > 0 is the unique 'y' such that e^y=x." 893 | }, 894 | "log10()" : { 895 | "scope": "pine, pinescript", 896 | "prefix": "log10()", 897 | "body": ["log10($0)"], 898 | "description": "Base 10 logarithm of any x > 0 is the unique 'y' such that 10^y=x." 899 | }, 900 | "lowest()" : { 901 | "scope": "pine, pinescript", 902 | "prefix": "lowest()", 903 | "body": ["lowest${1|(,(source=\\, |}length=${2})$0"], 904 | "description": "Lowest value for a given number of bars back." 905 | }, 906 | "lowestbars()" : { 907 | "scope": "pine, pinescript", 908 | "prefix": "lowestbars()", 909 | "body": ["lowestbars${1|(,(source=\\, |}length=${2})$0"], 910 | "description": "Lowest value offset for a given number of bars back." 911 | }, 912 | "macd()" : { 913 | "scope": "pine, pinescript", 914 | "prefix": "macd()", 915 | "body": ["[${1:macd_line}, ${2:macd_signal}, ${3:macd_hist}] = macd(source=${4}, fastlen=${5}, slowlen=${6}, siglen=${7})$0"], 916 | "description": "MACD (moving average convergence/divergence). It is supposed to reveal changes in the strength, direction, momentum, and duration of a trend in a stock's price." 917 | }, 918 | "max()" : { 919 | "scope": "pine, pinescript", 920 | "prefix": "max()", 921 | "body": ["max($0)"], 922 | "description": "Returns the greatest of multiple values." 923 | }, 924 | "max_bars_back()" : { 925 | "scope": "pine, pinescript", 926 | "prefix": "max_bars_back()", 927 | "body": ["max_bars_back(var=${1}, num=${2})$0"], 928 | "description": "Cap the stored series length." 929 | }, 930 | "mfi()" : { 931 | "scope": "pine, pinescript", 932 | "prefix": "mfi()", 933 | "body": ["mfi(series=${1}, length=${2})$0"], 934 | "description": "Money Flow Index." 935 | }, 936 | "min()" : { 937 | "scope": "pine, pinescript", 938 | "prefix": "min()", 939 | "body": ["min($0)"], 940 | "description": "Returns the smallest of multiple values." 941 | }, 942 | "minute()" : { 943 | "scope": "pine, pinescript", 944 | "prefix": "minute()", 945 | "body": ["minute(time=${1})$0"], 946 | "description": "Minute (in exchange timezone) for provided UNIX time." 947 | }, 948 | "mom()" : { 949 | "scope": "pine, pinescript", 950 | "prefix": "mom()", 951 | "body": ["mom(source=${1}, length=${2})$0"], 952 | "description": "Difference of x-x[y]." 953 | }, 954 | "month()" : { 955 | "scope": "pine, pinescript", 956 | "prefix": "month()", 957 | "body": ["month(time=${1})$0"], 958 | "description": "Month (in exchange timezone) for provided UNIX time." 959 | }, 960 | "na()" : { 961 | "scope": "pine, pinescript", 962 | "prefix": "na()", 963 | "body": ["na($0)"], 964 | "description": "Test value if its NaN." 965 | }, 966 | "nz()" : { 967 | "scope": "pine, pinescript", 968 | "prefix": "nz()", 969 | "body": ["nz(x=${1}${2:, y=})$0"], 970 | "description": "Replaces NaN values with zeros or given value." 971 | }, 972 | "offset()" : { 973 | "scope": "pine, pinescript", 974 | "prefix": "offset()", 975 | "body": ["offset(source=${1}, offset=${2})$0"], 976 | "description": "Shifts series x on the y bars to the right." 977 | }, 978 | "percentile_linear_interpolation()" : { 979 | "scope": "pine, pinescript", 980 | "prefix": "percentile_linear_interpolation()", 981 | "body": ["percentile_linear_interpolation(source=${1}, length=${2}, percentage=${3})$0"], 982 | "description": "Calculates percentile using method of linear interpolation between the two nearest ranks." 983 | }, 984 | "percentile_nearest_rank()" : { 985 | "scope": "pine, pinescript", 986 | "prefix": "percentile_nearest_rank()", 987 | "body": ["percentile_nearest_rank(source=${1}, length=${2}, percentage=${3})$0"], 988 | "description": "Calculates percentile using method of nearest rank." 989 | }, 990 | "percentrank()" : { 991 | "scope": "pine, pinescript", 992 | "prefix": "percentrank()", 993 | "body": ["percentrank(source=${1}, length=${2})$0"], 994 | "description": "Percent rank is the percents of how many previous values was less than or equal to the current value of given series." 995 | }, 996 | "pivothigh()" : { 997 | "scope": "pine, pinescript", 998 | "prefix": "pivothigh()", 999 | "body": ["pivothigh${1|(,(source=\\, |}leftbars=${2}, rightbars=${3})$0"], 1000 | "description": "Returns price of the pivot high point. It returns 'NaN', if there was no pivot high point." 1001 | }, 1002 | "pivotlow()" : { 1003 | "scope": "pine, pinescript", 1004 | "prefix": "pivotlow()", 1005 | "body": ["pivotlow${1|(,(source=\\, |}leftbars=${2}, rightbars=${3})$0"], 1006 | "description": "Returns price of the pivot low point. It returns 'NaN', if there was no pivot low point." 1007 | }, 1008 | "plot()" : { 1009 | "scope": "pine, pinescript", 1010 | "prefix": "plot()", 1011 | "body": [ 1012 | "plot(series=${1}${2:, title=''}${3:, color=color.blue}${4:, linewidth=1}${5:, style=plot.style_line}${6:, trackprice=true}${7:, transp=0}${8:, histbase=0}${9:, offset=0}${10:, join=true}${11:, editable=true}${12:, show_last=1}${13:, display=display.none})", 1013 | "$0" 1014 | ], 1015 | "description": "Plots a series of data on the chart." 1016 | }, 1017 | "plotarrow()" : { 1018 | "scope": "pine, pinescript", 1019 | "prefix": "plotarrow()", 1020 | "body": [ 1021 | "plotarrow(series=${1}${2:, title=''}${3:, colorup=color.blue}${4:, colordown=color.navy}${5:, transp=0}${6:, offset=0}${7:, minheight=0}${8:, maxheight=0}${9:, editable=0}${10:, show_last=1}${11:, display=display.none})", 1022 | "$0" 1023 | ], 1024 | "description": "Plots a series of conditional up/down arrows on the chart." 1025 | }, 1026 | "plotbar()" : { 1027 | "scope": "pine, pinescript", 1028 | "prefix": "plotbar()", 1029 | "body": [ 1030 | "plotbar(open=${1}, high=${2}, low=${3}, close=${4}${5:, title=''}${6:, color=color.blue}${7:, editable=true}${8:, show_last=1}${8:, display=display.none})", 1031 | "$0" 1032 | ], 1033 | "description": "Plots ohlc bars on the chart." 1034 | }, 1035 | "plotcandle()" : { 1036 | "scope": "pine, pinescript", 1037 | "prefix": "plotcandle()", 1038 | "body": [ 1039 | "plotcandle(open=${1}, high=${2}, low=${3}, close=${4}${5:, title=''}${6:, color=color.blue}${7:, wickcolor=color.navy}${8:, editable=true}${9:, show_last=1}${10:, bordercolor=color.teal}${11:, display=display.none})", 1040 | "$0" 1041 | ], 1042 | "description": "Plots candles on the chart." 1043 | }, 1044 | "plotchar()" : { 1045 | "scope": "pine, pinescript", 1046 | "prefix": "plotchar()", 1047 | "body": [ 1048 | "plotchar(series=${1}${2:, title=''}${3:, char=''}${4:, location=location.absolute}${5:, color=color.blue}${6:, transp=0}${7:, offset=0}${8:, text=''}${9:, textcolor=color.navy}${10:, editable=true}${11:, size=size.small}${12:, show_last=1}${11:, display=display.none})", 1049 | "$0" 1050 | ], 1051 | "description": "Plots a series of conditional shapes using Unicode characters on the chart." 1052 | }, 1053 | "plotshape()" : { 1054 | "scope": "pine, pinescript", 1055 | "prefix": "plotshape()", 1056 | "body": [ 1057 | "plotshape(series=${1}${2:, title=''}${3:, style=shape.xcross}${4:, location=location.absolute}${5:, color=color.blue}${6:, transp=0}${7:, offset=0}${8:, text=''}${9:, textcolor=color.navy}${10:, editable=true}${11:, size=size.small}${12:, show_last=1}${11:, display=display.none})", 1058 | "$0" 1059 | ], 1060 | "description": "Plots visual shapes on the chart." 1061 | }, 1062 | "pointfigure()" : { 1063 | "scope": "pine, pinescript", 1064 | "prefix": "pointfigure()", 1065 | "body": ["pointfigure(symbol=${1}, source=${2}, style=${3}, param=${4}, reversal=${5})$0"], 1066 | "description": "Creates a ticker for requesting Point & Figure values." 1067 | }, 1068 | "pow()" : { 1069 | "scope": "pine, pinescript", 1070 | "prefix": "pow()", 1071 | "body": ["pow(base=${1}, exponent=${2})$0"], 1072 | "description": "Mathematical power function." 1073 | }, 1074 | "renko()" : { 1075 | "scope": "pine, pinescript", 1076 | "prefix": "renko()", 1077 | "body": ["renko(symbol=${1}, style=${2}, param=${3})$0"], 1078 | "description": "Creates a ticker for requesting Renko values." 1079 | }, 1080 | "rising()" : { 1081 | "scope": "pine, pinescript", 1082 | "prefix": "rising()", 1083 | "body": ["rising(source=${1}, length=${2})$0"], 1084 | "description": "Test if the x series is now rising for y bars long." 1085 | }, 1086 | "rma()" : { 1087 | "scope": "pine, pinescript", 1088 | "prefix": "rma()", 1089 | "body": ["rma(source=${1}, length=${2})$0"], 1090 | "description": "Moving average used in RSI. It is the exponentially weighted moving average with alpha = 1 / length." 1091 | }, 1092 | "roc()" : { 1093 | "scope": "pine, pinescript", 1094 | "prefix": "roc()", 1095 | "body": ["roc(source=${1}, length=${2})$0"], 1096 | "description": "Function roc (rate of change) showing the difference between current value of x and the value of x that was y days ago." 1097 | }, 1098 | "round()" : { 1099 | "scope": "pine, pinescript", 1100 | "prefix": "round()", 1101 | "body": ["round(${1})$0"], 1102 | "description": "The round function returns the value of the argument rounded to the nearest integer, with ties rounding up." 1103 | }, 1104 | "rsi()" : { 1105 | "scope": "pine, pinescript", 1106 | "prefix": "rsi()", 1107 | "body": ["rsi(x=${1}, y=${2})$0"], 1108 | "description": "Relative strength index. It is calculated based on rma's of upward and downward change of x." 1109 | }, 1110 | "sar()" : { 1111 | "scope": "pine, pinescript", 1112 | "prefix": "sar()", 1113 | "body": ["sar(start=${1}, inc=${2}, max=${3})$0"], 1114 | "description": "Parabolic SAR (parabolic stop and reverse) is a method devised by J. Welles Wilder, Jr., to find potential reversals in the market price direction of traded goods." 1115 | }, 1116 | "second()" : { 1117 | "scope": "pine, pinescript", 1118 | "prefix": "second()", 1119 | "body": ["second(time=${1})$0"], 1120 | "description": "Second (in exchange timezone) for provided UNIX time." 1121 | }, 1122 | "security()" : { 1123 | "scope": "pine, pinescript", 1124 | "prefix": "security()", 1125 | "body": ["security(symbol=${1}, resolution=${2}, expression=${3}${4:, gaps=barmerge.gaps_on}${5:, lookahead=barmerge.lookahead_on})$0"], 1126 | "description": "Request another symbol/resolution" 1127 | }, 1128 | "sign()" : { 1129 | "scope": "pine, pinescript", 1130 | "prefix": "sign()", 1131 | "body": ["sign(${1})$0"], 1132 | "description": "Sign (signum) of x is zero if the x is zero, 1.0 if the x is greater than zero, -1.0 if the x is less than zero." 1133 | }, 1134 | "sin()" : { 1135 | "scope": "pine, pinescript", 1136 | "prefix": "sin()", 1137 | "body": ["sin(${1})$0"], 1138 | "description": "Trigonometric sine of an angle." 1139 | }, 1140 | "sma()" : { 1141 | "scope": "pine, pinescript", 1142 | "prefix": "sma()", 1143 | "body": ["sma(source=${1}, length=${2})$0"], 1144 | "description": "The sma function returns the moving average, that is the sum of last y values of x, divided by y." 1145 | }, 1146 | "sqrt()" : { 1147 | "scope": "pine, pinescript", 1148 | "prefix": "sqrt()", 1149 | "body": ["sqrt(${1})$0"], 1150 | "description": "Square root of any x >= 0 is the unique y >= 0 such that y^2 = x." 1151 | }, 1152 | "stdev()" : { 1153 | "scope": "pine, pinescript", 1154 | "prefix": "stdev()", 1155 | "body": ["stdev(source=${1}, length=${2})$0"], 1156 | "description": "Standard deviation." 1157 | }, 1158 | "stoch()" : { 1159 | "scope": "pine, pinescript", 1160 | "prefix": "stoch()", 1161 | "body": ["stoch(source=${1}, high=${2}, low=${3}, length=${4})$0"], 1162 | "description": "Stochastic. It is calculated by a formula: 100 * (close - lowest(low, length)) / (highest(high, length) - lowest(low, length))." 1163 | }, 1164 | "str.replace_all()" : { 1165 | "scope": "pine, pinescript", 1166 | "prefix": "str.replace_all()", 1167 | "body": ["str.replace_all(source=${1}, target=${2}, replacement=${3})$0"], 1168 | "description": "Replaces each occurrence of the target string in the source string with the replacement string." 1169 | }, 1170 | "strategy()" : { 1171 | "scope": "pine, pinescript", 1172 | "prefix": "strategy()", 1173 | "body": [ 1174 | "strategy(title='${1}', shorttitle='${2}', overlay=${3|true,false|}${4:, format=format.${5|inherit,price,volume|},}", 1175 | "\t precision=${6}, scale=scale.${7|right,left,none|}, pyramiding=${8},", 1176 | "\t calc_on_order_fills=${9}, calc_on_every_tick=${10}, max_bars_back=${11},", 1177 | "\t backtest_fill_limits_assumption=${12}, default_qty_type=${13}, default_qty_value=${14},", 1178 | "\t initial_capital=${15}, currency=currency.${16:USD}, slippage=${17}, commission_type=${18}, commission_value=${19},", 1179 | "\t process_orders_on_close=${20}, close_entries_rule=${21}", 1180 | "\t )$0"], 1181 | "description": "The function sets a number of strategy properties." 1182 | }, 1183 | "strategy.cancel()" : { 1184 | "scope": "pine, pinescript", 1185 | "prefix": "strategy.cancel()", 1186 | "body": ["strategy.cancel(id=${1}${2:, when=${3}})$0"], 1187 | "description": "It is a command to cancel/deactivate pending orders by referencing their names, which were generated by the functions: strategy.order, strategy.entry and strategy.exit." 1188 | }, 1189 | "strategy.cancel_all()" : { 1190 | "scope": "pine, pinescript", 1191 | "prefix": "strategy.cancel_all()", 1192 | "body": ["strategy.cancel_all(${1:when=${2}})$0"], 1193 | "description": "It is a command to cancel/deactivate all pending orders, which were generated by the functions: strategy.order, strategy.entry and strategy.exit." 1194 | }, 1195 | "strategy.close()" : { 1196 | "scope": "pine, pinescript", 1197 | "prefix": "strategy.close()", 1198 | "body": ["strategy.close(id=${1}${2:, when=${3}}${4:, comment=}${5:, qty=}${6:, qty_percent=})$0"], 1199 | "description": "It is a command to exit from the entry with the specified ID. If there were multiple entry orders with the same ID, all of them are exited at once. If there are no open entries with the specified ID by the moment the command is triggered, the command will not come into effect. The command uses market order. Every entry is closed by a separate market order." 1200 | }, 1201 | "strategy.close_all()" : { 1202 | "scope": "pine, pinescript", 1203 | "prefix": "strategy.close_all()", 1204 | "body": ["strategy.close_all(${1:when=${2}}${3:, comment=})$0"], 1205 | "description": "It is a command to exit from current market position making it flat. If there is no open market position by the moment the command is triggered, the command will not come into effect." 1206 | }, 1207 | "strategy.entry()" : { 1208 | "scope": "pine, pinescript", 1209 | "prefix": "strategy.entry()", 1210 | "body": ["strategy.entry(id=${1}, long=strategy.${2|long,short|}${3:, qty=${4}}${5:, limit=${6}}${7:, stop=${8}}${9:, oca_name=${10}}${11:, oca_type=${12}}${13:, comment=${14}}${15:, when=${16}})","$0"], 1211 | "description": "It is a command to enter market position." 1212 | }, 1213 | "strategy.exit()" : { 1214 | "scope": "pine, pinescript", 1215 | "prefix": "strategy.exit()", 1216 | "body": ["strategy.exit(id=${1}, from_entry=${2}${3:, qty=}${4:, qty_percent=}${5:, profit=}${6:, limit=}${7:, loss=}${8:, stop=}${9:, trail_price=}${10:, trail_points=}${11:, trail_offset=}${12:, oca_name=}${13:, comment=}${14:, when=})", "$0"], 1217 | "description": "It is a command to exit either a specific entry, or whole market position. " 1218 | }, 1219 | "strategy.order()" : { 1220 | "scope": "pine, pinescript", 1221 | "prefix": "strategy.order()", 1222 | "body": ["strategy.order(id=${1}, long=strategy.${2|long,short|}${3:, qty=${4}}${5:, limit=${6}}${7:, stop=${8}}${9:, oca_name=${10}}${11:, oca_type=${12}}${13:, comment=${14}}${15:, when=${16}})","$0"], 1223 | "description": "It is a command to place order. If an order with the same ID is already pending, it is possible to modify the order. If there is no order with the specified ID, a new order is placed." 1224 | }, 1225 | "strategy.risk.allow_entry_in()" : { 1226 | "scope": "pine, pinescript", 1227 | "prefix": "strategy.risk.allow_entry_in()", 1228 | "body": ["strategy.risk.allow_entry_in(${1:value=strategy.direction.${2|all,long,short|}})","$0"], 1229 | "description": "The purpose of this rule is to forbid short entries, only long etries will be placed. The rule affects the following function: 'entry'." 1230 | }, 1231 | "strategy.risk.max_cons_loss_days()" : { 1232 | "scope": "pine, pinescript", 1233 | "prefix": "strategy.risk.max_cons_loss_days()", 1234 | "body": ["strategy.risk.max_cons_loss_days(count=${1})","$0"], 1235 | "description": "The purpose of this rule is to cancel all pending orders, close all open positions and stop placing orders after a specified number of consecutive days with losses. The rule affects the whole strategy." 1236 | }, 1237 | "strategy.risk.max_drawdown()" : { 1238 | "scope": "pine, pinescript", 1239 | "prefix": "strategy.risk.max_drawdown()", 1240 | "body": ["strategy.risk.max_drawdown(value=${1}, type=strategy.${2|cash,percent_of_equity|})","$0"], 1241 | "description": "The purpose of this rule is to determine maximum drawdown. The rule affects the whole strategy. Once the maximum drawdown value is reached, all pending orders are cancelled, all open positions are closed and no new orders can be placed." 1242 | }, 1243 | "strategy.risk.max_intraday_filled_orders()" : { 1244 | "scope": "pine, pinescript", 1245 | "prefix": "strategy.risk.max_intraday_filled_orders()", 1246 | "body": ["strategy.risk.max_intraday_filled_orders(count=${1})","$0"], 1247 | "description": "The purpose of this rule is to determine maximum number of filled orders per 1 day (per 1 bar, if chart resolution is higher than 1 day). The rule affects the whole strategy. Once the maximum number of filled orders is reached, all pending orders are cancelled, all open positions are closed and no new orders can be placed till the end of the current trading session." 1248 | }, 1249 | "strategy.risk.max_intraday_loss()" : { 1250 | "scope": "pine, pinescript", 1251 | "prefix": "strategy.risk.max_intraday_loss()", 1252 | "body": ["strategy.risk.max_intraday_loss(value=${1}, type=strategy.${2|cash,percent_of_equity|})","$0"], 1253 | "description": "The purpose of this rule is to determine maximum loss per 1 day (per 1 bar, if chart resolution is higher than 1 day). The rule affects the whole strategy. Once the maximum loss value is reached, all pending orders are cancelled, all open positions are closed and no new orders can be placed till the end of the current trading session." 1254 | }, 1255 | "strategy.risk.max_position_size()" : { 1256 | "scope": "pine, pinescript", 1257 | "prefix": "strategy.risk.max_position_size()", 1258 | "body": ["strategy.risk.max_position_size(contracts=${1})","$0"], 1259 | "description": "The purpose of this rule is to determine maximum size of a market position. The rule affects the following function: strategy.entry. The 'entry' quantity can be reduced (if needed) to such number of contracts/shares/lots/units, so the total position size doesn't exceed the value specified in 'strategy.risk.max_position_size'. If minimum possible quantity still violates the rule, the order will not be placed." 1260 | }, 1261 | "string()" : { 1262 | "scope": "pine, pinescript", 1263 | "prefix": "string()", 1264 | "body": ["string(${1})$0"], 1265 | "description": "Casts na to string." 1266 | }, 1267 | "study()" : { 1268 | "scope": "pine, pinescript", 1269 | "prefix": "study()", 1270 | "body": [ 1271 | "study(title='${1}', shorttitle='${2}', overlay=${3|true,false|}${4:, format=format.${5|inherit,price,volume|},}", 1272 | "\t precision=${6}, scale=scale.${7|right,left,none|}, max_bars_back=${8}", 1273 | "\t )$0"], 1274 | "description": "The function sets a number of study properties." 1275 | }, 1276 | "sum()" : { 1277 | "scope": "pine, pinescript", 1278 | "prefix": "sum()", 1279 | "body": ["sum(source=${1}, length=${2})$0"], 1280 | "description": "The Sum function returns the sliding sum of last y values of x." 1281 | }, 1282 | "supertrend()" : { 1283 | "scope": "pine, pinescript", 1284 | "prefix": "supertrend()", 1285 | "body": ["[${1:supertrend}, ${2:st_direction}] = supertrend(fact=${3}, atrPeriod=${4})","$0"], 1286 | "description": "The Supertrend indicator." 1287 | }, 1288 | "swma()" : { 1289 | "scope": "pine, pinescript", 1290 | "prefix": "swma()", 1291 | "body": ["swma(${1:x=${2:close}})$0"], 1292 | "description": "Symmetrically weighted moving average with fixed length: 4. Weights: [1/6, 2/6, 2/6, 1/6]." 1293 | }, 1294 | "tan()" : { 1295 | "scope": "pine, pinescript", 1296 | "prefix": "tan()", 1297 | "body": ["tan(${1})$0"], 1298 | "description": "Returns the trigonometric tangent of an angle." 1299 | }, 1300 | "tickerid()" : { 1301 | "scope": "pine, pinescript", 1302 | "prefix": "tickerid()", 1303 | "body": ["tickerid(prefix=${1}, ticker=${2}, session=${3}, adjustment=${4})$0"], 1304 | "description": "Creates a ticker identifier for requesting additional data for script." 1305 | }, 1306 | "time()" : { 1307 | "scope": "pine, pinescript", 1308 | "prefix": "time()", 1309 | "body": ["time(resolution=${1}${2:, session=${3}})$0"], 1310 | "description": "Function time returns UNIX time of current bar for the specified resolution and session or NaN if time point is out-of-session." 1311 | }, 1312 | "timestamp()" : { 1313 | "scope": "pine, pinescript", 1314 | "prefix": "timestamp()", 1315 | "body": ["timestamp(${1:timezone=syminfo.timezone, }year=${2}, month=${3}, day=${4}, hour=${5}, minute=${6}, second=${7})$0"], 1316 | "description": "Function timestamp returns UNIX time of specified date and time." 1317 | }, 1318 | "tostring()" : { 1319 | "scope": "pine, pinescript", 1320 | "prefix": "tostring()", 1321 | "body": ["tostring(x=${1}${2:, y=})$0"], 1322 | "description": "String representation of x argument." 1323 | }, 1324 | "tr()" : { 1325 | "scope": "pine, pinescript", 1326 | "prefix": "tr()", 1327 | "body": ["tr(${1:handle_na=${2|true,false|}})$0"], 1328 | "description": "True range. It is max(high - low, abs(high - close[1]), abs(low - close[1]))" 1329 | }, 1330 | "tsi()" : { 1331 | "scope": "pine, pinescript", 1332 | "prefix": "tsi()", 1333 | "body": ["tsi(source=${1}, short_length=${2}, long_length=${3})$0"], 1334 | "description": "True strength index. It uses moving averages of the underlying momentum of a financial instrument." 1335 | }, 1336 | "valuewhen()" : { 1337 | "scope": "pine, pinescript", 1338 | "prefix": "valuewhen()", 1339 | "body": ["valuewhen(condition=${1}, source=${2}, occurrence=${3})$0"], 1340 | "description": "Source series value when the condition was true on the n-th most recent occurence." 1341 | }, 1342 | "variance()" : { 1343 | "scope": "pine, pinescript", 1344 | "prefix": "variance()", 1345 | "body": ["variance(source=${1}, length=${2})$0"], 1346 | "description": "Variance is the expectation of the squared deviation of a series from its mean (sma), and it informally measures how far a set of numbers are spread out from their mean." 1347 | }, 1348 | "vwap()" : { 1349 | "scope": "pine, pinescript", 1350 | "prefix": "vwap()", 1351 | "body": ["vwap(${1:x=${2}})$0"], 1352 | "description": "Volume weighted average price." 1353 | }, 1354 | "vwma()" : { 1355 | "scope": "pine, pinescript", 1356 | "prefix": "vwma()", 1357 | "body": ["vwma(source=${1}, length=${2})$0"], 1358 | "description": "The vwma function returns volume-weighted moving average of x for y bars back. It is the same as: sma(x * volume, y) / sma(volume, y)" 1359 | }, 1360 | "weekofyear()" : { 1361 | "scope": "pine, pinescript", 1362 | "prefix": "weekofyear()", 1363 | "body": ["weekofyear(${1:time=${2}})$0"], 1364 | "description": "Week of year (in exchange timezone) for provided UNIX time." 1365 | }, 1366 | "wma()" : { 1367 | "scope": "pine, pinescript", 1368 | "prefix": "wma()", 1369 | "body": ["wma(source=${1}, length=${2})$0"], 1370 | "description": "The wma function returns weighted moving average of x for y bars back. In wma weighting factors decrease in arithmetical progression." 1371 | }, 1372 | "wpr()" : { 1373 | "scope": "pine, pinescript", 1374 | "prefix": "wpr()", 1375 | "body": ["wpr(${1:length=${2}})$0"], 1376 | "description": "Williams %R. The oscillator shows the current closing price in relation to the high and low of the past 'length' bars." 1377 | }, 1378 | "year()" : { 1379 | "scope": "pine, pinescript", 1380 | "prefix": "year()", 1381 | "body": ["year(${1:time=${2}})$0"], 1382 | "description": "year (in exchange timezone) for provided UNIX time." 1383 | }, 1384 | ///////////////////////////////// 1385 | //*** UPDATE V4 - Arrays: ***// 1386 | ///////////////////////////////// 1387 | "array.avg()": { 1388 | "scope": "pine, pinescript", 1389 | "prefix": "array.avg()", 1390 | "body": ["array.avg(${1:id=${2}})$0"], 1391 | "description": "The function returns the mean of an array's elements." 1392 | }, 1393 | "array.clear()": { 1394 | "scope": "pine, pinescript", 1395 | "prefix": "array.clear()", 1396 | "body": ["array.clear(${1:id=${2}})$0"], 1397 | "description": "The function removes all elements from an array." 1398 | }, 1399 | "array.concat()": { 1400 | "scope": "pine, pinescript", 1401 | "prefix": "array.concat()", 1402 | "body": ["array.concat(${1:id1=${2}}${3:, id2=${4}})$0"], 1403 | "description": "The function is used to merge two arrays. It pushes all elements from the second array to the first array, and returns the first array." 1404 | }, 1405 | "array.copy()": { 1406 | "scope": "pine, pinescript", 1407 | "prefix": "array.copy()", 1408 | "body": ["array.copy(${1:id=${2}})$0"], 1409 | "description": "The function creates a copy of an existing array." 1410 | }, 1411 | "array.covariance()": { 1412 | "scope": "pine, pinescript", 1413 | "prefix": "array.covariance()", 1414 | "body": ["array.covariance(${1:id1=${2}}${3:, id2=${4}})$0"], 1415 | "description": "The function returns the covariance of two arrays." 1416 | }, 1417 | "array.fill()": { 1418 | "scope": "pine, pinescript", 1419 | "prefix": "array.fill()", 1420 | "body": ["array.fill(${1:id=${2}}${3:, value=${4}}${5:, index_from=${6}}${7:, index_to=${8}})$0"], 1421 | "description": "The function changes all elements in an array to a static value, from the start index (default 0) to the end index (default na)." 1422 | }, 1423 | "array.get()": { 1424 | "scope": "pine, pinescript", 1425 | "prefix": "array.get()", 1426 | "body": ["array.get(${1:id=${2}}${3:, index=${4}})$0"], 1427 | "description": "The function returns an element with the specified index." 1428 | }, 1429 | "array.includes()": { 1430 | "scope": "pine, pinescript", 1431 | "prefix": "array.includes()", 1432 | "body": ["array.includes(${1:id=${2}}${3:, value=${4}})$0"], 1433 | "description": "The function returns true if the value was found in an array, false otherwise." 1434 | }, 1435 | "array.indexof()": { 1436 | "scope": "pine, pinescript", 1437 | "prefix": "array.indexof()", 1438 | "body": ["array.indexof(${1:id=${2}}${3:, value=${4}})$0"], 1439 | "description": "The function returns the index of the first occurrence of the value, or -1 if the value is not found." 1440 | }, 1441 | "array.insert()": { 1442 | "scope": "pine, pinescript", 1443 | "prefix": "array.insert()", 1444 | "body": ["array.insert(${1:id=${2}}${3:, index=${4}}${5:, value=${6}})$0"], 1445 | "description": "The function changes the contents of an array by adding new elements in place." 1446 | }, 1447 | "array.lastindexof()": { 1448 | "scope": "pine, pinescript", 1449 | "prefix": "array.lastindexof()", 1450 | "body": ["array.lastindexof(${1:id=${2}}${3:, value=${4}})$0"], 1451 | "description": "The function returns the index of the last occurrence of the value, or -1 if the value is not found." 1452 | }, 1453 | "array.max()": { 1454 | "scope": "pine, pinescript", 1455 | "prefix": "array.max()", 1456 | "body": ["array.min(${1:id=${2}})$0"], 1457 | "description": "The function returns the element with the largest value from a given array." 1458 | }, 1459 | "array.median()": { 1460 | "scope": "pine, pinescript", 1461 | "prefix": "array.median()", 1462 | "body": ["array.median(${1:id=${2}})$0"], 1463 | "description": "The function returns the median of an array's elements." 1464 | }, 1465 | "array.min()": { 1466 | "scope": "pine, pinescript", 1467 | "prefix": "array.min()", 1468 | "body": ["array.min(${1:id=${2}})$0"], 1469 | "description": "The function returns the element with the lowest value from a given array." 1470 | }, 1471 | "array.mode()": { 1472 | "scope": "pine, pinescript", 1473 | "prefix": "array.mode()", 1474 | "body": ["array.mode(${1:id=${2}})$0"], 1475 | "description": "The function returns the mode of an array's elements. If there are several values with the same frequency, it returns the smallest value." 1476 | }, 1477 | "array.new_bool()": { 1478 | "scope": "pine, pinescript", 1479 | "prefix": "array.newbool()", 1480 | "body": ["array.newbool(${1:size=${2}}${3:, initial_value=${4}})$0"], 1481 | "description": "The function creates a new array object." 1482 | }, 1483 | "array.new_color()": { 1484 | "scope": "pine, pinescript", 1485 | "prefix": "array.newcolor()", 1486 | "body": ["array.newcolor(${1:size=${2}}${3:, initial_value=${4}})$0"], 1487 | "description": "The function creates a new array object." 1488 | }, 1489 | "array.new_float()": { 1490 | "scope": "pine, pinescript", 1491 | "prefix": "array.newfloat()", 1492 | "body": ["array.newfloat(${1:size=${2}}${3:, initial_value=${4}})$0"], 1493 | "description": "The function creates a new array object." 1494 | }, 1495 | "array.new_int()": { 1496 | "scope": "pine, pinescript", 1497 | "prefix": "array.newint()", 1498 | "body": ["array.newint(${1:size=${2}}${3:, initial_value=${4}})$0"], 1499 | "description": "The function creates a new array object." 1500 | }, 1501 | "array.pop()": { 1502 | "scope": "pine, pinescript", 1503 | "prefix": "array.pop()", 1504 | "body": ["array.pop(${1:id=${2}})$0"], 1505 | "description": "The function removes the last element from an array and returns that element." 1506 | }, 1507 | "array.push()": { 1508 | "scope": "pine, pinescript", 1509 | "prefix": "array.push()", 1510 | "body": ["array.push(${1:id=${2}}${3:, value=${4}})$0"], 1511 | "description": "The function appends values to an array." 1512 | }, 1513 | "array.remove()": { 1514 | "scope": "pine, pinescript", 1515 | "prefix": "array.remove()", 1516 | "body": ["array.remove(${1:id=${2}}${3:, index=${4}})$0"], 1517 | "description": "The function changes the contents of an array by removing an existing element with the specified index." 1518 | }, 1519 | "array.reverse()": { 1520 | "scope": "pine, pinescript", 1521 | "prefix": "array.reverse()", 1522 | "body": ["array.reverse(${1:id=${2}})$0"], 1523 | "description": "The function reverses an array. The first array element becomes the last, and the last array element becomes the first." 1524 | }, 1525 | "array.set()": { 1526 | "scope": "pine, pinescript", 1527 | "prefix": "array.set()", 1528 | "body": ["array.set(${1:id=${2}}${3:, index=${4}}${5:, value=${6}})$0"], 1529 | "description": "The function replaces the existing element that has the specified index with a new value." 1530 | }, 1531 | "array.shift()": { 1532 | "scope": "pine, pinescript", 1533 | "prefix": "array.shift()", 1534 | "body": ["array.shift(${1:id=${2}})$0"], 1535 | "description": "The function removes an array's first element and returns its value." 1536 | }, 1537 | "array.size()": { 1538 | "scope": "pine, pinescript", 1539 | "prefix": "array.size()", 1540 | "body": ["array.size(${1:id=${2}})$0"], 1541 | "description": "The function returns the number of elements in an array." 1542 | }, 1543 | "array.slice()": { 1544 | "scope": "pine, pinescript", 1545 | "prefix": "array.slice()", 1546 | "body": ["array.slice(${1:id=${2}}${3:, index_from=${4}}${5:, index_to=${6}})$0"], 1547 | "description": "The function creates a slice from an existing array. If an object from the slice changes, the changes are applied to both the new and the original arrays." 1548 | }, 1549 | "array.sort()": { 1550 | "scope": "pine, pinescript", 1551 | "prefix": "array.sort()", 1552 | "body": ["array.sort(${1:id=${2}}${3:, order=${4}})$0"], 1553 | "description": "The function sorts elements of an array." 1554 | }, 1555 | "array.standardize()": { 1556 | "scope": "pine, pinescript", 1557 | "prefix": "array.standardize()", 1558 | "body": ["array.standardize(${1:id=${2}})$0"], 1559 | "description": "The function returns the array of standardized elements." 1560 | }, 1561 | "array.stdev()": { 1562 | "scope": "pine, pinescript", 1563 | "prefix": "array.stdev()", 1564 | "body": ["array.stdev(${1:id=${2}})$0"], 1565 | "description": "The function returns the standard deviation of an array's elements." 1566 | }, 1567 | "array.sum()": { 1568 | "scope": "pine, pinescript", 1569 | "prefix": "array.sum()", 1570 | "body": ["array.sum(${1:id=${2}})$0"], 1571 | "description": "The function returns the sum of array's elements." 1572 | }, 1573 | "array.unshift()": { 1574 | "scope": "pine, pinescript", 1575 | "prefix": "array.unshift()", 1576 | "body": ["array.unshift(${1:id=${2}}${3:, value=${4}})$0"], 1577 | "description": "The function inserts the value at the beginning of the array." 1578 | }, 1579 | "array.variance()": { 1580 | "scope": "pine, pinescript", 1581 | "prefix": "array.variance()", 1582 | "body": ["array.variance(${1:id=${2}})$0"], 1583 | "description": "The function returns the variance of an array's elements." 1584 | }, 1585 | 1586 | //------------------------------------------------------------------------------- 1587 | //------------------------------------------------------------------------------- 1588 | //------------------------------------------------------------------------------- 1589 | // custom functions: 1590 | //------------------------------------------------------------------------------- 1591 | "Custom Function Initializer": { 1592 | "prefix": "CFI", 1593 | "body": [ 1594 | "//\t\tFunction ${1}", 1595 | "${2/([^,]+)([,\\s]*|)/\\/\\/@param ${2}: [...]\n/g}", 1596 | "${1:name}(${2:param})=>", 1597 | "\t//code..$0" 1598 | ], 1599 | "description": "Custom Function Initializer" 1600 | }, 1601 | "f_color_palette_black_to_white" : { 1602 | "scope": "pine, pinescript", 1603 | "prefix": "f_color_palette_black_to_white", 1604 | "body": [ 1605 | "// Black to White color palette.", 1606 | "// 41 color palette, index 0 to 40.", 1607 | "f_color_palette_black_to_white(_i)=>_i==0?#000000:(_i==1?#0d0d0d:(_i==2?#1a1a1a:(_i==3?#262626:(_i==4?#333333:(_i==5?#404040:(_i==6?#4d4d4d:(_i==7?#595959:(_i==8?#696969:(_i==9?#737373:(_i==10?#808080:(_i==11?#8d8d8d:(_i==12?#999999:(_i==13?#a6a6a6:(_i==14?#b3b3b3:(_i==15?#bfbfbf:(_i==16?#cccccc:(_i==17?#d9d9d9:(_i==18?#e6e6e6:(_i==19?#f2f2f2:#ffffff)))))))))))))))))))", 1608 | "//." 1609 | ], 1610 | "description": "Black to White color palette with 41 colors." 1611 | }, 1612 | "if else" : { 1613 | "scope": "pine, pinescript", 1614 | "prefix": "if else statement", 1615 | "body": [ 1616 | "if ${1:true}", 1617 | "\t//do something", 1618 | "\t$0", 1619 | "else", 1620 | "\t//do something else" 1621 | ], 1622 | "description": "conditional if () else () statement" 1623 | }, 1624 | "f_perc_of()" : { 1625 | "scope": "pine, pinescript", 1626 | "prefix": "f_perc_of()", 1627 | "body": [ 1628 | "f_perc_of(_frac, _total)=>(_frac / _total) * 100" 1629 | ], 1630 | "description": "Custom Function:\nCalculates percentage value." 1631 | }, 1632 | "f_cus_sum()": { 1633 | "scope": "pine, pinescript", 1634 | "prefix": "f_sum()", 1635 | "body": [ 1636 | "Sum(src,p) => a = cum(src), a - a[p]" 1637 | ], 1638 | "description": "Custom Function:\nSum with variable length" 1639 | }, 1640 | "f_cus_sma()": { 1641 | "scope": "pine, pinescript", 1642 | "prefix": "f_cus_sum()", 1643 | "body": [ 1644 | "Sma(src,p) => a = cum(src), (a - a[p])/p" 1645 | ], 1646 | "description": "Custom Function:\nSMA with variable length" 1647 | }, 1648 | "f_cus_variance()": { 1649 | "scope": "pine, pinescript", 1650 | "prefix": "f_cus_variance()", 1651 | "body": [ 1652 | "Variance(src,p) => p == 1 ? 0 : Sma(src*src,p) - pow(Sma(src,p),2)" 1653 | ], 1654 | "description": "Custom Function:\nVariance with variable length" 1655 | }, 1656 | "f_cus_stdev()": { 1657 | "scope": "pine, pinescript", 1658 | "prefix": "f_cus_stdev()", 1659 | "body": [ 1660 | "Stdev(src,p) => p == 1 ? 0 : sqrt(Sma(src*src,p) - pow(Sma(src,p),2))" 1661 | ], 1662 | "description": "Custom Function:\nVariance with variable length" 1663 | }, 1664 | "f_cus_covariance()": { 1665 | "scope": "pine, pinescript", 1666 | "prefix": "f_cus_covariance()", 1667 | "body": [ 1668 | "Covariance(x,y,p) => Sma(x*y,p) - Sma(x,p)*Sma(y,p)" 1669 | ], 1670 | "description": "Custom Function:\nVariance with variable length" 1671 | }, 1672 | "f_cus_correlation()": { 1673 | "scope": "pine, pinescript", 1674 | "prefix": "f_cus_variance()", 1675 | "body": [ 1676 | "Correlation(x,y,p) => Covariance(x,y,p)/(Stdev(x,p)*Stdev(y,p))" 1677 | ], 1678 | "description": "Custom Function:\nVariance with variable length" 1679 | }, 1680 | "f_round()": { 1681 | "scope": "pine, pinescript", 1682 | "prefix": "f_round()", 1683 | "body": [ 1684 | "f_round( _val, _decimals) =>", 1685 | "\t_p = pow(10, _decimals)", 1686 | "\tround(abs(_val) * _p) / _p * sign(_val)" 1687 | ], 1688 | "description": "Custom Function:\nRound" 1689 | }, 1690 | "f_random()": { 1691 | "scope": "pine, pinescript", 1692 | "prefix": "f_random()", 1693 | "body": [ 1694 | "f_random(_range) =>", 1695 | "\tvar _return = 1.0 + timenow", 1696 | "\treturn := (3.14159 * _return % (bar_index + 1)) % _range" 1697 | ], 1698 | "description": "Custom Function:\nRandom Seed Number" 1699 | }, 1700 | "f_format_to_tick()": { 1701 | "scope": "pine, pinescript", 1702 | "prefix": "f_format_to_tick()", 1703 | "body": [ 1704 | "f_print(_txt) => var _lbl = label.new(bar_index, highest(10)[1], _txt, xloc.bar_index, yloc.price, #00000000, label.style_none, color.gray, size.large, text.align_center), label.set_xy(_lbl, bar_index, highest(10)[1]), label.set_text(_lbl, _txt)", 1705 | "// Produces a string format usable with `tostring()` to restrict precision to ticks.", 1706 | "// • Note that `tostring()` will also round the value.", 1707 | "f_tickFormat() =>", 1708 | "\ts = tostring(syminfo.mintick)", 1709 | "\ts := str.replace_all(_s, '25','00')", 1710 | "\ts := str.replace_all(_s, '5', '0')", 1711 | "\ts := str.replace_all(_s, '1', '0')", 1712 | ], 1713 | "description": "Custom Function:\nFormat string value to tick" 1714 | }, 1715 | "f_roundToTick()": { 1716 | "scope": "pine, pinescript", 1717 | "prefix": "f_roundToTick()", 1718 | "body": [ 1719 | "f_roundToTick( _price) => round(_price / syminfo.mintick) * syminfo.mintick" 1720 | ], 1721 | "description": "Custom Function:\nRound To Tick" 1722 | }, 1723 | "f_fib_slicer()" : { 1724 | "scope": "pine, pinescript", 1725 | "prefix": "f_fib_slicer()", 1726 | "body": [ 1727 | "//-----------------------------------------------------------------", 1728 | "// Fibonacci slicer function", 1729 | "//\tby https://www.tradingview.com/u/e2e4mfck/ {", 1730 | "f_fib_slicer(_val1, _val2)=>", 1731 | "\t_v1 = _val2 > _val1 ? _val1 : _val2", 1732 | "\t_v2 = _val2 > _val1 ? _val2 : _val1", 1733 | "\t_m = (_v2 - _v1)", 1734 | "\t_a = abs((1 - sqrt(5)) / 2.)", 1735 | "\t_b = sqrt(_a), _c = sqrt(_b), _d = 0.5", 1736 | "\t_e = pow(_a, 2), _f = pow(_a, 3), _g = pow(_a, 4) ", 1737 | "\t_886 = _m * _c + _v1", 1738 | "\t_786 = _m * _b + _v1", 1739 | "\t_618 = _m * _a + _v1", 1740 | "\t_5 = _m * _d + _v1", 1741 | "\t_381 = _m * _e + _v1", 1742 | "\t_236 = _m * _f + _v1", 1743 | "\t_145 = _m * _g + _v1", 1744 | "\t[_886, _786, _618, _5, _381, _236, _145] ", 1745 | "", 1746 | "[$1_886, $1_786, $1_618, $1_5, $1_381, $1_236, $1_145] = f_fib(${2:val1}, ${3:val2}) ", 1747 | "// } $0" 1748 | ], 1749 | "description": "Custom Function:\nSlices a range into Fibonacci Segments." 1750 | }, 1751 | "f_highest_since()" : { 1752 | "scope": "pine, pinescript", 1753 | "prefix": "f_highest_since()", 1754 | "body": [ 1755 | "//-----------------------------------------------------------------", 1756 | "// Highest since function", 1757 | "//\tby https://www.tradingview.com/u/Peter_O/ {", 1758 | "f_highest_since(_highseries,_sinceevent)=>", 1759 | "\tvar float _peak = na", 1760 | "\t_peak := _highseries > _peak or _sinceevent ? _highseries : _peak", 1761 | "// } $0" 1762 | ], 1763 | "description": "Custom Function:\nReturns value of a series at the last event occurence." 1764 | }, 1765 | "f_lowest_since()" : { 1766 | "scope": "pine, pinescript", 1767 | "prefix": "f_lowest_since()", 1768 | "body": [ 1769 | "//-----------------------------------------------------------------", 1770 | "// Lowest since function", 1771 | "//\tby https://www.tradingview.com/u/Peter_O/ {", 1772 | "f_lowest_since(_lowseries,_sinceevent)=>", 1773 | "\tvar float _bottom = na", 1774 | "\t_bottom := _lowseries < _bottom or _sinceevent ? _lowseries : _bottom", 1775 | "// } $0" 1776 | ], 1777 | "description": "Custom Function:\nReturns value of a series at the last event occurence." 1778 | }, 1779 | "for loop" : { 1780 | "scope": "pine, pinescript", 1781 | "prefix": "for loop statement", 1782 | "body": [ 1783 | "for _i = 0 to 999 by 1", 1784 | " if true", 1785 | " //do something", 1786 | " break", 1787 | " else", 1788 | " //do something", 1789 | " continue" 1790 | ], 1791 | "description": "for ()() loop statement" 1792 | }, 1793 | "f_mtf_countdown_to_close_text()" : { 1794 | "scope": "pine, pinescript", 1795 | "prefix": "f_mtf_countdown_to_close_text()", 1796 | "body": [ 1797 | "f_mtf_countdown_to_close_text(_tf)=>", 1798 | "\tint _open_date = valuewhen(change(time(_tf)) != 0, time, 0)", 1799 | "\tint _close_date = _open_date + round(f_tfResInMinutes(_tf)) * 60000", 1800 | "\tint _time_difference = _close_date - timenow", 1801 | "\tint _tina_minute = 60000, int _tina_hour = (60*_tina_minute), int _tina_day = (1440*_tina_minute), int _tina_week = (10080*_tina_minute), int _tina_month = (43800*_tina_minute)", 1802 | "\tint _month = _time_difference / _tina_month", 1803 | "\tint _weeks = (_time_difference % _tina_month) / _tina_week", 1804 | "\tint _days = ((_time_difference % _tina_month) % _tina_week) / _tina_day", 1805 | "\tint _hours = (((_time_difference % _tina_month) % _tina_week) % _tina_day) / _tina_hour", 1806 | "\tint _minutes = ((((_time_difference % _tina_month) % _tina_week) % _tina_day) % _tina_hour) / _tina_minute", 1807 | "\tstring _countdown = (_month >= 1 ? tostring(_month, ' #M ') : '') + (_weeks >= 1 ? tostring(_weeks, ' #W ') : '') + (_days >= 1 ? tostring(_days, ' #D ') : '') + (_hours >= 0 ? (_hours < 10 ? '0' : '') + tostring(_hours, '#') : '00') + (_minutes >= 0 ? (_minutes < 10 ? '0' : '') + tostring(_minutes, ':# ') : ':00')", 1808 | "\t_countdown" 1809 | ], 1810 | "description": "for ()() loop statement" 1811 | }, 1812 | //------------------------------------------------------------------------------- 1813 | //------------------------------------------------------------------------------- 1814 | ///////////////////////////////// 1815 | //*** PINECODERS SNIPPETS ***// 1816 | //////////////////////////////// 1817 | // added by Daveatt, Best-Trading-Indicator 1818 | // https://github.com/Best-Trading-Indicator/pinescript/blob/master/pine.v4.code-snippets 1819 | "date_range": { 1820 | "scope": "pine, pinescript", 1821 | "prefix": "date_range", 1822 | "body": [ 1823 | "DateFilter = input(false, '═════════════ Date Range Filtering')", 1824 | "FromYear = input(defval=${1}, 'From Year', minval = 1900)", 1825 | "FromMonth = input(defval=${2}, 'From Month', minval = 1, maxval = 12)", 1826 | "FromDay = input(defval=${3}, 'From Day', minval = 1, maxval = 31)", 1827 | "ToMonth = input(defval=${4}, 'To Month', minval = 1, maxval = 12)", 1828 | "ToYear = input(defval=${5}, 'To Year', minval = 1900)", 1829 | "ToDay = input(defval=${6}, 'To Day', minval = 1, maxval = 31)", 1830 | "FromDate = timestamp(FromYear, FromMonth, FromDay, 00, 00)", 1831 | "ToDate = timestamp(ToYear, ToMonth, ToDay, 23, 59)", 1832 | "TradeDateIsAllowed() => DateFilter ? (time >= FromDate and time <= ToDate) : true", 1833 | ], 1834 | "description": "Custom Function:\nTest if a date is in a range" 1835 | }, 1836 | "f_bar_within_today()": { 1837 | "scope": "pine, pinescript", 1838 | "prefix": "f_bar_within_today()", 1839 | "body": [ 1840 | "f_bar_within_today() =>", 1841 | "\tcurrentYear = year(timenow)", 1842 | "\tcurrentMonth = month(timenow)", 1843 | "\tcurrentDay = dayofmonth(timenow)", 1844 | "\ttoday = year == currentYear and month == currentMonth and dayofmonth == currentDay", 1845 | "\nbgcolor(today ? color.gray : na)" 1846 | ], 1847 | "description": "Custom Function:\nTest if a bar's date is today" 1848 | }, 1849 | "track_high_low_time": { 1850 | "scope": "pine, pinescript", 1851 | "prefix": "track_high_low_time", 1852 | "body": [ 1853 | "timeAllowed = input('1200-1500', 'Allowed hours', input.session)", 1854 | "// Check to see if we are in allowed hours.", 1855 | "timeIsAllowed = time(timeframe.period, timeAllowed)", 1856 | "var hi = 10e-10", 1857 | "var lo = 10e10", 1858 | "if timeIsAllowed", 1859 | "\t// We are entering allowed hours; reset hi/lo.", 1860 | "\tif not timeIsAllowed[1]", 1861 | "\t\thi := high", 1862 | "\t\tlo := low", 1863 | "\telse", 1864 | "\t\t// We are in allowed hours; track hi/lo.", 1865 | "\t\thi := max(high, hi)", 1866 | "\t\tlo := min(low, lo)" 1867 | ], 1868 | "description": "Track highs/lows for a specific period of time" 1869 | }, 1870 | "f_resInMinutes()": { 1871 | "scope": "pine, pinescript", 1872 | "prefix": "f_resInMinutes()", 1873 | "body": [ 1874 | "f_resInMinutes() =>", 1875 | "\t_resInMinutes = timeframe.multiplier * (", 1876 | "\t timeframe.isseconds ? 1. / 60. :", 1877 | "\t timeframe.isminutes ? 1. :", 1878 | "\t timeframe.isdaily ? 1440. :", 1879 | "\t timeframe.isweekly ? 10080. :", 1880 | "\t timeframe.ismonthly ? 43800. : na)", 1881 | ], 1882 | "description": "Custom Function: \nConverts current 'timeframe.multiplier' plus the TF into minutes of type float" 1883 | }, 1884 | "f_resFromMinutes()": { 1885 | "scope": "pine, pinescript", 1886 | "prefix": "f_resFromMinutes()", 1887 | "body": [ 1888 | "res = input(1440., 'Minutes in target resolution (<= 0.0167 [1 sec.])', minval = 0.0167)", 1889 | "\n\nf_resFromMinutes() =>", 1890 | "\t_resInMinutes = timeframe.multiplier * (", 1891 | "\t timeframe.isseconds ? 1. / 60. :", 1892 | "\t timeframe.isminutes ? 1. :", 1893 | "\t timeframe.isdaily ? 1440. :", 1894 | "\t timeframe.isweekly ? 10080. :", 1895 | "\t timeframe.ismonthly ? 43800. : na)", 1896 | "\n\n// Converts a resolution expressed in minutes into a string usable by 'security()'", 1897 | "f_resFromMinutes(_minutes) =>", 1898 | "\t_minutes <= 0.0167 ? '1S' :", 1899 | "\t _minutes <= 0.0834 ? '5S' :", 1900 | "\t _minutes <= 0.2500 ? '15S' :", 1901 | "\t _minutes <= 0.5000 ? '30S' :", 1902 | "\t _minutes <= 1440 ? tostring(round(_minutes)) :", 1903 | "\t _minutes <= 43800 ? tostring(round(min(_minutes / 1440, 365))) + 'D' : tostring(round(min(_minutes / 43800,12))) + 'M'" 1904 | ], 1905 | "description": "Custom Function: \nConverts current 'timeframe.multiplier' plus the TF into minutes of type float" 1906 | }, 1907 | "f_multipleOfRes(_res, _mult)": { 1908 | "scope": "pine, pinescript", 1909 | "prefix": "f_multipleOfRes(_res, _mult)", 1910 | "body": [ 1911 | "resMult = input(4, minval = 1)", 1912 | "\nf_multipleOfRes(_res, _mult) =>", 1913 | "\t// _res: current resolution in minutes, in the fractional format supplied by f_resInMinutes() companion function.", 1914 | "\t// _mult: Multiple of current TF to be calculated.", 1915 | "\t// Convert current float TF in minutes to target string TF in 'timeframe.period' format.", 1916 | "\t_targetResInMin = _res * max(_mult, 1)", 1917 | "\t// Find best string to express the resolution.", 1918 | "\t_targetResInMin <= 0.083 ? '5S' :", 1919 | "\t _targetResInMin <= 0.251 ? '15S' :", 1920 | "\t _targetResInMin <= 0.501 ? '30S' :", 1921 | "\t _targetResInMin <= 1440 ? tostring(round(_targetResInMin)) :", 1922 | "\t _targetResInMin <= 43800 ? tostring(round(min(_targetResInMin / 1440, 365))) + 'D' :", 1923 | "\t tostring(round(min(_targetResInMin / 43800, 12))) + 'M'" 1924 | ], 1925 | "description": "Custom Function: \nReturns a multiple of current TF as a string usable with 'security()'" 1926 | }, 1927 | "f_ideal_TimesInLast(_cond, _len)()": { 1928 | "scope": "pine, pinescript", 1929 | "prefix": "f_ideal_TimesInLast(_cond, _len)", 1930 | "body": [ 1931 | "// ————— Method 1. This function uses Pine's built-in function but only accepts a simple int for the length.", 1932 | "f_ideal_TimesInLast(_cond, _len) => sum(_cond ? 1 : 0, _len)" 1933 | ], 1934 | "description": "Custom Function: \nCount the occurrences of a condition in the last x bars?" 1935 | }, 1936 | "last_day": { 1937 | "scope": "pine, pinescript", 1938 | "prefix": "last_day", 1939 | "body": [ 1940 | "lastDay = security(syminfo.tickerid,'D', barstate.islast, lookahead = barmerge.lookahead_on)" 1941 | ], 1942 | "description": "Return the Last day" 1943 | }, 1944 | "f_normalize()": { 1945 | "scope": "pine, pinescript", 1946 | "prefix": "f_normalize()", 1947 | "body": [ 1948 | "// ————— When scale of signal to rescale is unknown.", 1949 | "// Min/Max of signal to rescale is determined by its historical low/high.", 1950 | "normalize(_src, _min, _max) =>", 1951 | "\t// Normalizes series with unknown min/max using historical min/max.,", 1952 | "\t// _src: series to rescale.", 1953 | "\t// _min: minimum value of rescaled series.", 1954 | "\t// _max: maximum value of rescaled series.", 1955 | "\tvar _historicMin = 10e10", 1956 | "\tvar _historicMax = -10e10", 1957 | "\t_historicMin := min(nz(_src, _historicMin), _historicMin)", 1958 | "\t_historicMax := max(nz(_src, _historicMax), _historicMax)", 1959 | "\t_min + (_max - _min) * (_src - _historicMin) / max(_historicMax - _historicMin, 10e-10)", 1960 | "\nplot(normalize(volume, -100, 100))" 1961 | ], 1962 | "description": "Custom Function: \nScale of signal to rescale is unknown" 1963 | }, 1964 | "f_rescale()": { 1965 | "scope": "pine, pinescript", 1966 | "prefix": "f_rescale()", 1967 | "body": [ 1968 | "// ————— When scale of signal to rescale is known.", 1969 | "rescale(_src, _oldMin, _oldMax, _newMin, _newMax) =>", 1970 | "\t// Rescales series with known min/max.", 1971 | "\t// _src: series to rescale.", 1972 | "\t// _oldMin: minimum value of series to rescale.", 1973 | "\t// _oldMax: maximum value of series to rescale.", 1974 | "\t// _newMin: minimum value of rescaled series.", 1975 | "\t// _newMax: maximum value of rescaled series.", 1976 | "\t_newMin + (_newMax - _newMin) * (_src - _oldMin) / max(_oldMax - _oldMin, 10e-10)", 1977 | "\nplot(rescale(rsi(close, 14), 0, 100, -100, 100), color = color.fuchsia)", 1978 | ], 1979 | "description": "Custom Function: \nScale of signal to rescale is known" 1980 | }, 1981 | "f_print()": { 1982 | "scope": "pine, pinescript", 1983 | "prefix": "f_print()", 1984 | "body": [ 1985 | "f_print(_txt) => var _lbl = label.new(bar_index, highest(10)[1], _txt, xloc.bar_index, yloc.price, #00000000, label.style_none, color.gray, size.large, text.align_left), label.set_xy(_lbl, bar_index, highest(10)[1]), label.set_text(_lbl, _txt)", 1986 | "f_print('Multiplier = ' + tostring(timeframe.multiplier) + '\\nPeriod = ' + timeframe.period + '\\nHigh = ' + tostring(high))" 1987 | ], 1988 | "description": "Custom Function: \nExamine the value of a string" 1989 | }, 1990 | //------------------------------------------------------------------------------- 1991 | //------------------------------------------------------------------------------- 1992 | //--- debug tool: 1993 | "debugBool": { 1994 | "scope": "pine, pinescript", 1995 | "prefix": "plotBool", 1996 | "body": [ 1997 | "plot(X ? 1 : 0, title='X', transp=100, color=color.orange)" 1998 | ], 1999 | "description": "inserting a 'debug bool plot' function" 2000 | } 2001 | //------------------------------------------------------------------------------- 2002 | //--- End of file. 2003 | } -------------------------------------------------------------------------------- /settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "python.linting.pylintEnabled": true, 3 | "python.linting.enabled": true 4 | } --------------------------------------------------------------------------------