◆ New — Strategy Validator, Code Fixer & Prop Compliance Checker are live. Try one free →
Home / Case studies / EMA crossover, non-repainting with a real stop
Case study · EMA crossover, non-repainting with a real stop

What a clean strategy looks like

The same EMA crossover idea, written the honest way: confirmed-bar entries and a stop-loss that is actually connected. This is the baseline every strategy above is measured against.

The code

//@version=6
// Educational only — validate before trading; not financial advice.
strategy("EMA cross (clean)", overlay = true)

fast   = ta.ema(close, 12)
slow   = ta.ema(close, 26)
stopPts = input.int(300, "Stop distance (points)")

if ta.crossover(fast, slow) and barstate.isconfirmed
    strategy.entry("Long", strategy.long)

if strategy.position_size > 0
    strategy.exit("Stop", "Long", stop = strategy.position_avg_price - stopPts * syminfo.mintick)

What our engine found

100/ 100
Strategy Health Score™ · code correctness
Clean
0 critical0 high0 medium0 info

Why it matters

Our engine returns a clean Strategy Health Score — no look-ahead, no repainting, no version-hygiene issues, and the stop input is genuinely wired into strategy.exit. Entries are gated to confirmed bars, so the tester and live evaluate the same way. Correctness clean is not a promise of profit; it means the code does what it says and the backtest reflects behaviour you could actually reproduce.

Takeaways

Run your own script through the same engine — get your Strategy Health Score →

Code-correctness analysis only — not financial advice, and not a measure of profitability. The code shown is a representative community pattern, not any specific author's script. Trading involves substantial risk of loss.

Catch the bug that compiles.Run auditGet Pro