OPEN-SOURCE SCRIPT

[3Commas] AMZN RSI Oversold Doubling DCA - Long Indicator

545
AMZN RSI Oversold Doubling DCA — Long Indicator

🔷 What it does:
This is a signal-only indicator that mirrors an AMZN dip-buying workflow with an aggressive doubling-martingale safety ladder. It tracks one virtual long position at a time, opened only when AMZN prints a deep oversold reading on 4-hour RSI. Five safety orders fire at fixed deviations from base entry (−2%, −5%, −9.5%, −16%, −25%) with sizes doubling on every rung. Exit is a fixed 3% Take Profit from average entry. The indicator computes running average entry, deployed capital, open PnL, and lifetime realized PnL — all derived from honest fill-by-fill bookkeeping. Every event emits a webhook-ready JSON alert payload for direct DCA Bot consumption.
- Selective oversold entry: 4h RSI < 28.
- Non-uniform fixed-deviation safety ladder: −2%, −5%, −9.5%, −16%, −25% from base entry.
- Doubling safety-order sizes: 1k / 2k / 4k / 8k / 16k USDT from a $500 base.
- Tight 3% Take Profit from the averaged-down entry — quick deal close once price stabilizes.
- Honest virtual bookkeeping: Open PnL and lifetime Total PnL displayed live on the chart.

🔷 Who is it for:
- Swing traders running a DCA Bot on AMZN who want to buy deep oversold dips.
- Bot operators who want a chart-driven signal source that emits per-event JSON ready for a DCA Bot.
- Traders who can absorb a doubling martingale up to ~31.5% of equity deployed per trade in exchange for a high deal-close rate.
- Operators tracking staged position management — entry, up to five staged safety fills, and a single exit — directly on the chart without the strategy-tester overhead.

🔷 How does it work:
Entry Filter: A 4-hour RSI(14) is sampled via request.security with lookahead disabled (no repaint). The entry gate fires when RSI is below 28 (deep oversold) at host-bar close, filtering out shallow dips.
Base Entry: When the gate is satisfied, the indicator marks a virtual long entry, captures the base entry price, and seeds the cost-basis ledger with the configured base order size (default 500 USDT).
Safety Order Ladder (Fixed Deviations, Doubling Sizes): After base fill, the indicator monitors price deviation against the position. Each safety order has its own fixed deviation from base entry — not a cumulative ladder. AO1 fills at close ≤ base × 0.98 (−2%); AO2 at −5%; AO3 at −9.5%; AO4 at −16%; AO5 at −25%. USDT sizes double from a 1,000 first AO: 1,000 / 2,000 / 4,000 / 8,000 / 16,000. Each fill updates the running cost-basis and dispatches its own webhook payload.
Honest Virtual Bookkeeping: Total cost and qty are updated incrementally on every event, so the avg entry, deployed capital, Open PnL, and Total PnL displayed in the status table reflect the actual broker-equivalent position state — no shortcut from base entry, no synthetic averaging.
Lifetime Total PnL: When the position closes for profit, the realized PnL from that cycle accumulates into a lifetime counter. The status table displays both Open PnL (current cycle, resets on exit) and Total PnL (lifetime, persists across the chart history) — giving traders a real-time read on cumulative performance without a backtest engine.
Exit: A fixed 3% Take Profit above the running average entry. When close hits the TP target, the close webhook fires, realized PnL accumulates, and the virtual position resets.

🔷 Why it's unique:
- Selective Oversold Entry: The deal opens only on a deep 4h RSI < 28 print, so capital is committed at genuinely stretched conditions rather than on every dip.
- Non-Uniform Fixed-Deviation Ladder: Most published DCA tools use formula-based ladders (step × multiplier). This one exposes each AO deviation as a direct input, allowing an asymmetric ladder (2% / 5% / 9.5% / 16% / 25%) where deeper safety orders trigger only on serious adverse moves and the lowest rung sits a full 25% below base.
- Doubling Martingale: 1 / 2 / 4 / 8 / 16 / 32 size progression scales position capital exponentially if the position runs adverse, but is hard-bounded by the 5-rung ladder.
- Lifetime PnL Tracking: Open PnL and Total PnL are displayed live on the chart — Open resets per cycle, Total persists across the entire chart history. The indicator gives strategy-tester-equivalent insight without running a backtest.
- Per-Event Webhook Ledger: Up to seven discrete events per cycle (entry + 5 AO fills + TP), each with its own JSON alert payload. One TradingView alert with "Any alert() function call" drives a DCA Bot end-to-end.

🔷 Considerations Before Using the Indicator:
Sample Size: The companion strategy's backtest produced 22 closed trades — below the ≥100 floor typically used for statistical confidence. The 90.91% win rate and high profit factor reflect favorable conditions over the test window and the averaging mechanic, not a deterministic edge. Treat them as indicative of how the ladder behaves, not a forward-performance guarantee.
Aggressive Capital Deployment: If all five safety orders fill, total deployed capital reaches 31,500 USDT = ~31.5% of the default reference equity. The doubling martingale amplifies both upside on recovery and risk if the lower bound breaks. Match the indicator's per-AO allocation to your bot's configuration to keep the avg-entry display honest.
No Stop Loss: There is no exit signal on adverse moves below AO5 (−25% from base). If price keeps falling, the virtual position holds unhedged until either price recovers to the 3% TP target or the user intervenes. Risk is structurally capped on the bot side by the bounded position ladder; if a hard exchange-side stop is required, configure it on the bot directly.
Martingale Tail Risk: A doubling ladder that bottoms out at −25% is built for mean-reverting moves. A sustained directional collapse below −25% leaves the full virtual position open with no further averaging available — the single largest risk in any martingale DCA. Choose assets and regimes where deep-but-recoverable dips are the norm.
Cross Detection Granularity: Entries and AO fills are evaluated on bar close. A bar that spikes through a level and returns within the same bar may be missed by design — this matches realistic polling behavior and avoids over-signaling on intra-bar wicks.
Live vs Historical State: The virtual position state is rebuilt from chart history each time the indicator is recompiled. If the indicator is added mid-deployment or the live bot diverges from the signal stream (manual interventions, partial fills), the indicator state may not match the live bot. Toggle the indicator off and on to reset.
Backtesting Note: This is an indicator, not a strategy. There is no built-in P&L tester — but the live Total PnL counter in the status table gives a running approximation. For full metrics over a ~9.4-month sample (22 closed trades, 90.91% win rate, 0.20% max drawdown, profit factor 21.997, +0.81% net return), use the companion strategy version on identical parameters.

🔷 How to Use It:
🔸 Add the indicator to an AMZN / USDT chart on 4h.
🔸 Review the RSI entry level, the five AO deviations and sizes, and the Take Profit percentage. Defaults are calibrated for AMZN 4h — recalibrate when the asset's volatility regime shifts.
🔸 Set Base Order Size and AO sizes to match your bot's configuration (the indicator's avg-entry display becomes meaningful when virtual sizing matches real sizing).
🔸 In the DCA Bot Webhook group, paste the Bot ID, Email Token, and Pair (QUOTE_BASE format, e.g., USDT_AMZN).
🔸 Create an alert on the indicator with "Any alert() function call". Paste the DCA Bot's webhook URL into the alert's Webhook field. The indicator will emit JSON payloads for entry, each safety order, and TP exit — formatted for direct DCA Bot consumption.

🔷 INDICATOR SETTINGS
Base Order Size (USDT): Virtual order size for the avg-entry / open-PnL computation.
AO1–AO5 Deviation (%): Fixed distance from base entry where each safety order becomes eligible. Non-uniform by design, reaching −25% at AO5.
AO1–AO5 Size (USDT): Virtual USDT amount of each safety order. Doubles at each rung by default.
RSI Timeframe / Length / Less Than: 4h RSI filter for the base entry.
Take Profit (%): Fixed distance above the running average entry where the virtual long closes.
Active Window: Optional date filter — when ON, the indicator only fires signals between From and To dates.
DCA Bot Webhook: Bot ID, Email Token, and Pair fields injected into every alert payload.
Visualization: Toggle AO Ladder, Avg / TP plot lines, fill labels, signal triangles, status table.
Brand Watermark: Configurable text, position, size, and transparency.

👨🏻‍💻💭 We hope this tool helps enhance your trading. Your feedback is invaluable, so feel free to share any suggestions for improvements or new features you'd like to see implemented.

__
The information and publications within the 3Commas TradingView account are not meant to be and do not constitute financial, investment, trading, or other types of advice or recommendations supplied or endorsed by 3Commas and any of the parties acting on behalf of 3Commas, including its employees, contractors, ambassadors, etc.

Pernyataan Penyangkalan

Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.