OPEN-SOURCE SCRIPT
NP : Supertrend Optimizer

NP : Supertrend Optimizer runs multiple Supertrend variants at once (different ATR multipliers/factors), tracks their historical performance, and then highlights the best-scoring factor. It plots that chosen Supertrend on your chart and shows a performance table so you can compare settings at a glance.
Under the hood it:
Computes Supertrend for a fixed set of factors (1.0 → 3.0 in 0.25 steps).
“Paper trades” each factor: enters on a Supertrend flip, exits on the next flip.
Records per-factor stats: Trades, Win %, Avg Win %, Avg Loss %, Win/Loss ratio, Max Loss %, and a composite Score (Win % × W/L).
Picks the winner (highest Score) and plots only that factor’s Supertrend (green for uptrend, red for downtrend, with background fill).
Note: The script determines the winner at the latest bar, then shows that choice across history for easy visual comparison. That’s great for parameter discovery, but it’s not meant as a forward-tested strategy as-is.
How to use it
Add to chart and pick your timeframe/symbol.
Tune the core setting:
ATR Length: Smoother (higher) vs more reactive (lower).
Read the table:
Trades: number of completed flips.
Win %: share of profitable trades.
Avg Win % / Avg Loss %: average move per winning/losing trade.
Avg W/L: average win divided by average loss (>1 is good).
Max Loss %: worst trade drawdown.
Score: Win % × Avg W/L (used to rank factors).
Act on the insights:
Use the winner’s factor as your preferred setting.
For live use, consider locking that factor (e.g., replace the factors array with only your chosen value) to avoid optimization bias.
Combine with your own filters (trend strength, volume, market regime, higher-TF confirmation, etc.).
Under the hood it:
Computes Supertrend for a fixed set of factors (1.0 → 3.0 in 0.25 steps).
“Paper trades” each factor: enters on a Supertrend flip, exits on the next flip.
Records per-factor stats: Trades, Win %, Avg Win %, Avg Loss %, Win/Loss ratio, Max Loss %, and a composite Score (Win % × W/L).
Picks the winner (highest Score) and plots only that factor’s Supertrend (green for uptrend, red for downtrend, with background fill).
Note: The script determines the winner at the latest bar, then shows that choice across history for easy visual comparison. That’s great for parameter discovery, but it’s not meant as a forward-tested strategy as-is.
How to use it
Add to chart and pick your timeframe/symbol.
Tune the core setting:
ATR Length: Smoother (higher) vs more reactive (lower).
Read the table:
Trades: number of completed flips.
Win %: share of profitable trades.
Avg Win % / Avg Loss %: average move per winning/losing trade.
Avg W/L: average win divided by average loss (>1 is good).
Max Loss %: worst trade drawdown.
Score: Win % × Avg W/L (used to rank factors).
Act on the insights:
Use the winner’s factor as your preferred setting.
For live use, consider locking that factor (e.g., replace the factors array with only your chosen value) to avoid optimization bias.
Combine with your own filters (trend strength, volume, market regime, higher-TF confirmation, etc.).
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, penulis skrip ini telah menjadikannya sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Hormat untuk penulisnya! Meskipun anda dapat menggunakannya secara gratis, ingatlah bahwa penerbitan ulang kode tersebut tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, penulis skrip ini telah menjadikannya sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Hormat untuk penulisnya! Meskipun anda dapat menggunakannya secara gratis, ingatlah bahwa penerbitan ulang kode tersebut tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.