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.).
Script open-source
Dans l'esprit de TradingView, le créateur de ce script l'a rendu open-source, afin que les traders puissent examiner et vérifier sa fonctionnalité. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit de TradingView, le créateur de ce script l'a rendu open-source, afin que les traders puissent examiner et vérifier sa fonctionnalité. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.