OPEN-SOURCE SCRIPT

Range Finder

290
Range Finder Strategy for TradingView

Overview

The Range Finder Strategy is a sophisticated trading system designed for forex and cryptocurrency markets, leveraging dynamic range detection, wick-based rejection patterns, and EMA confluence to execute high-probability trades. This strategy identifies key price ranges using pivot points and triggers trades when price rejects from these boundaries with significant wick formations, aligning with the broader market trend as confirmed by EMA crossovers. It incorporates robust risk management, customizable parameters, and visual aids for clear trade visualization, making it suitable for both manual and automated trading on platforms like Bitget via webhook alerts.

Strategy Components

1. Dynamic Range Detection





Pivot Points: The strategy identifies range boundaries using pivot highs and lows, calculated with a user-defined Pivot Length (default: 5 bars left/right). These pivots mark significant swing points, defining the upper (range high) and lower (range low) boundaries of the price range.



Visualization: The range high is plotted as an orange line, and the range low as a purple line, using a broken line style (plot.style_linebr) to show only confirmed pivot levels, providing a clear visual of the trading range.

2. Wick-Based Rejection Pattern





Wick Detection: The strategy looks for rejection candles at the range boundaries, characterized by significant wicks. A wick is considered valid if its size is at least the user-defined Wick to Body Ratio (default: 1.1, or 10% larger than the candle body).





Sell Signal: Triggered when the high exceeds the range high, the candle closes bearish (close < open), and the upper wick meets the ratio requirement.



Buy Signal: Triggered when the low falls below the range low, the candle closes bullish (close > open), and the lower wick meets the ratio requirement.



Purpose: These wicks indicate strong rejection at key levels, often signaling a reversal back into the range, providing high-probability entry points.

3. EMA Trend Confirmation





EMA Calculation: Uses two Exponential Moving Averages (EMAs) calculated on a user-selectable timeframe (default: 5-minute):





EMA 200: Long-term trend indicator (plotted in red).



EMA 50: Short-term trend indicator (plotted in green).



Crossover Logic:





A bullish trend is confirmed when the EMA 50 crosses above the EMA 200 (ema_trend_up = true).



A bearish trend is confirmed when the EMA 50 crosses below the EMA 200 (ema_trend_down = true).



Confluence Requirement: Trades are only executed when the wick rejection aligns with the EMA trend (e.g., sell signals require close < ema200 and bearish trend; buy signals require close > ema200 and bullish trend).

4. Risk Management





Position Sizing: Calculated based on the user-defined Account Balance (default: $10,000) and Risk Per Trade (default: 2%). The position size is determined as risk_amount / stop_distance, where stop_distance is derived from the Average True Range (ATR, default period: 14).



Stop Loss (SL): Set using an ATR-based multiplier (SL Multiplier, default: 9.0). For sells, SL is placed above the high; for buys, below the low.



Take Profit (TP): Set using an ATR-based multiplier (TP Multiplier, default: 6.0) scaled by the Risk:Reward Ratio (default: 6.0), ensuring a favorable reward-to-risk profile.



Example: For a $10,000 account with 2% risk, if ATR is 0.5, the position size is 400 units, with SL and TP dynamically adjusted to market volatility.

5. Trade Execution





Sell Entry: Triggered on a wick rejection above the range high, with bearish EMA confluence (ema_trend_down and close < ema200). Enters a short position with calculated SL and TP.



Buy Entry: Triggered on a wick rejection below the range low, with bullish EMA confluence (ema_trend_up and close > ema200). Enters a long position with calculated SL and TP.



Exit Logic: Uses strategy.exit to set SL and TP levels, closing trades when either is hit.

6. Visual Feedback





Lines and Labels: Upon trade entry, the strategy plots:





Red SL line and label (e.g., "SL: 123.45").



Green TP line and label (e.g., "TP: 120.00").



Entry line (red for sell, green for buy) labeled with "Sell (Range Rejection)" or "Buy (Range Rejection)".



Customization: Users can adjust the Line Length (default: 25 bars) for how long lines persist and Label Position (left or right) for optimal chart visibility.

7. Alert Conditions





Webhook Integration: Generates alerts for Bitget webhook integration, providing JSON-formatted messages with trade details (action, contracts, market position, size, price, symbol, and timestamp).



Usage: Traders can set up automated trading by connecting these alerts to trading bots or platforms supporting webhooks.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.