A clean Pine Script v6 strategy to start from
Create a new strategy in Pine Editor and replace its entire contents with this example. It calculates two EMAs on every bar, enters long on a crossover, and requests a close on a crossunder. There are no external data requests, libraries, date filters, or stop orders to complicate the first check. This is a diagnostic baseline, not a trading recommendation.
- Save and add the script to a standard candlestick chart. Confirm that both EMA plots appear.
- The green marker shows the crossover condition, not a confirmed fill. With default settings, market orders normally fill on the next available tick, typically the next bar open in a historical test.
- No trades can still be legitimate: the loaded history may contain no qualifying crossover, or one unit may exceed available capital for the symbol and its contract multiplier.
- The final source passed the Pineify syntax checker on October 16, 2026. Chart execution and trade results were not measured for this page.
- A successful baseline check does not certify your account, data feed, or full strategy. Keep the original script for comparison.
//@version=6
strategy("Clean compile diagnostic", overlay = true, initial_capital = 100000, default_qty_type = strategy.fixed, default_qty_value = 1)
fastLength = input.int(9, "Fast EMA", minval = 1)
slowLength = input.int(21, "Slow EMA", minval = 1)
fastEma = ta.ema(close, fastLength)
slowEma = ta.ema(close, slowLength)
enterLong = ta.crossover(fastEma, slowEma)
exitLong = ta.crossunder(fastEma, slowEma)
if enterLong and strategy.position_size == 0
strategy.entry("Long", strategy.long)
if exitLong and strategy.position_size > 0
strategy.close("Long")
plot(fastEma, "Fast EMA", color = color.blue)
plot(slowEma, "Slow EMA", color = color.orange)
plotshape(enterLong, title = "Entry condition", style = shape.triangleup, location = location.belowbar, color = color.green)