PROTECTED SOURCE SCRIPT

Range Filter Strategy

14
The Range Filter Strategy, based on DonovanWall Range Filter indicator, is a trend-following trading system designed for TradingView. It identifies price trends by filtering market noise using a dynamic range based on user-defined metrics.

Functionality
Core Mechanism: The strategy calculates a central filter line (filt) with upper (h_band) and lower (l_band) bands, determined by price range and smoothing parameters, to detect trend direction.

Trend Signals:

Uptrend: Initiates a long entry when the filter line rises (filt > filt[1]).

Downtrend: Initiates a short entry when the filter line falls (filt < filt[1]).

Range Calculation: The range size is configurable using metrics such as ATR, Standard Deviation, or Percentage of Price, scaled by a user-defined quantity (rng_qty).

Smoothing: Optional EMA-based smoothing (smooth_range) refines the range to reduce false signals.

Entry/Exit Rules:

Entries: Long or short positions are opened when the trend direction changes.

Exits: Stop-loss and take-profit levels are set using the filter range, scaled by multipliers (sl_multiplier, tp_multiplier).

Position Sizing: Risks a fixed percentage of equity (default 1%) per trade, calculated based on stop-loss distance.

Commission: Incorporates trading costs (default 0.1% per trade), adjustable to match broker fees.

Key Features
Inputs:

Filter Type: Select between Type 1 (basic range filter) or Type 2 (step-based filter).

Movement Source: Choose wicks (high/low) or close prices.

Range Scale: Options include Pips, Points, Ticks, % of Price, ATR, Average Change, or Standard Deviation.

Smoothing: Enable/disable range smoothing and set period.

Risk Management: Configure risk per trade, stop-loss, and take-profit multipliers.

Visuals: Plots the filter line (green for uptrend, red for downtrend) and bands (transparent green/red). Fills between bands enhance visibility.

Output: Provides trend signals (fdir) for external use.

Usage Instructions
Setup: Apply to any chart (e.g., forex, stocks, crypto) and timeframe. Adjust inputs such as rng_qty, rng_per, sl_multiplier, and tp_multiplier to optimize for specific markets.

Trading: Enter long positions on green filter line uptrends and short positions on red filter line downtrends. Exits are automated via stop-loss and take-profit.

Backtesting: Use TradingView's strategy tester to evaluate performance and refine parameters for profitability.

Commission: Set commission_value to align with your broker’s fees for accurate net profit calculations.

Disclaimer
The Range Filter Strategy is provided for educational and informational purposes only and does not constitute financial advice. Trading carries significant risks, including potential loss of capital, and is not suitable for all investors. Past performance is not indicative of future results. Users are solely responsible for their trading decisions and should conduct thorough backtesting and validation on TradingView before deploying real capital. Adjust parameters and commission settings to reflect your broker and market conditions. Consult a qualified financial advisor prior to trading. The developers and associated parties are not liable for any losses incurred.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.