OPEN-SOURCE SCRIPT
DCA Percent Signal

Overview
The DCA Percent Signal Indicator generates buy and sell signals based on percentage drops from all-time highs and percentage gains from lowest lows since ATH. This indicator is designed for pyramiding strategies where each signal represents a configurable percentage of equity allocation.
Definitions
DCA (Dollar-Cost Averaging): An investment strategy where you invest a fixed amount at regular intervals, regardless of price fluctuations. This indicator generates signals for a DCA-style pyramiding approach.
Gann Bar Types: Classification system for price bars based on their relationship to the previous bar:
ATH (All-Time High): The highest price level reached during the entire chart period
ATL (All-Time Low): The lowest price level reached since the most recent ATH
Pyramiding: A trading strategy that adds to positions on favorable price movements
Look-Ahead Bias: Using future information that wouldn't be available in real-time trading
Default Properties
Signal Thresholds:
Price Sources:
Filter Options:
Display Options:
How It Works
Buy Signals: Trigger every 10% drop from the all-time highest price reached
Sell Signals: Trigger every 30% increase from the lowest low since the most recent all-time high
Smart Tracking: Uses configurable price sources for signal generation
Key Features
Usage Instructions
Signal Logic
Buy Signals:
Sell Signals:
Limitations
Implementation Notes
The DCA Percent Signal Indicator generates buy and sell signals based on percentage drops from all-time highs and percentage gains from lowest lows since ATH. This indicator is designed for pyramiding strategies where each signal represents a configurable percentage of equity allocation.
Definitions
DCA (Dollar-Cost Averaging): An investment strategy where you invest a fixed amount at regular intervals, regardless of price fluctuations. This indicator generates signals for a DCA-style pyramiding approach.
Gann Bar Types: Classification system for price bars based on their relationship to the previous bar:
- Up Bar: High > previous high AND low ≥ previous low
- Down Bar: High ≤ previous high AND low < previous low
- Inside Bar: High ≤ previous high AND low ≥ previous low
- Outside Bar: High > previous high AND low < previous low
ATH (All-Time High): The highest price level reached during the entire chart period
ATL (All-Time Low): The lowest price level reached since the most recent ATH
Pyramiding: A trading strategy that adds to positions on favorable price movements
Look-Ahead Bias: Using future information that wouldn't be available in real-time trading
Default Properties
Signal Thresholds:
- Buy Threshold: 10% (triggers every 10% drop from ATH)
- Sell Threshold: 30% (triggers every 30% gain from lowest low since ATH)
Price Sources:
- ATH Tracking: High (ATH detection)
- ATL Tracking: Low (low detection)
- Buy Signal Source: Low (buy signals)
- Sell Signal Source: High (sell signals)
Filter Options:
- Apply Gann Filter: False (disabled by default)
- Buy Sets ATL: False (disabled by default)
Display Options:
- Show Buy/Sell Signals: True
- Show Reference Lines: True
- Show Info Table: False
- Show Bar Type: False
How It Works
Buy Signals: Trigger every 10% drop from the all-time highest price reached
Sell Signals: Trigger every 30% increase from the lowest low since the most recent all-time high
Smart Tracking: Uses configurable price sources for signal generation
Key Features
- Configurable Thresholds: Adjustable buy/sell percentage thresholds (default: 10%/30%)
- Separate Price Sources: Independent sources for ATH tracking, ATL tracking, and signal triggers
- Configurable Signals: Uses low for buy signals and high for sell signals by default
- Optional Gann Filter: Apply Gann bar analysis for additional signal filtering
- Optional Buy Sets ATL: Option to set ATL reference point when buy signals occur
- Visual Debug: Detailed labels showing signal parameters and values
Usage Instructions
- Apply to Chart: Use on any timeframe (recommended: 1D or higher for better signal quality)
- Risk Management: Adjust thresholds based on your risk tolerance and market volatility
- Signal Analysis: Monitor debug labels for detailed signal information and validation
Signal Logic
- Buy signals are blocked when ATH increases to prevent buying at peaks
- Sell signals are blocked when ATL decreases to prevent selling at lows
- This ensures signals only trigger on subsequent bars, not the same bar that establishes new reference points
Buy Signals:
- Calculate drop percentage from ATH to buy signal source
- Trigger when drop reaches threshold increments (10%, 20%, 30%, etc.)
- Always blocked on ATH bars to prevent buying at peaks
- Optional: Also blocked on up/outside bars when Gann filter enabled
Sell Signals:
- Calculate gain percentage from lowest low to sell signal source
- Trigger when gain reaches threshold increments (30%, 60%, 90%, etc.)
- Always blocked when ATL decreases to prevent selling at lows
- Optional: Also blocked on down bars when Gann filter enabled
Limitations
- Designed for trending markets; may generate many signals in sideways/ranging markets
- Requires sufficient price movement to be effective
- Not suitable for scalping or very short timeframes
Implementation Notes
- Signals use optimistic price sources (low for buys, high for sells), these can be configured to be more conservative
- Gann filter provides additional signal filtering based on bar types
- Debug information available in data window for real-time analysis
- Detailed labels on each signal show ATH, lowest low, buy level, sell level, and drop/gain percentages
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。