Pine Script (TradingView)
This is a TradingView Pine Script strategy example for this page concept. Paste it into the TradingView Pine Editor, add it to your chart, and run it in the Strategy Tester.
//@version=6
strategy("Gap Trading Strategy", overlay=true)
atrLen = input.int(14, "ATR Length")
atrMult = input.float(2.0, "ATR Mult")
emaLen = input.int(50, "Trend EMA")
ema = ta.ema(close, emaLen)
atr = ta.atr(atrLen)
longSignal = ta.crossover(close, ema)
stop = strategy.position_avg_price - atr * atrMult
if longSignal
strategy.entry("Long", strategy.long)
strategy.exit("ATR Exit", "Long", stop=stop)
plot(ema, "EMA", color=color.new(color.orange, 0))