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.).
Skrypt open-source
W duchu TradingView twórca tego skryptu udostępnił go jako open-source, aby traderzy mogli analizować i weryfikować jego funkcjonalność. Brawo dla autora! Możesz korzystać z niego za darmo, ale pamiętaj, że ponowna publikacja kodu podlega naszym Zasadom Społeczności.
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.
Skrypt open-source
W duchu TradingView twórca tego skryptu udostępnił go jako open-source, aby traderzy mogli analizować i weryfikować jego funkcjonalność. Brawo dla autora! Możesz korzystać z niego za darmo, ale pamiętaj, że ponowna publikacja kodu podlega naszym Zasadom Społeczności.
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.