Dip and Rally Market Structure
- Indicatori
-
Koji Saito
nice to meet you!
Trader focused on developing indicators built on market structure and price action analysis logic.
Designed with zero repainting, strict risk management, and a focus on reproducibility. - Versione: 1.0
- Attivazioni: 10
Dip and Rally Market Structure is a dual-timeframe Dow Theory market structure indicator engineered for discretionary traders and EA developers who require clarity without chart clutter.
Core Highlights: Dual-Timeframe MTF (Higher & Lower TF) | Strict Closed-Bar Non-Repainting | Tester-Safe Pseudo-MTF | Interactive Panel & Clean Mode | 8 EA-Ready Buffers ( iCustom )
Instead of crowding your chart with overlapping zones, it focuses cleanly on confirmed swing structure: automatic Dip (Protected Low) and Rally (Protected High) levels, BOS (Break of Structure), and CHoCH (Change of Character).
Key Features
- Dual-Timeframe Market Structure Engine (Full-Range MTF): Run two independent structure engines simultaneously (TF1 + TF2), such as Higher Timeframe trend structure + Current Timeframe execution structure. Also supports Lower Timeframe monitoring on higher timeframe charts (for example, monitoring M5/M15 structure shifts and alerts while viewing a clean H1/H4 chart).
- Non-Repainting & Tester-Safe Pseudo-MTF: All swing points, Protected Levels, BOS, and CHoCH signals are computed from confirmed closed bars. Once plotted, historical signals do not shift or disappear. Built-in Pseudo-MTF reconstruction builds higher-timeframe OHLC and ATR14 series sequentially from chart bars in the Strategy Tester to prevent future-bar look-ahead leakage. Feel free to verify with the free demo in the Strategy Tester.
- Clear Market Structure Visualization:
- BOS (Break of Structure): Dashed structural break lines with timeframe labels (e.g., "H1 BOS").
- CHoCH (Change of Character): Highlighted solid lines marking structural trend reversals (e.g., "H1 CHoCH").
- Active Protected Low / High Extension: Right-extended active defense level with live price label.
- Automatic TF1 / TF2 Vertical Label Separation: TF1 labels sit above lines and TF2 labels below lines so dual-timeframe labels remain readable even at matching prices.
- Flexible Structure & False-Break Controls: Switch between Candle Close confirmation and Candle Wick (High/Low) breakout detection. Choose Instant Flip (continuous directional bias) or Trendless / Neutral Zone (waits in neutral state until clear opposite structural confirmation), plus Swing Extension Guard & Break Filter (ATR %) to reduce premature flips from shallow wick spikes.
- Clean Mode & High-Speed Viewport Rendering: Historical structure is stored in memory while only objects overlapping your current chart view are rendered and pooled, enabling smooth scrolling through up to 30,000 bars. Toggle Clean Mode in one click to show only the most recent waves, breaks, and active Protected Low / High level.
- Interactive Dark-Card Control Panel: Switch TF1 / TF2 tabs, change timeframes in one click, and toggle ZigZag, Dip/Rally, BOS/CHoCH, or Clean Mode instantly. Includes real-time status badges ( TF1: BULL/BEAR/WAIT , TF2 , and ALIGNED / MIXED / SINGLE ), smooth header drag, collapse/expand, and automatic state preservation across timeframe switches.
- Granular Alert System: Independent toggles for CHoCH (Reversal), BOS (Continuation), and Dip/Rally Line Touch (with optional ATR14 tolerance). Supports Popup Alerts, Mobile Push Notifications, and Email alerts (automatically muted during Strategy Tester runs).
- EA-Ready Architecture (8 Output Buffers & Automatic iCustom Mode): 29 streamlined input parameters with all 9 core calculation settings grouped at the top for concise iCustom calls. Automatically detects headless iCustom execution and disables chart objects, panel UI, global variables, and alerts so EA calls never interfere with your live chart setup.
How to Test in Strategy Tester
- Download the free demo and attach it in MetaTrader 4 Strategy Tester (Visual Mode recommended).
- Switch timeframes or toggle ZigZag / Dip-Rally / BOS-CH / Clean Mode directly on the floating panel.
- Observe Higher Timeframe structure updating bar-by-bar without look-ahead repainting.
Input Parameters (29 Total)
Core Calculation Inputs (Top 9 for Easy iCustom Integration)
- Maximum Bars to Calculate (default: 30000 ) — History depth for calculation.
- Break Detection Mode (default: Candle Close ) — Candle Close or Candle Wick (High/Low).
- Post-Break Structure Mode (default: Instant Flip ) — Instant Flip or Trendless / Neutral Zone.
- Break Filter (ATR %) (default: 0 ) — Shared ATR14 percentage filter applied to structure break thresholds (0 = disabled).
- [TF1] Timeframe (default: Current ) — First engine timeframe (Current or M1 to MN1).
- [TF1] ZigZag Period (default: 12 ) — Swing detection period for TF1.
- [TF2] Enable Second Timeframe (default: false ) — Enable/disable the second engine.
- [TF2] Timeframe (default: Current ) — Second engine timeframe (Current or M1 to MN1).
- [TF2] ZigZag Period (default: 12 ) — Swing detection period for TF2.
Display & Color Settings
- 10. Clean Mode (Recent Structure Only) (default: false ) — Initial Clean Mode state.
- 11. Show Control Panel (default: true ) — Show or hide the interactive chart panel.
- 12–14. [TF1] Colors — Dip: Aqua / Rally: Magenta / ZigZag: Gray .
- 15–17. [TF2] Colors — Dip: Blue / Rally: Red / ZigZag: Gray .
- 18–21. BOS / CHoCH Colors — Bullish BOS: MediumSpringGreen / Bearish BOS: Tomato / Bullish CHoCH: Aqua / Bearish CHoCH: Magenta .
Alert & Instance Settings
- 22–24. Event Toggles — Alert on CHoCH ( true ), BOS ( true ), Dip/Rally Line Touch ( true ).
- 25–27. Delivery Channels — Popup Alert ( false ), Push Notification ( false ), Email Notification ( false ).
- 28. Touch Tolerance (ATR14 Multiplier) (default: 0.0 ).
- 29. Instance ID (0-9) (default: 0 ) — Set unique IDs (0-9) when attaching multiple instances to the same chart.
EA / iCustom Integration Guide (8 Buffers)
- Buffer 0: Dip [TF1] — Active Protected Low price (Empty = EMPTY_VALUE )
- Buffer 1: Rally [TF1] — Active Protected High price (Empty = EMPTY_VALUE )
- Buffer 2: Dip [TF2] — Active Protected Low price (Empty = EMPTY_VALUE )
- Buffer 3: Rally [TF2] — Active Protected High price (Empty = EMPTY_VALUE )
- Buffer 4: Trend [TF1] — 1.0 = Bullish, -1.0 = Bearish, 0.0 = Neutral/None
- Buffer 5: Trend [TF2] — 1.0 = Bullish, -1.0 = Bearish, 0.0 = Neutral/None
- Buffer 6: Signal [TF1] — 1.0 = Bullish BOS, -1.0 = Bearish BOS, 2.0 = Bullish CHoCH, -2.0 = Bearish CHoCH, 0.0 = None
- Buffer 7: Signal [TF2] — 1.0 = Bullish BOS, -1.0 = Bearish BOS, 2.0 = Bullish CHoCH, -2.0 = Bearish CHoCH, 0.0 = None
Minimal MQL4 iCustom Example (using the top 9 calculation inputs):
// Read closed bar (shift = 1) from MQL5 Market downloaded indicator path string indName = "Market\\Dip and Rally Market Structure"; double trendTF1 = iCustom(_Symbol, PERIOD_CURRENT, indName, 5000, // MaxBars 0, // BreakMode: 0=Close, 1=Wick 0, // StructureMode: 0=InstantFlip, 1=Trendless 0, // BreakFilterAtrPct 0, // TF1: 0=Current, 60=H1, 240=H4... 12, // ZigPeriod1 true, // UseTF2 240, // TF2 (e.g., H4) 12, // ZigPeriod2 4, // Buffer 4 = Trend [TF1] 1); // Shift = 1 (closed bar) double signalTF1 = iCustom(_Symbol, PERIOD_CURRENT, indName, 5000, 0, 0, 0, 0, 12, true, 240, 12, 6, 1); // Buffer 6 = Signal [TF1]
Note: Lower timeframes (TF < Chart Period) are supported for alerts and visual structure, while ZigZag drawing is intentionally skipped on lower timeframes to keep the chart legible.
FAQ
Q: Does this indicator repaint?
A: No. ZigZag pivots and structural breaks (BOS / CHoCH) are confirmed only on closed bars. In Strategy Tester higher-timeframe mode, higher-timeframe bars are reconstructed sequentially from chart bars to avoid future-bar leakage.
Q: Why does ZigZag show "ZG: N/A" when selecting a timeframe lower than the chart?
A: Lower timeframe ZigZag segments cannot be drawn cleanly inside a higher-timeframe candle, so ZigZag is disabled while Dip/Rally structure, BOS/CHoCH, trend badges, and alerts remain fully active.
Q: Will my panel position and settings reset when I switch chart timeframes?
A: No. Your panel position, collapsed state, active tab, TF1/TF2 settings, and Clean Mode are preserved across chart timeframe switches. Modifying indicator parameters or removing the indicator restores default settings.
Q: Can I attach more than one instance to the same chart?
A: Yes. Assign a different Instance ID (0-9) for each instance on the same chart so panel objects and states remain independent.
