OPEN-SOURCE SCRIPT
BTC DCA Risk Metric Strategy

BTC DCA Risk Strategy - Automated Dollar Cost Averaging with 3Commas Integration
Overview
This strategy combines the proven Oakley Wood Risk Metric with an intelligent tiered Dollar Cost Averaging (DCA) system, designed to help traders systematically accumulate Bitcoin during periods of low risk and take profits during high-risk conditions.
Key Features
📊 Multi-Component Risk Assessment
4-Year SMA Deviation: Measures Bitcoin's distance from its long-term mean
20-Week MA Analysis: Tracks medium-term momentum shifts
50-Day/50-Week MA Ratio: Captures short-to-medium term trend strength
All metrics are normalized by time to account for Bitcoin's maturing market dynamics
💰 3-Tier DCA Buy System
Level 1 (Low Risk): Conservative entry with base allocation
Level 2 (Lower Risk): Increased allocation as opportunity improves
Level 3 (Extreme Low Risk): Maximum allocation during rare buying opportunities
Buys execute every bar while risk remains below thresholds, enabling true DCA accumulation
📈 Progressive Profit Taking
Sell Level 1: Take initial profits as risk increases
Sell Level 2: Scale out further positions during elevated risk
Sell Level 3: Final exit during extreme market conditions
Sell levels automatically reset when new buy signals occur, allowing flexible re-entry
🤖 3Commas Integration
Fully automated webhook alerts for Custom Signal Bots
JSON payloads formatted per 3Commas API specifications
Supports multiple exchanges (Binance, Coinbase, Kraken, Gemini, Bybit)
Configurable quote currency (USD, USDT, BUSD)
How It Works
The strategy calculates a composite risk metric (0-1 scale):
0.0-0.2: Extreme buying opportunity (green zone)
0.2-0.5: Favorable accumulation range (yellow zone)
0.5-0.8: Neutral to cautious territory (orange zone)
0.8-1.0+: High risk, profit-taking zone (red zone)
Buy Logic: As risk decreases, position sizes increase automatically. If risk drops from L1 to L3 threshold, the strategy combines all three tier allocations for maximum exposure.
Sell Logic: Sequential profit-taking ensures you capture gains progressively. The system won't advance to Sell L2 until L1 completes, preventing premature full exits.
Configuration
Risk Metric Parameters:
All calculations use Bitcoin price data (any BTC chart works)
Time-normalized formulas adapt to market maturity
No manual parameter tuning required
Buy Settings:
Set risk thresholds for each tier (default: 0.20, 0.10, 0.00)
Define dollar amounts per tier (default: $10, $15, $20)
Fully customizable to your risk tolerance and capital
Sell Settings:
Configure risk thresholds for profit-taking (default: 1.00, 1.50, 2.00)
Set percentage of position to sell at each level (default: 25%, 35%, 40%)
3Commas Setup:
Create a Custom Signal Bot in 3Commas
Copy Bot UUID and Secret Token into strategy inputs
Enable 3Commas Alerts checkbox
Create TradingView alert: Condition → "alert() function calls only", Webhook → api.3commas.io/signal_bots/webhooks
Backtesting Results
Strengths:
Systematically buys dips without emotion
Averages down during extended bear markets
Captures explosive bull run profits through tiered exits
Pyramiding (1000 max orders) allows true DCA behavior
Considerations:
Requires sufficient capital for multiple buys during prolonged downtrends
Backtest on Daily timeframe for most reliable signals
Past performance does not guarantee future results
Visual Design
The indicator pane displays:
Color-coded risk metric line: Changes from white→red→orange→yellow→green as risk decreases
Background zones: Green (buy), yellow (hold), red (sell) areas
Dashed threshold lines: Clear visual markers for each buy/sell level
Entry/Exit labels: Green buy labels and orange/red sell labels mark all trades
Credits
Original Risk Metric: Oakley Wood
Strategy Development & 3Commas Integration: Claude AI (Anthropic)
Modifications: pommesUNDwurst
Disclaimer
This strategy is for educational and informational purposes only. Cryptocurrency trading carries substantial risk of loss. Always conduct your own research and never invest more than you can afford to lose. The authors are not financial advisors and assume no responsibility for trading decisions made using this tool.
Overview
This strategy combines the proven Oakley Wood Risk Metric with an intelligent tiered Dollar Cost Averaging (DCA) system, designed to help traders systematically accumulate Bitcoin during periods of low risk and take profits during high-risk conditions.
Key Features
📊 Multi-Component Risk Assessment
4-Year SMA Deviation: Measures Bitcoin's distance from its long-term mean
20-Week MA Analysis: Tracks medium-term momentum shifts
50-Day/50-Week MA Ratio: Captures short-to-medium term trend strength
All metrics are normalized by time to account for Bitcoin's maturing market dynamics
💰 3-Tier DCA Buy System
Level 1 (Low Risk): Conservative entry with base allocation
Level 2 (Lower Risk): Increased allocation as opportunity improves
Level 3 (Extreme Low Risk): Maximum allocation during rare buying opportunities
Buys execute every bar while risk remains below thresholds, enabling true DCA accumulation
📈 Progressive Profit Taking
Sell Level 1: Take initial profits as risk increases
Sell Level 2: Scale out further positions during elevated risk
Sell Level 3: Final exit during extreme market conditions
Sell levels automatically reset when new buy signals occur, allowing flexible re-entry
🤖 3Commas Integration
Fully automated webhook alerts for Custom Signal Bots
JSON payloads formatted per 3Commas API specifications
Supports multiple exchanges (Binance, Coinbase, Kraken, Gemini, Bybit)
Configurable quote currency (USD, USDT, BUSD)
How It Works
The strategy calculates a composite risk metric (0-1 scale):
0.0-0.2: Extreme buying opportunity (green zone)
0.2-0.5: Favorable accumulation range (yellow zone)
0.5-0.8: Neutral to cautious territory (orange zone)
0.8-1.0+: High risk, profit-taking zone (red zone)
Buy Logic: As risk decreases, position sizes increase automatically. If risk drops from L1 to L3 threshold, the strategy combines all three tier allocations for maximum exposure.
Sell Logic: Sequential profit-taking ensures you capture gains progressively. The system won't advance to Sell L2 until L1 completes, preventing premature full exits.
Configuration
Risk Metric Parameters:
All calculations use Bitcoin price data (any BTC chart works)
Time-normalized formulas adapt to market maturity
No manual parameter tuning required
Buy Settings:
Set risk thresholds for each tier (default: 0.20, 0.10, 0.00)
Define dollar amounts per tier (default: $10, $15, $20)
Fully customizable to your risk tolerance and capital
Sell Settings:
Configure risk thresholds for profit-taking (default: 1.00, 1.50, 2.00)
Set percentage of position to sell at each level (default: 25%, 35%, 40%)
3Commas Setup:
Create a Custom Signal Bot in 3Commas
Copy Bot UUID and Secret Token into strategy inputs
Enable 3Commas Alerts checkbox
Create TradingView alert: Condition → "alert() function calls only", Webhook → api.3commas.io/signal_bots/webhooks
Backtesting Results
Strengths:
Systematically buys dips without emotion
Averages down during extended bear markets
Captures explosive bull run profits through tiered exits
Pyramiding (1000 max orders) allows true DCA behavior
Considerations:
Requires sufficient capital for multiple buys during prolonged downtrends
Backtest on Daily timeframe for most reliable signals
Past performance does not guarantee future results
Visual Design
The indicator pane displays:
Color-coded risk metric line: Changes from white→red→orange→yellow→green as risk decreases
Background zones: Green (buy), yellow (hold), red (sell) areas
Dashed threshold lines: Clear visual markers for each buy/sell level
Entry/Exit labels: Green buy labels and orange/red sell labels mark all trades
Credits
Original Risk Metric: Oakley Wood
Strategy Development & 3Commas Integration: Claude AI (Anthropic)
Modifications: pommesUNDwurst
Disclaimer
This strategy is for educational and informational purposes only. Cryptocurrency trading carries substantial risk of loss. Always conduct your own research and never invest more than you can afford to lose. The authors are not financial advisors and assume no responsibility for trading decisions made using this tool.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
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.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
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.