OPEN-SOURCE SCRIPT

Darvas Lines/Box

421
1. Overview
The Darvas Lines/Box (v1.0) is a dynamic trend following indicator based on the renowned method developed by Nicolas Darvas. It's designed to identify clear price consolidation ranges and detect decisive breakouts, crucial for positional and swing trading strategies.

This indicator automatically draws and adjusts the consolidation ranges, and includes modern enhancements such as Advanced Retest Confirmation and exposed alert conditions, providing reliable signals for monitoring and acting on trend continuations.

2. Core Features
Custom Display Mode (Lines/Box): Allows the user to toggle the visualization between showing just the Breakout Lines (Lines) or displaying the consolidation area with a filled background box (Box).

Source Selection (Wicks/Body): Users can choose whether the box boundaries are defined by the candlestick wicks (price extremes) or the candlestick body (open/close price). This feature is critical for adjusting sensitivity to market noise.

Dynamic Box Drawing: Draws Darvas boxes automatically by tracking price highs and lows based on user-defined parameters (Bars to Define Range, Max Box Height).

Retest Confirmation: Detects if the old resistance/support line functions effectively after a breakout. When a retest is confirmed, the line is extended and its color changes.

Price Labels (Stable Lock): Displays the highest and lowest box prices, fixed to the left outer edge of the box. This ensures stable visibility.

Progress Labels: Visualizes the current line price and the percentage distance to the closing price on the right side of the box, showing progress toward the next breakout.

3. Trading Strategy: How to Use the Indicator
This indicator is primarily used to identify trend initiation and trend continuation signals.

A. Entry Strategy (Breakout)
Long Entry Action: Consider taking a long entry when the price closes above the Upper Line (Green Line), signaled by a BULLISH BREAKOUT alert.

Signal: Use the BULLISH BREAKOUT alert.

Short Entry Action: Consider taking a short entry when the price closes below the Lower Line (Red Line), signaled by a BEARISH BREAKOUT alert.

Signal: Use the BEARISH BREAKOUT alert.

B. Retest Strategy (Add-on/Confirmation)
Action: When the price pulls back to touch the broken line (signaled by RETEST CONFIRMED), this confirms the break's validity.

Alert: The RETEST CONFIRMED alert is triggered at this moment.

C. Risk Management (General)
Stop Loss: The initial stop-loss is typically set just beyond the opposite side of the broken box. As the trend progresses and new boxes form, the lower boundary of the most recently formed box can be used as a trailing stop for managing risk.

4. Setting Parameters
Line Source (Wicks/Body): Crucial for sensitivity. 'Wicks' tracks price extremes; 'Body' tracks stronger close-to-close movements, ignoring noise.

Bars to Define Range: Defines the calculation period (in bars) for the box.

Cooldown Bars After Breakout: Sets the waiting period after a breakout before a new box can start forming.

Retest Lookback Bars (Phase 3): Sets the maximum number of bars to check for a retest during the cooldown phase.

Max Gap for Retest (%): Defines the maximum percentage distance from the line allowed to confirm a retest (Set to Zero (0.0%) for near-touch detection).

Alert Frequency (Breakout): Allows selection between Continuous and Once per Box for breakout signals.

5. Alerts: How to Set Up the Triggers
This indicator exposes several specific conditions to the TradingView alert panel, allowing you to select the exact event you want to monitor.

Step-by-Step Alert Setup:
Open the Alert Panel on the chart.

In the Condition field, select the indicator's name.

In the Alert Condition field, choose the specific event you want to monitor:

1. ANY DARVAS EVENT (Consolidated)

2. BULLISH BREAKOUT (Individual)

3. BEARISH BREAKOUT (Individual)

4. RETEST CONFIRMED (Individual)

In the Trigger field (Frequency), select your preferred native option (e.g., "Once Per Bar Close" or "Once per bar").

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。