GoldWheel Quant Martingale MT5 Source Code
Pinned Quarterly
In-house
MT5v1.2
Three-consecutive-price entries + martingale averaging + MT5 asynchronous batch fast close + basket breakeven + money trailing take-profit + multi-layer risk control + fixed avoidance + Beijing-time sessions + deep-sea blue panel. Suits ranging and pullback markets.
Details & Usage Instructions

1. Three-Consecutive-Price Entry Signal (core)
Samples the Bid price once every Sampling Interval seconds (default 2 s).
Three consecutive samples: P1< P2 < P3 → open long; P1 >P2 > P3 → open short.
Optional MA filter and price-gap filter; they apply only to the first entry and do not block martingale averaging.
Optional spread filter (enabled by default).
Sampling uses the Bid price, consistent with the final MT4 version.
2. Martingale Averaging
Averaging trigger: price moves against the position by Martingale Spacing Points (default 100 points).
Two lot modes:
Multiplier mode: previous lot × martingale multiplier.
Manual mode: takes lots one by one from a comma-separated lot list.
Anti-step protection: when a lot is too small and gets rounded back down by the step, one minimum lot step is added automatically so the multiplier still takes effect.
Max averaging count defaults to 30.
Optional "average only while the basket is losing".
Minimum averaging interval in seconds is adjustable.
3. MT5 Asynchronous Batch Fast Close (standout feature)
All strategy close-out conditions use fast close by default.
Uses OrderSendAsync for batch asynchronous submission, approaching MT5 one-click close speed.
Close priority: profitable orders first, then losing orders.
Retry count, wait milliseconds, and slippage multiplier are all adjustable.
Three close scopes:
EA fast close: closes only this EA's magic number.
Money-management close: used by automatic money-based TP/SL and avoidance force-close.
Account close-all: closes every position and pending order in the account.
Optional extension: also manages manual orders on the current symbol and orders under other magic numbers.
4. Basket Breakeven + Ratio Trailing
Activates once profit reaches Breakeven Trigger Points (default 150 points).
Locks in Breakeven Safe Profit Points (default 80 points) as a floor.
Ratio trailing: as profit keeps growing, it locks extra profit by the ratio factor (default 1.0).
It only moves in the favorable direction and never gives ground.
5. Money Trailing Take-Profit
Activates once the basket's floating profit reaches Money Trailing TP Start Amount (default $6).
Records the peak profit.
Closes all when profit retraces from the peak by Money Trailing TP Protect Drawdown (default $2).
6. Floating-Loss Hard Stop
Closes all when the basket's floating loss reaches Total Max Loss Amount (default -$1000).
After triggering, it enters cooldown (default 60 minutes) during which new entries and martingale are blocked.
7. Multi-Layer Account Risk Control
Daily loss-streak limit: stops opening new positions once the day's consecutive losing rounds reach the threshold (default 3).
Account drawdown circuit breaker: once drawdown from the equity high reaches the threshold (default $100), it trips, closes everything and locks trading.
Breaker reset button: one click resets the breaker lock and loss cooldown.
8. Fixed Avoidance Filter (Beijing Time)
Weekday filter: separate switches for Monday through Sunday.
Friday all-day block (optional).
Friday cutoff block (optional; stops after a specified time).
Major-news avoidance: blocks new positions within a specified time window.
Fed avoidance: blocks new positions within a specified time window.
Optional forced close during the avoidance window.
9. Beijing-Time Trading Sessions
Auto-detects Beijing time (GMT+8) or lets you set the time offset manually.
Three session groups can be enabled independently.
Allow an existing basket to keep averaging to completion outside the session (optional).
N minutes before session end, block new first entries in advance when there is no position.
10. Chart Tools
Cost-price line: blue for longs / yellow for shorts, showing the average cost.
Actual redemption-price line: light blue for longs / gold for shorts, back-calculating the theoretical redemption price from current floating profit.
Brand horse bitmap: disabled (to avoid bitmap loading failures).
Deep-sea blue panel: multi-button toggles, live status, P/L statistics, order details.
Deep-Sea Blue Panel
Top: 金轮量化 Goldlung.com + status badges
Row 1 buttons: Both / Long Only / Short Only / Pause
Row 2 buttons: MA Filter / Price-Gap Filter / Spread Filter / Time Filter
Row 3 buttons: Martingale On/Off / Clear P-L / EA Fast Close / Account Close-All
Row 4 buttons: Breaker On/Off / Breaker Reset
Signal Monitor
Current signal, direction, spread, Beijing time, trading status
MA filter status, price-gap filter status, MA value
Fixed avoidance status
Position & Risk Control
Position direction, order count, total lots
Average cost, actual redemption price, averaging layers
Position P/L, EA P/L since reset, account equity change
Stats start point, average P/L, losing rounds
Equity high, current equity, drawdown breaker status
Total cooldown remaining, hard-stop amount
Stop-Loss & Martingale Averaging
Money hard stop, fixed TP/SL status
Fixed SL / TP points
Breakeven status, trigger points, locked points
Ratio trailing status, factor
Money trailing TP status, MT5 batch mode
Martingale status, mode, averaging layers
Multiplier, spacing points
Next lot, next averaging price
Latest order, latest SL / TP
Close-scope hint
The panel can be collapsed / expanded.
Suitable Market Conditions
Suits markets alternating between range and trend with pullbacks.
Not suited to extreme one-way moves, markets without pullbacks, or frequent gaps.

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.