RichMartin Hedge MT5 Source Code

RichMartin Hedge MT5 Source Code

Pinned Annual In-house MT5

A two-way martingale grid MT5 EA with virtual pending-order tracking, multi-level TP/SL, tail-offset deduction and a UI panel.

Views 850 Downloads 163 File 208.3 KB Updated 2026-09-25

Details & Usage Instructions

Custom-built for a client at 30k — params need your own tuning.

Core Strategy
1. Two-way independent martingale grid
Long and short use independent magic numbers (base +1000 / +2000), operating independently.
First order can open instantly or wait as a virtual pending order.
Averaging by fixed spacing or a custom interval sequence, up to 135 orders.
Three lot modes: multiplier, fixed sequence, fixed lot.

2. Virtual Pending-order Tracking
Does not send real pending orders to the server; tracks price locally.
Order price moves with the current price, with a trailing distance and step.
When price breaks the trigger line, opens at market automatically.
Chart shows the tracking line, virtual TP line and virtual SL line.

3. Signal Filter (optional)
No-signal mode: pure grid.
Bollinger signal: buy on lower band, sell on upper band.
RSI signal: buy on oversold, sell on overbought.
MACD signal: golden cross above zero-line buy, dead cross below sell.
Combinable, or fully off.

4. Multi-level TP/SL
Average TP: by direction average + fixed points, whole basket.
Virtual trailing stop: based on average, starts after profit target; close all on pullback.
Dynamic hard stop: reverse-derive stop points from a fixed loss amount, applied to all orders.
Total TP / total loss: force-close all by total amount.
Account drawdown protection: close all when equity drawdown hits a %.

5. Tail-order Offset (profit offsets loss)
After one-side order count passes a threshold, use the latest tail profitable order's profit to offset the earliest head loss order.
Closed tail-profit orders' lots are stored in a recovery cache and preferentially refilled on later averaging.
Head-loss orders, once closed, do not enter the recovery cache — optimizing grid structure.
Profit coverage ratio configurable; 100% means trigger at breakeven.

6. ATR Volatility Filter
When fast/slow ATR ratio exceeds threshold, pause averaging.
Avoids the grid being quickly penetrated in high volatility.

7. High-layer Fixed Lot
From layer N onward, each order uses a fixed lot to prevent martingale lot explosion.
Default fixed 0.08 lots from layer 71.

8. Risk Lot Auto-calc
Reverse-derive first-order lot from a fixed loss amount and preset stop points.
For traders who want strict per-trade risk control.

8544753b-9767-430c-9873-8cfeb33ba043.png

84B53EE06B03C2942D69E0C18754FC44 (1).jpg

Risk Warning:Resources on this site are for learning, research and technical exchange only, and do not constitute any investment advice. Before running any EA on any account, please do thorough forward-testing on a demo account first; no strategy can guarantee profits.