|
| 1 | +" Vim syntax file |
| 2 | +" Language: TradingView Pine Script Language |
| 3 | +" Maintainer: Bruno Morgado |
| 4 | +" Latest Revision: 21 September 2015 |
| 5 | + |
| 6 | +if exists("b:current_syntax") |
| 7 | + finish |
| 8 | +endif |
| 9 | + |
| 10 | +" Keywords |
| 11 | +" ----------------------------------------------------------------------------- |
| 12 | +" comments |
| 13 | +syn match pslComment "\v//.*$" |
| 14 | + |
| 15 | +" strings |
| 16 | +syn region pslString start=/\v"/ skip=/v\\./ end=/\v"/ |
| 17 | +syn region pslString start=/\v'/ skip=/v\\./ end=/\v'/ |
| 18 | + |
| 19 | +" operators |
| 20 | +syn match pslOperator "\v\=" |
| 21 | +syn match pslOperator "\v\!\=" |
| 22 | +syn match pslOperator "\v\%" |
| 23 | +syn match pslOperator "\v\*" |
| 24 | +syn match pslOperator "\v\+" |
| 25 | +syn match pslOperator "\v\-" |
| 26 | +syn match pslOperator "\v[^/]/[^/]" |
| 27 | +syn match pslOperator "\v\<" |
| 28 | +syn match pslOperator "\v\<\=" |
| 29 | +syn match pslOperator "\v\=\=" |
| 30 | +syn match pslOperator "\v\>" |
| 31 | +syn match pslOperator "\v\>\=" |
| 32 | +syn match pslOperator "\v\?\:" |
| 33 | +syn match pslOperator "\v\[" |
| 34 | +syn match pslOperator "\v\]" |
| 35 | +syn keyword pslOperator and |
| 36 | +syn keyword pslOperator not |
| 37 | +syn keyword pslOperator or |
| 38 | + |
| 39 | +" functions |
| 40 | +" TODO: make category for annotation function |
| 41 | +syn keyword pslFunction abs acos alma asin atan atr avg barcolor barssince |
| 42 | +syn keyword pslFunction bgcolor cci ceil change cog correlation cos cross |
| 43 | +syn keyword pslFunction crossover crossunder cum dayofmonth dayofweek dev ema |
| 44 | +syn keyword pslFunction exp falling fill fixnan floor heikenashi highest |
| 45 | +syn keyword pslFunction highestbars hline hour iff input kagi linebreak linreg |
| 46 | +syn keyword pslFunction log log10 lowest lowestbars mac max min minute mom |
| 47 | +syn keyword pslFunction month na nz offset percentile_linear_interpolation |
| 48 | +syn keyword pslFunction percentile_nearest_rank percentrank pivothigh pivotlow |
| 49 | +syn keyword pslFunction plot plotarrow plotbar plotcandle plotchar plotshape |
| 50 | +syn keyword pslFunction pointfigure pow renko rising rma roc round rsi sar |
| 51 | +syn keyword pslFunction second security sign sin sma sqrt stdev stoch strategy |
| 52 | +syn keyword pslFunction strategy.cancel strategy.cancel_all strategy.close |
| 53 | +syn keyword pslFunction strategy.close_all strategy.entry strategy.exit |
| 54 | +syn keyword pslFunction strategy.order strategy.risk.allow_entry_in |
| 55 | +syn keyword pslFunction strategy.risk.max_cons_loss_days |
| 56 | +syn keyword pslFunction strategy.risk.max_drawdown |
| 57 | +syn keyword pslFunction strategy.risk.max_intraday_filled_orders |
| 58 | +syn keyword pslFunction strategy.risk.max_intraday_loss |
| 59 | +syn keyword pslFunction strategy.risk.max_position_size study sum swma tan |
| 60 | +syn keyword pslFunction tickerid time tostring tr tsi valuewhen variance vwap |
| 61 | +syn keyword pslFunction vwma weekofyear wma year |
| 62 | + |
| 63 | +" variables |
| 64 | +syn keyword pslVariable accdist aqua area areabr black blue bool circles close |
| 65 | +syn keyword pslVariable columns cross currency.AUD currency.CAD currency.CHF |
| 66 | +syn keyword pslVariable currency.EUR currency.GBP currency.HKD currency.JPY |
| 67 | +syn keyword pslVariable currency.NOK currency.NONE currency.NZD currency.SEK |
| 68 | +syn keyword pslVariable currency.SGD currency.TRY currency.USD currency.ZAR |
| 69 | +syn keyword pslVariable dashed dayofmonth dayofweek dotted float friday fuchsia |
| 70 | +syn keyword pslVariable gray green high histogram hl2 hlc3 hour integer |
| 71 | +syn keyword pslVariable interval isdaily isdwm isintraday ismonthly isweekly |
| 72 | +syn keyword pslVariable lime line location.abovebar location.absolute |
| 73 | +syn keyword pslVariable location.belowbar location.bottom location.top low |
| 74 | +syn keyword pslVariable maroon minute monday month n na navy ohlc4 olive openo |
| 75 | +syn keyword pslVariable orange period purple red resolution saturday scale.left |
| 76 | +syn keyword pslVariable scale.none scale.right second session session.extended |
| 77 | +syn keyword pslVariable session.regular shape.arrowdown shape.arrowup |
| 78 | +syn keyword pslVariable shape.circle shape.cross shape.diamond shape.flag |
| 79 | +syn keyword pslVariable shape.labeldown shape.labelup shape.square |
| 80 | +syn keyword pslVariable shape.triangledown shape.triangleup shape.xcross silver |
| 81 | +syn keyword pslVariable solid source strategy.cash strategy.closedtrades |
| 82 | +syn keyword pslVariable strategy.direction.all strategy.direction.long |
| 83 | +syn keyword pslVariable strategy.direction.short strategy.equity |
| 84 | +syn keyword pslVariable strategy.eventrades strategy.fixed strategy.grossloss |
| 85 | +syn keyword pslVariable strategy.grossprofit strategy.initial_capital |
| 86 | +syn keyword pslVariable strategy.losstrades strategy.max_contracts_held_all |
| 87 | +syn keyword pslVariable strategy.max_contracts_held_long |
| 88 | +syn keyword pslVariable strategy.max_contracts_held_short |
| 89 | +syn keyword pslVariable strategy.max_drawdown strategy.netprofit |
| 90 | +syn keyword pslVariable strategy.oca.cancel strategy.oca.none |
| 91 | +syn keyword pslVariable strategy.oca.reduce strategy.openprofit |
| 92 | +syn keyword pslVariable strategy.opentrades strategy.percent_of_equity |
| 93 | +syn keyword pslVariable strategy.position_avg_price |
| 94 | +syn keyword pslVariable strategy.position_entry_name strategy.position_size |
| 95 | +syn keyword pslVariable strategy.wintrades string sunday symbol syminfo.mintick |
| 96 | +syn keyword pslVariable syminfo.pointvalue syminfo.prefix syminfo.root |
| 97 | +syn keyword pslVariable syminfo.session teal thursday ticker tickerid time tr |
| 98 | +syn keyword pslVariable tuesday volume vwap wednesday weekofyear white year |
| 99 | +syn keyword pslVariable yellosyn keyword pslVariable strategy.losstrades |
| 100 | +syn keyword pslVariable strategy.max_contracts_held_all |
| 101 | +syn keyword pslVariable strategy.max_contracts_held_long |
| 102 | +syn keyword pslVariable strategy.max_contracts_held_short |
| 103 | +syn keyword pslVariable strategy.max_drawdown strategy.netprofit |
| 104 | +syn keyword pslVariable strategy.oca.cancel strategy.oca.none |
| 105 | +syn keyword pslVariable strategy.oca.reduce strategy.openprofit |
| 106 | +syn keyword pslVariable strategy.opentrades strategy.percent_of_equity |
| 107 | +syn keyword pslVariable strategy.position_avg_price |
| 108 | +syn keyword pslVariable strategy.position_entry_name strategy.position_size |
| 109 | +syn keyword pslVariable strategy.wintrades string sunday symbol syminfo.mintick |
| 110 | +syn keyword pslVariable syminfo.pointvalue syminfo.prefix syminfo.root |
| 111 | +syn keyword pslVariable syminfo.session teal thursday ticker tickerid time tr |
| 112 | +syn keyword pslVariable tuesday volume vwap wednesday weekofyear white year |
| 113 | +syn keyword pslVariable yellow |
| 114 | + |
| 115 | +" Digits |
| 116 | +" ----------------------------------------------------------------------------- |
| 117 | +" integer with - + or nothing in front |
| 118 | +syn match pslNumber "\<\d\+" |
| 119 | +syn match pslNumber "\<[-+]\d\+" |
| 120 | + |
| 121 | +" floating point number with decimal no E or e (+,-) |
| 122 | +syn match pslFloat "\<\d\+\.\d*" |
| 123 | +syn match pslFloat "\<[-+]\d\+\.\d*" |
| 124 | + |
| 125 | +" floating point like number with E and no decimal point (+,-) |
| 126 | +syn match pslFloat "\<[-+]\=\d[[:digit:]]*[eE][\-+]\=\d\+" |
| 127 | +syn match pslFloat "\<\d[[:digit:]]*[eE][\-+]\=\d\+" |
| 128 | + |
| 129 | +" floating point like number with E and decimal point (+,-) |
| 130 | +syn match pslFloat "\<[-+]\=\d[[:digit:]]*\.\d*[eE][\-+]\=\d\+" |
| 131 | +syn match pslFloat "\<\d[[:digit:]]*\.\d*[eE][\-+]\=\d\+" |
| 132 | + |
| 133 | + |
| 134 | +" Define highlighting |
| 135 | +" ----------------------------------------------------------------------------- |
| 136 | +hi def link pslComment Comment |
| 137 | +hi def link pslString String |
| 138 | +hi def link pslFunction Function |
| 139 | +hi def link pslVariable Identifier |
| 140 | +hi def link pslNumber Number |
| 141 | +hi def link pslFloat Float |
| 142 | +hi def link pslOperator Operator |
| 143 | + |
| 144 | + |
| 145 | +" Set syntax |
| 146 | +" ----------------------------------------------------------------------------- |
| 147 | +let b:current_syntax = "psl" |
0 commit comments