Amazing Ver8.0 MT5 Source Code
Pinned Quarterly
Featured
MT5v8.0
Two-way pending orders + hedge close + counter-trend protection + trend-side protection + dual Magic numbers + normalized point scale — the MT4 logic ported 1:1 to MT5, built for hedging accounts.
Details & Usage Instructions
AmazingMT5 Ver8.0 is an MT5 automated EA built on a two-way hedge grid, ported 1:1 from the original MT4 strategy logic.
The EA places BUY_STOP above price and SELL_STOP below. Whichever side price breaks fills first, and after the fill it keeps placing counter-trend orders at the configured spacing, forming a two-way grid. When long and short positions are open at the same time they hedge each other; once the combined P/L reaches the target amount, everything is closed and the EA waits for the next round.
Built-in multi-layer mechanisms: counter-trend protection, trend-side protection, basket close, single-side take-profit, monetary stop-loss, time filter and point-scale normalization.
Key highlight: two separate Magic numbers distinguish normal orders from trend-side orders. Since MT5 has no OrderCloseBy(), hedging is closed with two market legs — the strategy logic is fully equivalent to the original MT4 version.
Core Features
1. Two-way pending-order grid (core)
BUY_STOP above price, SELL_STOP below
Whichever side price breaks fills first; after the fill the next order is placed at the configured spacing
Long and short open simultaneously → positions hedge each other
Combined P/L reaches the set amount → close everything and wait for the next round
First-order distance, first/second averaging spacing and pending-order trailing points are all configurable independently
2. Dual Magic numbers: normal orders vs trend-side orders
MAGIC_NN (normal orders): 2024060501
MAGIC_SS (trend-side orders): 2024060502
The MT4 version separated them by order comment "SS"/"NN"; comments are unreliable on MT5, so two independent Magic numbers are used instead
Statistics, closing and protection are all grouped by Magic — more robust logic
3. Counter-trend protection
When one side's floating loss grows too large, automatically close the most profitable 1 order and the 2 worst orders on that side
Reduces single-side exposure and keeps a one-way market from dragging the account down
Can be switched off independently (on by default)
4. Trend-side protection
When long and short lots are fully locked against each other, automatically place trend-side orders (SS orders)
Wait for the breakout, then close the net
If SS orders exist and the combined P/L reaches target → close everything
Can be switched off independently (off by default)
5. Lots and averaging
Initial lot: 0.01 by default
Lot multiplier: 1.3 by default (exponential by level)
Lot increment: 0 by default (optional linear add-on)
Max lot: 10.0 by default
Max orders: 50 by default
6. Averaging settings
First-order distance: 30 points by default
First/second minimum distance: 60 / 60 points by default
First/second averaging spacing: 100 / 100 points by default
Pending-order trailing points: 5 points by default (pending orders follow price)
Floating loss that enables the second parameter set: 0 by default (disabled)
Single-side floating loss above which averaging stops: 100000 by default
7. Closing settings
Basket close amount: 0.5 by default (combined long + short P/L hits target → close all)
Single-side close amount: 2.0 by default (that side's profit hits target → close that side)
Single-side close amount accumulation switch: on by default (threshold scales with order count)
Stop-loss amount: 0 by default (disabled)
Stop trading after close: off by default
Seconds before a new round after basket close: 0 by default (immediately)
8. Entry modes
A Time-zone mode: per chart period — only one entry per new bar
B Time-interval mode: entry every N seconds (30 s by default)
C No-delay mode: entries allowed on every tick (default)
9. Time filter
EA trading session: 00:00-24:00 by default (all day)
Price-limit session: 00:00-24:00 by default (all day)
Price limit lines apply only inside the limit session (no longs above a price, no shorts below a price)
10. Point-scale normalization
Quote digits can differ between MT4 and MT5 (e.g. gold is 2 digits on MT4 and 3 on MT5)
InpPointScale offers auto-detect / x1 / x10 / x100
Check the P value printed on the panel the first time you run it to confirm the point scale
11. Chart panel
Top-right: balance, equity, free margin, long/short positions, total P/L, spread, leverage
Top-left: Close Long / Close Short / Close All buttons
Top-left: halt notice + status icon (Wingdings)
Chart auto-styled: black background, red up / green down, dark grey grid
12. Diagnostic heartbeat
Every 20 seconds it prints why it is blocked (algo trading off, insufficient leverage, spread too wide, outside session, cooling down, etc.)
Halt reasons show right on the chart — no need to dig through logs
Suitable Market Conditions
Suited to ranging markets with pullbacks and two-way movement.
Not suited to extreme one-way trends, markets without pullbacks, or frequent gaps.
Risk Notice
This EA is a two-way grid averaging strategy: it keeps adding positions while price runs one way, so drawdown risk is significant.
MT5 has no OrderCloseBy(); hedging closes with two market legs, so each long/short pair pays one extra spread — an inherent MT5 limitation.
Set lots, multiplier, spacing, max orders and stop-loss amount sensibly.
Test on demo for at least 30 days first. No profit is guaranteed; investing carries risk and you are responsible for your own P/L.
The EA places BUY_STOP above price and SELL_STOP below. Whichever side price breaks fills first, and after the fill it keeps placing counter-trend orders at the configured spacing, forming a two-way grid. When long and short positions are open at the same time they hedge each other; once the combined P/L reaches the target amount, everything is closed and the EA waits for the next round.
Built-in multi-layer mechanisms: counter-trend protection, trend-side protection, basket close, single-side take-profit, monetary stop-loss, time filter and point-scale normalization.
Key highlight: two separate Magic numbers distinguish normal orders from trend-side orders. Since MT5 has no OrderCloseBy(), hedging is closed with two market legs — the strategy logic is fully equivalent to the original MT4 version.
Core Features
1. Two-way pending-order grid (core)
BUY_STOP above price, SELL_STOP below
Whichever side price breaks fills first; after the fill the next order is placed at the configured spacing
Long and short open simultaneously → positions hedge each other
Combined P/L reaches the set amount → close everything and wait for the next round
First-order distance, first/second averaging spacing and pending-order trailing points are all configurable independently
2. Dual Magic numbers: normal orders vs trend-side orders
MAGIC_NN (normal orders): 2024060501
MAGIC_SS (trend-side orders): 2024060502
The MT4 version separated them by order comment "SS"/"NN"; comments are unreliable on MT5, so two independent Magic numbers are used instead
Statistics, closing and protection are all grouped by Magic — more robust logic
3. Counter-trend protection
When one side's floating loss grows too large, automatically close the most profitable 1 order and the 2 worst orders on that side
Reduces single-side exposure and keeps a one-way market from dragging the account down
Can be switched off independently (on by default)
4. Trend-side protection
When long and short lots are fully locked against each other, automatically place trend-side orders (SS orders)
Wait for the breakout, then close the net
If SS orders exist and the combined P/L reaches target → close everything
Can be switched off independently (off by default)
5. Lots and averaging
Initial lot: 0.01 by default
Lot multiplier: 1.3 by default (exponential by level)
Lot increment: 0 by default (optional linear add-on)
Max lot: 10.0 by default
Max orders: 50 by default
6. Averaging settings
First-order distance: 30 points by default
First/second minimum distance: 60 / 60 points by default
First/second averaging spacing: 100 / 100 points by default
Pending-order trailing points: 5 points by default (pending orders follow price)
Floating loss that enables the second parameter set: 0 by default (disabled)
Single-side floating loss above which averaging stops: 100000 by default
7. Closing settings
Basket close amount: 0.5 by default (combined long + short P/L hits target → close all)
Single-side close amount: 2.0 by default (that side's profit hits target → close that side)
Single-side close amount accumulation switch: on by default (threshold scales with order count)
Stop-loss amount: 0 by default (disabled)
Stop trading after close: off by default
Seconds before a new round after basket close: 0 by default (immediately)
8. Entry modes
A Time-zone mode: per chart period — only one entry per new bar
B Time-interval mode: entry every N seconds (30 s by default)
C No-delay mode: entries allowed on every tick (default)
9. Time filter
EA trading session: 00:00-24:00 by default (all day)
Price-limit session: 00:00-24:00 by default (all day)
Price limit lines apply only inside the limit session (no longs above a price, no shorts below a price)
10. Point-scale normalization
Quote digits can differ between MT4 and MT5 (e.g. gold is 2 digits on MT4 and 3 on MT5)
InpPointScale offers auto-detect / x1 / x10 / x100
Check the P value printed on the panel the first time you run it to confirm the point scale
11. Chart panel
Top-right: balance, equity, free margin, long/short positions, total P/L, spread, leverage
Top-left: Close Long / Close Short / Close All buttons
Top-left: halt notice + status icon (Wingdings)
Chart auto-styled: black background, red up / green down, dark grey grid
12. Diagnostic heartbeat
Every 20 seconds it prints why it is blocked (algo trading off, insufficient leverage, spread too wide, outside session, cooling down, etc.)
Halt reasons show right on the chart — no need to dig through logs
Suitable Market Conditions
Suited to ranging markets with pullbacks and two-way movement.
Not suited to extreme one-way trends, markets without pullbacks, or frequent gaps.
Risk Notice
This EA is a two-way grid averaging strategy: it keeps adding positions while price runs one way, so drawdown risk is significant.
MT5 has no OrderCloseBy(); hedging closes with two market legs, so each long/short pair pays one extra spread — an inherent MT5 limitation.
Set lots, multiplier, spacing, max orders and stop-loss amount sensibly.
Test on demo for at least 30 days first. No profit is guaranteed; investing carries risk and you are responsible for your own P/L.

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.