backtest
Run a trading strategy over Stockbit daily history to see actual trades, equity curve, and performance metrics versus buy-and-hold. Fills are executed at the next open and costs include IDX fees for realistic results.
Instructions
Run a trading strategy over Stockbit's own daily history and report what it would actually have done: every trade, an equity curve, and metrics (return, CAGR, Sharpe, max drawdown, win rate, profit factor, expectancy, exposure) against buy-and-hold over the SAME window.
Use a preset name, or supply your own entry/exit in the same condition grammar alert_create and pine_script use — so a backtested rule, a live alert and a TradingView strategy are one object rather than three that drift.
The execution model is deliberately pessimistic and it matters: signals are read at the bar CLOSE and filled at the NEXT bar's open (never at the price the signal was computed from); a bar that hits both stop and target resolves to the STOP; a gap through a level fills at the open, not the level; and a session locked by IDX auto-rejection (high === low) cannot be filled at all. Costs default to Indonesian retail: 0.15% to buy, 0.25% to sell (the extra 0.1% is the sale tax), plus 0.1% slippage, in whole 100-share lots.
ALWAYS read warnings before quoting a number. Under ten trades it says so, and it means it.
Set walk_forward for an out-of-sample check. Long-only: retail shorting is not available on IDX.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | No | Latest session, YYYY-MM-DD | |
| bars | No | Sessions of history (default 500, the practical maximum) | |
| from | No | Earliest session, YYYY-MM-DD | |
| folds | No | Walk-forward folds, default 3 | |
| panels | No | Oscillators the conditions reference | |
| symbol | Yes | IDX ticker, e.g. BBRI | |
| exit_op | No | ||
| entry_op | No | ||
| overlays | No | Series the conditions reference | |
| strategy | No | A preset. Omit to supply entry/exit yourself. | |
| exit_left | No | Exit condition, left side | |
| entry_left | No | Entry condition, left side | |
| exit_right | No | ||
| entry_right | No | ||
| slippage_pct | No | Default 0.1 | |
| walk_forward | No | Also run an out-of-sample check. Costs no extra requests. | |
| max_hold_bars | No | Force an exit after this many bars | |
| stop_loss_pct | No | Percent below the fill price, e.g. 5 | |
| include_equity | No | Include the equity curve, one point per bar. Default false. | |
| include_trades | No | Include the full trade log. Default true. | |
| initial_capital | No | IDR, default 10,000,000 | |
| take_profit_pct | No | Percent above the fill price | |
| commission_buy_pct | No | Default 0.15 | |
| commission_sell_pct | No | Default 0.25 (includes the 0.1% sale tax) |