Write a JavaScript strategy. Backtest it on 800 candles of seeded history. Tune the parameters until the equity curve looks heavenly. Then click ✷ Reveal Future and watch random god rip your edge apart.
Define two functions:
function setup(api, memory) { /* called once before bar 0 */ }
function loop(api, memory) { /* called at every candle close */ }
api.i — current candle indexapi.bars[k] — {o,h,l,c,vol} for k ≤ iapi.price — close of candle iapi.position — current qty (+long, −short)api.indicators.macd — {macd[], signal[], hist[]}api.indicators.rsi[] — RSI(14)api.indicators.kdj — {K[], D[], J[]}api.indicators.ema(period) — EMA on closesapi.openBuy(qty) · api.openSell(qty) · api.close()api.log(msg)An empty object you can attach state to. Persists across loop() calls within a single backtest/forward run.
In-sample tuning produces beautiful curves. Out-of-sample, the random god gives back exactly your costs. If the simulator had costs.