TradeOnReplayDOCSSearch the whole guidetradeonreplay.com

Guide / Scripts

Example scripts

Ten examples ship with the editor. Open one from Open ▾ → Examples, or from the Indicators list under My scripts. Each one is run by an automated test, so a change to the language cannot quietly break it.

ExampleWhat it shows
EMA CrossTwo EMAs with buy and sell markers where they cross.
RSI with BandsRSI in its own pane with overbought and oversold levels.
Bollinger BandsBands around a moving average, with the space between shaded.
MACD HistogramMACD with a histogram that is brighter while momentum grows.
ATR ChannelA moving average with bands a multiple of ATR away.
Daily OpenA line at each day's opening price, restarting every day.
Higher-Timeframe EMAAn EMA from a higher timeframe, shown only once that timeframe's bar has closed.
Swing PivotsLabels each swing high and low once enough bars have passed to confirm it.
Heikin Ashi CandlesSmoothed Heikin Ashi candles in their own pane, built with plotcandle.
Inside BarHighlights bars that trade entirely inside the previous bar.

Recipe: Bollinger Bands

//@version=5
indicator("Bollinger Bands", overlay = true)

len = input.int(20, "Length", minval = 1)
mult = input.float(2.0, "Multiplier", minval = 0.1, step = 0.1)

[basis, upper, lower] = ta.bb(close, len, mult)

plot(basis, "Basis", color.orange)
u = plot(upper, "Upper", color.blue)
l = plot(lower, "Lower", color.blue)
fill(u, l, color.new(color.blue, 90))

Recipe: a line at each day's open

//@version=5
indicator("Daily Open", overlay = true)

newDay = dayofmonth != dayofmonth[1]
var float dailyOpen = na
if newDay
    dailyOpen := open

plot(dailyOpen, "Daily open", color.yellow, 2, plot.style_linebr)

Recipe: an RSI pane with shaded zones

//@version=5
indicator("RSI with Bands")

len = input.int(14, "Length", minval = 1)
upper = input.int(70, "Overbought")
lower = input.int(30, "Oversold")

value = ta.rsi(close, len)

plot(value, "RSI", color.purple, 2)
hline(upper, "Overbought", color.red, hline.style_dashed)
hline(lower, "Oversold", color.green, hline.style_dashed)
bgcolor(value > upper ? color.new(color.red, 85) : value < lower ? color.new(color.green, 85) : na)