OPEN-SOURCE SCRIPT
Aggiornato BTC(Sats Stacking) - CDC Action zone filter

Type: Indicator (Pine v6) • Category: Strategy Tools / DCA • Overlay: Yes
Overview
This indicator simulates fixed-amount Bitcoin DCA (dollar-cost averaging) and lets you apply a CDC Action Zone filter to only buy in specific market conditions. It plots EMA(12/26) lines with a shaded zone (green when fast > slow, red when slow > fast), shows buy markers on the chart when a DCA event actually executes, and displays a concise performance table.
The simulation tracks real invested capital (sum of your buys), not hypothetical equity injections, and reports PnL vs invested capital.
Key features
DCA frequency: Everyday, Every week, or Every month
CDC filter: Buy on all days, only when CDC is Green (trend-up above fast EMA), or only when Red (trend-down below fast EMA)
Execution price: Choose to buy at bar close or next bar open
Capital controls: Fixed DCA amount per event, optional max budget cap
Currency support: Portfolio currency label plus optional FX conversion (by symbol or manual rate)
Chart visuals: Buy markers on candles; EMA(12/26) lines with shaded “action zone”
Metrics table: Invested capital, buys executed, BTC accumulated, average price per BTC (quote), equity (portfolio), PnL% vs invested, and CAGR
How it works
CDC state:
Green = EMA(fast) > EMA(slow) and price ≥ EMA(fast)
Red = EMA(fast) < EMA(slow) and price < EMA(fast)
DCA trigger: Fires on new day/week/month boundaries (timeframe-agnostic).
Buy execution: When a DCA event occurs and passes the CDC filter and budget check, the script spends the fixed amount and adds the corresponding BTC at the chosen execution price.
Inputs (highlights)
Simulation
Symbol (blank = current chart), Buy at close/open, DCA amount, Max total invested
DCA Schedule
Everyday / Every week / Every month
CDC Action Zone
Filter mode (All / Green only / Red only), Price source, Fast/Slow EMA lengths (defaults 12/26)
Currency / Conversion
Portfolio currency label, Convert on/off, By symbol (e.g., OANDA:USDTHB) or Manual rate
Backtest Range
Optional start/end dates
Style
Show EMA lines and zone, colors and opacities, buy marker size and color
Display
Show qty/price labels on buys, show metrics table, number formatting
Metrics
Invested capital: Sum of all DCA spends in your portfolio currency
Equity (portfolio): BTC holdings marked to market and converted back if FX is enabled
PnL % vs invested: (Equity / Invested - 1) × 100
CAGR: Based on elapsed time from first in-range bar to the latest bar
Average price per BTC (quote): Spend in quote currency divided by BTC accumulated
Notes
This is an indicator, not a broker-connected strategy. It simulates buys and displays results without placing orders.
For more realistic fills, use Buy at next bar open.
If your portfolio currency differs from the symbol’s quote currency, enable Convert and supply a conversion symbol or manual rate.
EMA shading is purely visual; the filter logic uses the same EMA definitions.
Attribution & License
Inspired by the DCA idea and community simulations; CDC filtering implemented with standard EMA(12/26) logic.
License: MPL-2.0 (see code header).
Author: MiSuNoJo
Disclaimer
This tool is for research and education only and is not financial advice. Past performance does not guarantee future results. Use at your own risk.
Overview
This indicator simulates fixed-amount Bitcoin DCA (dollar-cost averaging) and lets you apply a CDC Action Zone filter to only buy in specific market conditions. It plots EMA(12/26) lines with a shaded zone (green when fast > slow, red when slow > fast), shows buy markers on the chart when a DCA event actually executes, and displays a concise performance table.
The simulation tracks real invested capital (sum of your buys), not hypothetical equity injections, and reports PnL vs invested capital.
Key features
DCA frequency: Everyday, Every week, or Every month
CDC filter: Buy on all days, only when CDC is Green (trend-up above fast EMA), or only when Red (trend-down below fast EMA)
Execution price: Choose to buy at bar close or next bar open
Capital controls: Fixed DCA amount per event, optional max budget cap
Currency support: Portfolio currency label plus optional FX conversion (by symbol or manual rate)
Chart visuals: Buy markers on candles; EMA(12/26) lines with shaded “action zone”
Metrics table: Invested capital, buys executed, BTC accumulated, average price per BTC (quote), equity (portfolio), PnL% vs invested, and CAGR
How it works
CDC state:
Green = EMA(fast) > EMA(slow) and price ≥ EMA(fast)
Red = EMA(fast) < EMA(slow) and price < EMA(fast)
DCA trigger: Fires on new day/week/month boundaries (timeframe-agnostic).
Buy execution: When a DCA event occurs and passes the CDC filter and budget check, the script spends the fixed amount and adds the corresponding BTC at the chosen execution price.
Inputs (highlights)
Simulation
Symbol (blank = current chart), Buy at close/open, DCA amount, Max total invested
DCA Schedule
Everyday / Every week / Every month
CDC Action Zone
Filter mode (All / Green only / Red only), Price source, Fast/Slow EMA lengths (defaults 12/26)
Currency / Conversion
Portfolio currency label, Convert on/off, By symbol (e.g., OANDA:USDTHB) or Manual rate
Backtest Range
Optional start/end dates
Style
Show EMA lines and zone, colors and opacities, buy marker size and color
Display
Show qty/price labels on buys, show metrics table, number formatting
Metrics
Invested capital: Sum of all DCA spends in your portfolio currency
Equity (portfolio): BTC holdings marked to market and converted back if FX is enabled
PnL % vs invested: (Equity / Invested - 1) × 100
CAGR: Based on elapsed time from first in-range bar to the latest bar
Average price per BTC (quote): Spend in quote currency divided by BTC accumulated
Notes
This is an indicator, not a broker-connected strategy. It simulates buys and displays results without placing orders.
For more realistic fills, use Buy at next bar open.
If your portfolio currency differs from the symbol’s quote currency, enable Convert and supply a conversion symbol or manual rate.
EMA shading is purely visual; the filter logic uses the same EMA definitions.
Attribution & License
Inspired by the DCA idea and community simulations; CDC filtering implemented with standard EMA(12/26) logic.
License: MPL-2.0 (see code header).
Author: MiSuNoJo
Disclaimer
This tool is for research and education only and is not financial advice. Past performance does not guarantee future results. Use at your own risk.
Note di rilascio
BTC Sats Stacking • CDC Action Zone Filter (v4)Overview
This study simulates fixed-amount DCA into the chart symbol and optionally filters buys using a CDC “Action Zone” built from two EMAs. Purchases occur on calendar boundaries you choose (Everyday / Weekly / Monthly) and can execute at bar close or the next bar’s open. Unspent contributions can be accumulated as cash stacking and fully deployed on the next eligible buy. The overlay shows EMA lines with a shaded zone, buy markers, and a compact table with key metrics. No orders are placed and no positions are managed; this is an educational simulation.
Core logic
CDC states
Fast EMA and Slow EMA are computed from the selected source.
“Green” when fast ≥ slow and price ≥ fast.
“Red” when fast < slow and price < fast.
Buy gate modes: All days, Green only, Red only.
Schedule
Calendar events (new day/week/month) define when a buy is allowed.
Optional date-range mask limits the backtest window.
Execution price
Execute at bar close, or at the next bar’s open.
Contributions & cash stacking
Base contribution accrues per day or per event.
If a scheduled buy is blocked by the CDC gate or falls outside the range, the contribution remains in a cash stack.
On the next eligible buy, the simulation spends the entire stack (subject to the Max Budget cap).
FX (optional)
Convert portfolio currency to the symbol’s quote using a conversion symbol or manual rate.
If disabled, contributions are assumed to be in the quote currency already.
Inputs (summary)
Symbol (blank = chart symbol)
Execution: at bar close or next bar open
Base contribution amount; Max Budget (0 = unlimited)
Frequency: Everyday / Every week / Every month
Contribution pace: Per day or Per event
Cash stacking: on/off
CDC filter: All days / Green only / Red only
EMA lengths and Source
FX: on/off, by symbol or manual rate
Backtest range: start and end timestamps
Display toggles: EMA lines/zone, buy markers, table
Outputs / metrics
BTC accumulated: total coins bought inside the selected date range
Invested (portfolio): total portfolio currency actually deployed (respects Max Budget)
Equity (portfolio): accumulated coins × mark price × FX
PnL% vs invested: (Equity / Invested − 1) × 100
CAGR: growth rate from the first buy inside the range
Average cost per BTC (quote): invested quote ÷ coins (shown when holdings > 0)
Notes
Weekly/monthly results can vary with calendar anchors; start dates matter.
Executing at close vs next open will change fills.
Cash stacking makes buy sizes lumpy when periods are skipped by the CDC gate.
This is an accumulate-only simulation: no sells, rebalancing, fees, or slippage modeled.
Change log (v4)
Added cash stacking (per-day or per-event contributions)
Added compact metrics table (Cash stack, Invested, Equity, PnL%, CAGR, BTC accumulated)
EMA zone and marker display refinements; stability and formatting fixes
Disclaimer
This study is for information and education only and is not financial advice. Simulation results do not guarantee future performance. Use at your own risk.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.