Variables are ways to store values to be used elsewhere. Users can store their own variables, but there are some builtin variables.
You can create variables like so:
length = 14
smaValue = SMA(close, length)
wmaValue = WMA(close, length)
Variables can then be referenced anywhere after that in your code.
You can reference past values of a variable using square bracket notation:
value = upticks - downticks
momentum = value + momentum[1]
This retrieves the value of momentum from the previous candlestick (momentum[1]), enabling time-series logic such as accumulation, smoothing, and state tracking.
Scripts typically run once per candlestick, so these variables refer to values specific to that candle (time period).
open represents the opening price of the current candlestick.
close represents the closing price of the current candlestick.
upticks represents the number of price changes (ticks) during the current candlestick where the price moved upward.
It can be used as a proxy for buying pressure or bullish activity within the candle's timeframe.
downticks represents the number of price changes (ticks) during the current candlestick where the price moved downward.
It serves as a proxy for selling pressure or bearish activity within the current candlestick.