PROTECTED SOURCE SCRIPT
SuperTrend Strategy with Trend-Based Exits

🟩 SuperTrend Strategy with Trend-Based Exits
This is a fully automated trend-following strategy based on the popular SuperTrend indicator, enhanced with a position sizing algorithm tied to stop-loss distance and dynamic entry/exit rules. The strategy is designed for futures trading with an emphasis on sustainable risk, realistic backtesting, and transparent logic.
🧠 Concept and Methodology
The strategy uses the SuperTrend indicator, which is derived from ATR (Average True Range) and is widely used to capture medium- to long-term market trends.
Key features:
✅ Entries are triggered only when the SuperTrend direction changes (trend reversal).
✅ Exits are performed using a dynamic stop-loss placed at the SuperTrend line.
✅ Position size is automatically calculated based on the trader’s fixed dollar risk per trade and the current distance to the stop-loss.
✅ Rounding logic is included to ensure quantity is valid for the exchange’s lot size.
This strategy does not use any take-profit or classic trailing stop — the position is only closed when the trend reverses or the stop is hit by touching the SuperTrend line.
⚙️ Default Parameters
ATR Length: 92
Factor: 4.6
Risk per trade: $200 (2% of the default $10,000 capital)
Lot step: 0.01
Commission: 0.05%
Slippage: 5 ticks
These default parameters are not universal. They were optimized specifically for ETHUSDT at 15M timeframe and may not produce viable results on other pairs and timeframes.
Users are encouraged to customize the settings according to specific asset’s volatility, timeframe and other characteristics.
❗ These default settings yield meaningful backtesting results on ETHUSDT with a reasonable number of trades (180+) over 6-month period. If applied to other assets, results may vary significantly.
📈 Position Sizing Logic
The strategy uses a dynamic position sizing formula:
Pine Script®
This ensures the trader always risks a fixed dollar amount per trade and never exceeds a sustainable equity exposure (recommended 2% or less).
✅ Realism in Backtesting
To ensure realistic and non-misleading backtest results, this strategy includes:
— Slippage and commission settings matching average exchange conditions (commission = 0.05%, slippage 5 ticks).
— Position sizing based on stop-loss distance (not fixed contract quantity).*
— A fixed risk-per-trade model that adheres to responsible capital management principles.
— This is in compliance with TradingView's Script publishing rules and House Rules.
📌 How to Use
Apply the strategy to a clean chart (preferably 15M for ETHUSDT by default).
If using another asset, adjust:
- ATR Length
- Factor
- Risk per trade
- Qty step (lot precision for the symbol)
Avoid using with other indicators unless you understand their purpose.
Use the Strategy Tester to evaluate performance and optimize parameters.
⚠️ Disclaimer
This is not financial advice. Always perform forward testing and assess risk before deploying any strategy on live capital. The strategy is designed for educational and experimental use.
This is a fully automated trend-following strategy based on the popular SuperTrend indicator, enhanced with a position sizing algorithm tied to stop-loss distance and dynamic entry/exit rules. The strategy is designed for futures trading with an emphasis on sustainable risk, realistic backtesting, and transparent logic.
🧠 Concept and Methodology
The strategy uses the SuperTrend indicator, which is derived from ATR (Average True Range) and is widely used to capture medium- to long-term market trends.
Key features:
✅ Entries are triggered only when the SuperTrend direction changes (trend reversal).
✅ Exits are performed using a dynamic stop-loss placed at the SuperTrend line.
✅ Position size is automatically calculated based on the trader’s fixed dollar risk per trade and the current distance to the stop-loss.
✅ Rounding logic is included to ensure quantity is valid for the exchange’s lot size.
This strategy does not use any take-profit or classic trailing stop — the position is only closed when the trend reverses or the stop is hit by touching the SuperTrend line.
⚙️ Default Parameters
ATR Length: 92
Factor: 4.6
Risk per trade: $200 (2% of the default $10,000 capital)
Lot step: 0.01
Commission: 0.05%
Slippage: 5 ticks
These default parameters are not universal. They were optimized specifically for ETHUSDT at 15M timeframe and may not produce viable results on other pairs and timeframes.
Users are encouraged to customize the settings according to specific asset’s volatility, timeframe and other characteristics.
❗ These default settings yield meaningful backtesting results on ETHUSDT with a reasonable number of trades (180+) over 6-month period. If applied to other assets, results may vary significantly.
📈 Position Sizing Logic
The strategy uses a dynamic position sizing formula:
position_size = floor((risk_per_trade / stop_loss_distance) / lot_step) * lot_step
This ensures the trader always risks a fixed dollar amount per trade and never exceeds a sustainable equity exposure (recommended 2% or less).
✅ Realism in Backtesting
To ensure realistic and non-misleading backtest results, this strategy includes:
— Slippage and commission settings matching average exchange conditions (commission = 0.05%, slippage 5 ticks).
— Position sizing based on stop-loss distance (not fixed contract quantity).*
— A fixed risk-per-trade model that adheres to responsible capital management principles.
— This is in compliance with TradingView's Script publishing rules and House Rules.
📌 How to Use
Apply the strategy to a clean chart (preferably 15M for ETHUSDT by default).
If using another asset, adjust:
- ATR Length
- Factor
- Risk per trade
- Qty step (lot precision for the symbol)
Avoid using with other indicators unless you understand their purpose.
Use the Strategy Tester to evaluate performance and optimize parameters.
⚠️ Disclaimer
This is not financial advice. Always perform forward testing and assess risk before deploying any strategy on live capital. The strategy is designed for educational and experimental use.
Script protetto
Questo script è pubblicato come codice protetto. Tuttavia, è possibile utilizzarlo liberamente e senza alcuna limitazione – per saperne di più clicca qui.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script protetto
Questo script è pubblicato come codice protetto. Tuttavia, è possibile utilizzarlo liberamente e senza alcuna limitazione – per saperne di più clicca qui.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.