🧪 Tutorial Cluster

Cara Backtest di TradingView — Panduan Lengkap 2026

Oleh Dan Machado · 12 menit baca

Backtest adalah cara test strategi trading pada data historis sebelum risk uang real. TradingView punya Strategy Tester built-in yang powerful dan gratis. Tutorial ini menunjukkan cara pakai dengan benar — termasuk pitfalls yang membuat backtest “looks great” tapi fail di live trading.

Apa Itu Strategy Tester?

Strategy Tester adalah tools di TradingView yang menjalankan strategi kamu pada 1,000+ candle historis dan show:

  • Total profit / loss
  • Win rate, profit factor, Sharpe ratio
  • Max drawdown, longest streak
  • Equity curve (chart performance over time)
  • Detail setiap trade (entry, exit, P/L)

💡 Strategy vs Indicator

Di Pine Script, ada perbedaan penting:
Indicator: hanya plot signals, tidak track P/L
Strategy: simulate trades dengan position size, stop loss, take profit. Backtest hanya work untuk Strategy.
Untuk convert indicator ke strategy, pakai prompt #3 di tutorial AI prompts.

Setup Strategi di Pine Script

Sebelum backtest, kamu butuh Pine Script strategy. Contoh sederhana RSI Strategy:

▸ Pine Script v5 · Simple RSI Strategy
//@version=5
strategy("RSI Strategy Test", overlay=true,
  initial_capital=1000,
  default_qty_type=strategy.percent_of_equity,
  default_qty_value=2,
  commission_type=strategy.commission.percent,
  commission_value=0.1)

// === INPUTS ===
rsiLen = input.int(14, "RSI Length")
oversold = input.int(30, "Oversold")
overbought = input.int(70, "Overbought")
slPct = input.float(2.0, "Stop Loss %")
tpPct = input.float(4.0, "Take Profit %")

// === RSI ===
rsi = ta.rsi(close, rsiLen)

// === ENTRY ===
longCond = ta.crossover(rsi, oversold)
shortCond = ta.crossunder(rsi, overbought)

if longCond
    strategy.entry("Long", strategy.long)
    strategy.exit("Long Exit", "Long",
      stop = close * (1 - slPct/100),
      limit = close * (1 + tpPct/100))

if shortCond
    strategy.entry("Short", strategy.short)
    strategy.exit("Short Exit", "Short",
      stop = close * (1 + slPct/100),
      limit = close * (1 - tpPct/100))

// === PLOTS ===
plotshape(longCond, location.belowbar, color=color.green,
  style=shape.triangleup, size=size.small)
plotshape(shortCond, location.abovebar, color=color.red,
  style=shape.triangledown, size=size.small)

Step-by-Step Backtest

1

Paste Strategy ke Pine Editor

TradingView → buka chart → klik “Pine Editor” di bottom → paste code → Save

2

Add to Chart

Klik “Add to chart” di Pine Editor. Strategy mulai compile dan jalan di chart.

3

Buka Strategy Tester

Tab “Strategy Tester” di bottom (sebelah “Pine Editor”). Klik untuk expand panel.

4

Lihat Overview

Panel Overview menunjukkan: Net Profit, Total Trades, Win Rate, Profit Factor, Max Drawdown, Sharpe Ratio.

5

Tab Performance Summary

Detail lengkap: average trade, max consecutive wins/losses, percent profitable, dll. Klik untuk eksplor.

6

Tab List of Trades

Setiap individual trade dengan entry, exit, P/L, durasi. Useful untuk debug strategy.

Metrics yang Harus Kamu Pahami

MetricApa ArtinyaTarget Min.
Net ProfitTotal P/L atas semua trades> 10% modal
Total TradesJumlah trades dieksekusi200+
Win Rate %Persen menang> 50%
Profit FactorTotal wins / total losses> 1.3
Sharpe RatioReturn / volatility> 1.0
Max DrawdownLoss terbesar peak-to-trough< 20%
Avg TradeRata profit per trade> commission × 2

⚠️ Win Rate Tidak Cukup

Win rate 80% sounds great. Tapi kalau average loss = 5x average win, kamu tetap rugi. Profit Factor lebih penting daripada Win Rate. Target: Profit Factor > 1.5.

Pitfalls — Yang Bikin Backtest “Lying”

1. Overfitting

Optimize parameters terlalu spesifik untuk historical data. Strategy “perfect” di backtest = fail di live trading.

Sign overfitting:

  • Win rate > 80% (suspiciously high)
  • Profit factor > 5
  • Parameter unusual (RSI 13.7, EMA 27, dll — bukan round numbers)
  • Equity curve “terlalu smooth” — straight line growth

2. Lookahead Bias

Pine Script bisa accidentally use “future” data. Common sources:

  • request.security() dengan timeframe lebih besar
  • barmerge.lookahead_on setting
  • Calculations yang depend pada close future bar

Setelah deploy live, profit yang tampak di backtest hilang karena di live tidak ada akses future data.

3. Repainting Indicators

Beberapa indikator (terutama yang pakai Heikin Ashi atau security calls) “repaint” — values berubah setelah candle close. Backtest pakai final values, live pakai real-time. Result: backtest profitable, live tidak.

4. Survivorship Bias

Test pada asset yang masih trading sekarang. Banyak stocks/crypto delisted sejak dulu. Hasil bias terhadap “winners” yang survive.

5. Insufficient Sample Size

❌ Backtest dengan 30 Trades = Tidak Reliable

Statistically, butuh minimum 200 trades untuk reliable backtest. Lebih bagus 500-1000+. Kalau strategy kamu hanya menghasilkan 30 trades dalam 1 tahun, perpanjang periode test atau ubah ke higher frequency strategy.

6. Commission & Slippage Ignored

Default Pine Script tidak include commission. Untuk realistic backtest, set:

  • commission_type=strategy.commission.percent
  • commission_value=0.1 (0.1% per trade)
  • slippage=2 (ticks)

Untuk binary options di Deriv (payout 95%), commission effectively 5%. Selalu factor in.

Workflow Profesional Backtest

  1. Phase 1: In-Sample Test — Test pada data 2020-2023. Optimize parameters.
  2. Phase 2: Out-of-Sample Test — Test SAMA parameters pada 2024-2026 (data yang strategy belum lihat). Performa harus serupa.
  3. Phase 3: Walk-Forward Analysis — Roll forward through time. Optimize 3 bulan, test 1 bulan. Ulangi.
  4. Phase 4: Monte Carlo Simulation — Randomize trade order, lihat distribusi outcome.
  5. Phase 5: Paper Trade Live — Run di demo account 30+ hari. Compare hasil.
  6. Phase 6: Live dengan Small Stake — Mulai dengan stake minimal. Scale up gradually.

Optimasi Parameter — Hati-Hati

Strategy Tester punya tab “Settings” untuk tune parameters. Tapi jangan over-optimize.

⚙️ Rules untuk Optimasi

1. Maksimal 2-3 parameters dioptimize. Lebih banyak = curve fitting.
2. Pakai round numbers (RSI 14, bukan 14.7).
3. Test stability — kalau RSI 13 dan 15 hasilnya beda banget dari RSI 14, strategy unstable.
4. Out-of-sample validation wajib setelah setiap optimasi.
5. Reserve 30% data untuk validation, jangan touch saat optimasi.

Backtest untuk Binary Options (Deriv)

TradingView tidak punya direct Deriv binary options simulation, tapi kamu bisa approximate:

  1. Pakai symbol proxy: Volatility 75 → bisa pakai SPX atau XAUUSD untuk testing
  2. Strategy harus convert indicator signals ke “Rise/Fall” decisions
  3. Calculate expected P/L manual: wins × $0.95 – losses × $1
  4. Untuk testing strategy yang tepat di V75, pakai Deriv Bot replay (lebih akurat)

Verdict Backtest yang Baik

✓ Strategi Siap Live Trading

1. Profit Factor > 1.5 di in-sample dan out-of-sample
2. 200+ trades di sample
3. Max drawdown < 20%
4. Win rate 50-70% (terlalu tinggi = suspicious)
5. Sharpe ratio > 1.0
6. Performa konsisten di periode berbeda
7. Paper trade 30 hari dengan hasil serupa backtest

🚀 Test strategi yang sudah validate di demo Deriv (gratis):

Buka Demo Deriv Gratis

Topik Terkait

DM

Dan Machado

Founder IA Trader Pro · Backtest 1000+ strategies di TradingView

⚠️ Disclaimer: Backtest hanya simulasi historis dan tidak menjamin performa di masa depan. Trading binary options memiliki risiko tinggi kehilangan modal. Deriv tidak diregulasi Bappebti Indonesia. Artikel ini mengandung affiliate link Deriv. Disclaimer lengkap.

Similar Posts