RSI Dip + EMA Trend Long DCA - IndicatorRSI Dip + EMA Trend Long DCA — Leveraged Indicator
🔷 What it does:
This is a signal-only indicator that mirrors a leveraged dip-buying DCA workflow on crypto perpetuals. It tracks one virtual long position at a time, opened only when an oversold dip and an uptrend confirmation align across two lower timeframes. The indicator manages up to four safety orders as price ladders lower, and exits via three independent paths: take profit with trailing, hard stop loss, or a forced close after a maximum holding period. Every event emits a webhook-ready JSON payload tailored for a DCA Bot configured for leveraged futures.
- Dual confirmation entry: RSI(12) crossing down 35 on 5m AND EMA(50) > EMA(100) on 15m.
- Soft-compounding safety ladder: 4 SOs at 1.05× margin progression, deviations 1.00%, 2.20%, 3.64%, 5.37%.
- Three-exit architecture: 1.0% Take Profit with 0.1% trailing, 9% hard Stop Loss, 3-day Max Hold timeout.
- Default leverage 25×, configurable from 1× upward.
- Honest virtual bookkeeping: total notional and qty updated per fill, avg entry / open PnL displayed live.
🔷 Who is it for:
- Active traders running a DCA Bot on leveraged crypto perpetuals who want a systematic dip-buying engine.
- Bot operators who want a chart-driven signal source with per-event JSON ready for a DCA Bot.
- Traders who want to monitor an evolving leveraged position — base entry, owned SO levels, deployed notional, open PnL, time-to-max-hold — directly on the chart.
- Operators comfortable with portfolio-level drawdowns in the 15–20% range in exchange for accelerated returns.
🔷 How does it work:
Entry RSI Filter (Oversold Dip): A 5-minute RSI(12) is sampled via request.security with lookahead disabled. The dip gate fires when RSI crosses down through 35 — momentum has rolled over into oversold.
EMA Trend Filter: A 15-minute EMA(50) and EMA(100) are sampled in parallel. The trend gate is satisfied only while Fast EMA > Slow EMA — broader trend is up. When the EMA cross flips, the dip signal alone cannot open a virtual position.
Entry: When both gates align at host-bar close, the indicator marks a virtual long entry, captures the base entry price, seeds the cost-basis ledger with base margin × leverage notional, and fires the entry webhook payload.
Safety Order Ladder: After base fill, the indicator monitors close price downward against the position. When close reaches base entry × (1 − cumulative deviation), the k-th SO is marked filled, cost-basis is updated, and the SO webhook payload is fired. No additional gating on the SO ladder — pure price.
Honest Virtual Bookkeeping: Total notional and qty are updated incrementally on every event, so the avg entry, deployed notional, and open PnL displayed in the status table reflect the actual broker-equivalent position state — no shortcut from base entry, no synthetic averaging.
Exit Priority: Three exits evaluated in order on each bar: (1) Stop Loss at 9% below average entry, (2) Maximum Hold timeout from base entry, (3) Take Profit at 1.0% above average entry with 0.1% trailing — once price reaches the TP target, the position closes only after a 0.1% retrace from the in-favor peak.
🔷 Why it's unique:
- Two-Layer Confirmation: RSI dip on 5m for timing, EMA stack on 15m for trend bias. The two filters operate on different scales — momentum exhaustion alone cannot fire a signal against a confirmed downtrend, and trend alignment alone cannot fire outside a tactical entry window.
- Three-Exit Architecture: Most DCA tools use one or two exit conditions. This indicator handles all three failure modes explicitly — hard tail-risk stop, stuck-trade timeout release, and momentum-trailing winner exit.
- Leverage-Aware Sizing: Margin and leverage are independent inputs. The virtual ledger tracks notional position, so the avg-entry line and open PnL reflect the leveraged broker state, not unleveraged cash-only math.
- Per-Event Webhook Ledger: Up to seven distinct events per cycle (entry + 4 SO fills + close + max-hold/SL), each with its own JSON alert payload. The indicator drives a DCA Bot end-to-end through a single TradingView alert.
🔷 Considerations Before Using the Indicator:
Market & Timeframe: Designed for liquid crypto perpetuals on 15m. Default thresholds are calibrated for XMRUSDT.P 15m. Different pairs may need EMA period and RSI threshold tuning.
Leverage Warning: The default 25× leverage is aggressive. The companion strategy's backtest at default settings produced 18.01% maximum drawdown — substantially above the 5–10% per-trade band, although that figure reflects portfolio-level accumulation across 779 trades, not single-trade risk. Lower the leverage input to dial down portfolio-level drawdown proportionally.
Cross Detection Granularity: Entries and SO 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.
No SO Condition: Safety orders fire on pure price ladder with no momentum gate — averaging continues unconditionally as price drops, until SL, MaxHold, or price reversal. Higher average-entry quality in shallow dips; greater unrealized exposure on sharp drops.
Maximum Hold Timeout: The 3-day forced close exists to release capital from stuck trades. The indicator dispatches a close webhook the moment the timeout fires — verify the receiving DCA Bot accepts unconditional close commands.
Funding Rates (Perpetuals): The indicator does not account for perpetual funding rates. Sustained negative funding improves live performance for this long strategy; sustained positive funding degrades it. Review the historical funding pattern before live deployment.
Backtesting Note: This is an indicator, not a strategy. There is no built-in P&L tester. For performance metrics over a 14-month sample (~779 closed trades, 74.07% win rate, 18.01% max drawdown, profit factor 1.313, +30.79% net return), use the companion strategy version on identical parameters.
🔷 How to Use It:
🔸 Add the indicator to a 15m chart on the leveraged perpetual pair you want to trade.
🔸 Review the entry filters (RSI on 5m, EMA stack on 15m), the 4-SO ladder, and the three exit conditions. Defaults are calibrated for XMRUSDT.P 15m at 25× leverage — recalibrate per asset and per risk tolerance before deploying.
🔸 Set leverage and base margin to match your exchange and account configuration. Lower leverage scales portfolio-level drawdown proportionally.
🔸 In the DCA Bot Webhook group, paste the Bot ID, Email Token, and Pair (QUOTE_BASE format, e.g., USDT_XMR).
🔸 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 all three close types — formatted for direct DCA Bot consumption.
🔷 INDICATOR SETTINGS
Base Order Margin (USDT): Margin per base trade. Notional = Margin × Leverage. Used for the virtual avg-entry / open-PnL computation.
Leverage (×): Exchange leverage. Default 25×.
Max Safety Orders: Maximum number of safety orders per cycle (default 4).
First SO Margin (USDT): USDT margin of the first safety order; subsequent SOs scale by the Size Multiplier.
Step to First SO (%): Distance from base entry at which SO1 becomes eligible.
Step Multiplier: Ladder factor that widens each subsequent deviation step.
Size Multiplier: Factor that grows each subsequent safety order's USDT margin.
Entry RSI Timeframe / Length / Level: Lower-timeframe RSI oversold-dip filter.
EMA Timeframe / Fast / Slow: Higher-timeframe trend confirmation filter.
Take Profit (%) / Trailing Deviation (%): TP target above avg entry and trailing buffer.
Stop Loss (%): Hard stop below avg entry.
Force Close After Max Hold / Max Hold (seconds): Timeout for forced market close.
DCA Bot Webhook: Bot ID, Email Token, and Pair fields injected into every alert payload.
Visualization: Toggle SO Ladder, Avg / TP / SL 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.
Indicador Pine Script®






















