PROTECTED SOURCE SCRIPT

SuperTrend Strategy V4 [Filtered & Directional]

108

  • Strategy Type: Trend-Following / Breakout
  • Core Indicator: SuperTrend (ATR-based trailing stop)
  • Risk Profile: Variable (User-defined Risk per Trade)
  • Filtering: ADX, CHOP


1. Executive Summary

This strategy is an advanced trend-following system designed to capture significant market moves while rigorously filtering out "noise" and consolidation phases. Built on the classic SuperTrend indicator, V4 introduces a modular "Regime Filter" suite (ADX, Choppiness Index) to solve the common problem of "whipsaw" losses during sideways markets. It features dynamic position sizing based on account risk and allows for full directional control (Long-only, Short-only, or Bi-directional).

2. Core Logic (The Engine)

The primary signal generation relies on the SuperTrend indicator, which serves two purposes:

- Trend Definition: Determining the market direction (Bullish/Bearish).
- Trailing Stop Loss: Providing a dynamic exit point that moves with the price.
- Entry Signal: A trade is triggered when the price closes on the opposite side of the SuperTrend line (flipping the trend direction), provided that all enabled filters give permission.

Important Note: ATR Length and Factor are key parameters of the strategy; to get positive backtesting results, those should be aligned individually for each specific asset and timeframe.

3. The "Anti-Whipsaw" Filter Suite

To prevent overtrading in ranging markets, the strategy employs three selectable filters. These act as "logic gates" if any enabled filter says "No," the trade is skipped.

A. Choppiness Index (The Noise Filter):
- Purpose: Detects lack of trend.
- Logic: If the "Chop" value exceeds the threshold, the market is considered too chaotic. The strategy waits for the index to drop, indicating a return to directional movement.
- Default settings (recommended):
- Chop Length: 14
- Max Chop Threshold: 55

B. ADX (The Strength Filter):
- Purpose: Measures the strength of the current trend.
- Logic: Only permits entry if the Average Directional Index (ADX) is above a set threshold, ensuring momentum is present.
- Default settings (recommended):
- DI Length: 14
- ADX Smoothing Length: 5
- Min ADX Threshold: 15

4. Risk Management & Position Sizing*

Instead of fixed lot sizes, this strategy uses Volatility-Adjusted Sizing:

- Risk Per Trade: The user defines a fixed dollar amount to risk according to initial capital.
- Calculation: The script calculates the distance between the Entry Price and the SuperTrend (Stop Loss). It then mathematically determines the exact position size so that if the Stop Loss is hit, the loss equals the defined risk amount.
- Safety: Includes a failsafe for zero-division errors during extreme volatility (e.g., crypto flash crashes).

5. Directional Bias Control

Recognizing that different assets have different biases (e.g., Crypto is often long-biased; Forex pairs can be mean-reverting), V4 allows the user to toggle:

- Enable Longs: Toggle ON/OFF.
- Enable Shorts: Toggle ON/OFF.

Note: Disabling a direction prevents new entries but allows existing positions to close naturally to preserve capital.

6. Visual Aids

- Trend Lines: Green/Red SuperTrend line indicates active trailing stop.
- Regime Highlighting: The chart background turns Gray when the market is in a "No Trade Zone" (failed filter checks), allowing for instant visual backtesting of the filters' effectiveness.

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.