Grid Hull Moving Average EA
- Uzmanlar
- Sürüm: 3.15
- Etkinleştirmeler: 5
Test it free before anything else: open Grid Hull Moving Average EA in the MetaTrader 5 Strategy Tester, switch on visual mode, and watch a fast line change direction, pass its guards, and only then start a grid.
THE MOMENT THE LINE TURNS, AND NOT A WOBBLE EARLIER.
Most moving averages make you choose between smooth and late or fast and jumpy. Alan Hull's average was designed to reduce that trade-off: it subtracts a slower weighted average from a doubled faster one, then smooths the result over the square root of the period. What you get is a line that hugs price and bends quickly. Grid Hull Moving Average EA does not wait for price to cross that line. It watches for the line itself to reverse, measures how strong the reversal is, and treats a qualified turn as the single visible reason to begin a grid cycle. After that, a full management engine keeps shrinking the oldest exposure through group closures and partial slices.
At a glance
• A BUY cycle can begin on a closed bar where the Hull line rises after falling or standing still, with the close above the line; a SELL cycle needs the mirror turn down. Closed bars only, so accepted signals do not repaint.
• The Hull line is calculated inside the EA from two MetaTrader 5 built-in Linear Weighted Moving Averages. No custom indicator file is needed.
• New in this product: the Hull Thrust Guard. A fast line wobbles, so the EA measures how tall the turn is on the signal bar in ATR and ignores turns too small to count.
• The default EMA 200 trend filter accepts a turn only on the same side as the slow trend. Our tests below show why it is on by default.
• The Turn Depth Guard skips a close that sits a hair from the line, and a close stretched far away from it on one violent candle.
• On the live chart the line is drawn in two colours, mint while rising and red while falling, and arrows mark each candle where a cycle was armed.
• Profits are banked by groups of the oldest and newest orders, and a heavy old order is retired in partial slices rather than waiting for a full return.
• No stop loss and no forced close-all. A reached limit refuses new levels while the existing book keeps being managed.
• Every limit is exposed as an input.
FIRST STEPS
Start on EURUSD H1 or XAUUSD D1 with the default 0.01 lot and the additive ladder. Set RunMode to Scan only for your first session: the panel shows each plan the EA would carry out and sends no orders, and one button moves it to Armed when you are ready. Repeat the Strategy Tester runs below on your own broker's data before going live, because spreads, swaps and commissions differ between brokers.
What our tests showed
Default settings, Strategy Tester, 1 minute OHLC model, 1:100 leverage, 2025.01.01 to 2026.09.30, one broker's demo data:
• EURUSD H1, $10,000 deposit: net result +881.01, maximal equity drawdown 3.36%, 312 trades, no stop-out and no margin refusals.
• EURUSD H1, $1,000,000 deposit: net result +881.01, no stop-out and no margin refusals.
• XAUUSD D1, $10,000 deposit: net result +16.33, maximal equity drawdown 0.02%, 6 trades, no stop-out and no margin refusals.
• XAUUSD D1, $1,000,000 deposit: net result +16.33, no stop-out and no margin refusals.
These are simulations of one past period, not a forecast, and the XAUUSD sample of 6 trades is far too small to prove anything. The warning matters more than the figures: during development, the same EURUSD H1 test at $10,000 with the trend filter off and looser guards ended in stop-out, losing most of the deposit. That is what a grid can do when its signal keeps opening against a trend, and it is why the defaults are stricter. Loosen them only after testing the change yourself.
Why the Hull line, and why its turn
With a period of 21, the EA reads a 10 bar and a 21 bar Linear Weighted Moving Average. Doubling the faster one and subtracting the slower one pushes the value ahead of ordinary lag. A final weighted average over 5 bars, the rounded square root of 21, removes most of the roughness this creates. The line is quick enough that a close crossing it says little, because price crosses a tight line all the time. A change in the line's direction says more, so that is the event this EA trades.
The improvement in this release
The Hull Thrust Guard is this EA's own addition. On each candidate turn the EA takes the step the line made on the signal bar, divides it by the ATR of that bar, and requires at least your minimum, so one setting can be used on currencies, gold and indices. A turn of a few points in a quiet session is skipped as a wobble. Set the minimum to 0 to switch it off. The panel shows the live thrust beside the live depth, each with OPEN or HOLD, so you can see why a turn did or did not qualify. Margin-level timeframe safety is included and is off by default.
One cycle, step by step
1. The read. On each new bar the EA rebuilds the Hull values from the two built-in averages. The forming candle is not used for signals.
2. The turn. A BUY is considered when the line rises on the signal bar after falling or standing still on the bar before; a SELL is the mirror.
3. The side rule. By default the close must be above the line for a BUY and below it for a SELL.
4. The Turn Depth Guard. The close must sit between your minimum and maximum distance from the line, measured in ATR.
5. The Hull Thrust Guard. The turn must be at least your minimum height in ATR.
6. The trend filter. By default a slow EMA must agree with the side. You can also fade it, or switch it off.
7. The rhythm. A quiet gap of bars between accepted signals stops a choppy session from starting cycle after cycle, and a signal stays valid for a few bars if a level cannot be placed at once.
8. The ladder. Levels are spaced by fixed points or by ATR, with a floor, an upper limit and an option to freeze the distance for the whole cycle. BUY and SELL grids can run side by side or in one direction only.
9. The harvest. The closer searches for groups of the oldest and newest orders and closes a group as soon as its combined result, after swap and commission, beats your target. When the oldest order is still too heavy, only a slice of it is closed, paid for with profit already available.
10. The safety checks. A reopen guard blocks any closure that would reopen the same level straight away. Every leg is checked against the deal history, failed legs go into a retry queue, and a plan is dropped if the book changes between the scan and the send.
11. The optional hedge cycle. Off by default. When switched on it holds a balanced pair on a symbol you choose and retires it in equal slices, funded by a small surcharge on closures the grid is already making.
The panel
The panel sits on the left of the chart and keeps the right side and the price scale clear. It shows the symbol and magic number, a status pill (ARMED, SCAN ONLY or PAUSED), grid mode, lot step, spacing, banked result, the book in lots with its net result, the closing plan for each side with its own close button, and the order list. The HMA PULSE row shows the period and live value of the line, whether price is above or below it, whether it is rising or falling and how many bars ago it last turned. The DEPTH GUARD row shows the live distance in ATR, the live thrust and the trend filter. Buttons switch Armed / Scan only, Pause / Resume, chart marks and slicing. The Hedge Vault card is docked directly under the main panel and follows it when you drag or minimise. The panel draws nothing in a non-visual backtest, so optimisation stays fast.
Protection you control
No stop loss and no forced close-all. A reached limit stops new levels; it never dumps the book at a bad moment.
Before each order the money check asks one plain question: is there enough free margin, with a safety buffer, for this order?
Limits on levels per grid, orders per side and lot per order keep the ladder bounded, and the lot ladder stops growing at the level limit. MinMarginLevelPercent and MaxAccountRiskPercent are off by default; consider setting them for your account.
On netting accounts the margin of the merged position is capped as a percentage of equity.
Optional margin-level timeframe safety moves the signal and the spacing to a higher timeframe when the margin level falls to your chosen levels, and moves back only after margin recovers past a cushion. Off by default.
Every copy isolates itself by symbol and magic numbers, so several charts never touch each other's orders or saved state.
Scan only mode shows every decision without sending any order.
Who it suits, and who it does not
It suits traders who want a clear reason behind every new cycle, who prefer many small closures to one distant target, and who will size the lot for their own account. It does not suit anyone who needs a stop loss on every order, a promised monthly figure, or a set-and-forget robot running large lots on a tiny balance.
Quick answers
Does it repaint? Accepted signals use closed bars only. Like any moving average, the value on the forming bar moves until that bar closes, and the EA does not trade on it by default.
Why so few trades on XAUUSD D1? The trend filter, guards and the 30 bar gap between signals are strict on a daily chart. Lower them for more cycles, and test the effect first.
Can I make the line faster or slower? Yes. A shorter period turns more often; a longer one turns less often. A smoother line makes smaller steps per bar, so lower the thrust minimum with it or signals can become very rare, even zero. Check the trade count in the tester.
Can I run it without the trend filter? Yes, set InpHMATrendFilter to 0, but read the test warning above first.
Every setting explained
Grid - how levels are opened
TradeMode - dual grid by default (BUY and SELL side by side), or one direction only.
GridSpacePoints - fixed distance between levels in points when ATR spacing is off (25).
GridSpaceMultiplier - 1.0 keeps levels evenly spaced; a higher value spreads deeper levels further apart.
MaxGridLevels - the most levels one grid may hold (1000).
UpDirectionIsBuy - decides which side an upward move belongs to.
EAMagicNumber - the ID written on this EA's grid orders (9754340).
GridOrderComment - the comment on each grid order (GHMA).
OneOrderPerBar - no more than one new level per bar.
Lot ladder
InitialLotSize - volume of the first level (0.01).
LotSizingMode - additive by default, or multiply.
LotMultiplier - in multiply mode, each level is the previous lot times this value (1.25).
LotAddStep - in additive mode, the volume added at each level (0.01; 0 means the starting lot).
MaxOrderVolume - the largest lot any single order may use (1.0).
UseAutoLot - scales the starting lot with the balance (off).
AutoLotBaseBalance - the balance that matches the starting lot (1000).
AutoLotAllowDecrease - lets auto lot go below the starting lot (off).
ATR spacing
GridSpacingMode - ATR by default, or fixed points.
ATRTimeframe - the timeframe volatility is measured on (current chart).
ATRPeriod - ATR length (14).
ATRSpacingFactor - spacing equals ATR times this value (1.0).
ATRBarShift - 1 uses the last closed bar.
ATRMinSpacingPts - the smallest allowed spacing in points (50; 0 means none).
ATRMaxSpacingPts - the largest allowed spacing in points (5000; 0 means none).
ATRFreezeOnStart - keeps one spacing for the whole cycle (off).
Profit target
DesiredProfitPerClosure - the base target in account currency (2.0).
ProfitMultiplier - scales the final target between 1.00 and 2.00.
ProfitTargetMode - scaled by default, so a bigger and deeper book must earn a bigger result.
ProfitVolumePower - how strongly closing volume lifts the target (1.0; 0 turns it off).
ProfitDepthBonus - extra target for each additional open level (0.10).
ProfitMaxMultiple - the cap on the scaled target as a multiple of the base (50).
ProfitMaxReachFraction - keeps the target within a fraction of one grid step so it stays reachable (0.50).
Fragment scanner
UseMultiLegScan - tests combinations of several orders before the simple pair (on).
MaxOldestLegs - the most oldest orders allowed in one closure (3).
MaxNewestLegs - the most newest orders allowed in one closure (6).
ScanPriority - how qualifying groups are ranked; most orders first by default.
NeverBankLessThanPair - a group must also beat the plain pair target (on).
RequireCloseVolumeExceedsTarget - the newest volume must outweigh the oldest volume (on).
MinCloseVolumeRatio - minimum ratio of closing volume to target volume (1.5).
Target slicing - partial closes
EnableTargetSlicing - closes a slice of the oldest order when the whole lot cannot be paid off yet (on).
FragProfitWeightPower - how profit is weighted per closing lot (1.5).
FragMinSlicePercent - the smallest slice as a percent of the target order (20).
FragAllowMultiCloser - lets several newest orders pool their profit to pay for one slice (on).
FragPreferFullClosure - a full closure wins over a slice whenever both qualify (on).
Reopen guard
ReopenGuard - blocks closures that would immediately reopen a level (step based).
ReopenGuardCushion - the safe distance as a fraction of one grid step (0.90).
Account protection
MinMarginLevelPercent - no new levels below this margin level percent (0 = off).
MaxAccountRiskPercent - no new levels above this floating loss as a percent of balance (0 = off).
NetMaxMarginPercent - on netting accounts, the largest margin of the net position as a percent of equity (5.0).
MaxTotalOrders - absolute cap on grid orders per side (1000).
Execution and verification
RunMode - Armed or Scan only; Scan only is the gentle first step.
CloseSequence - the order in which legs are sent; oldest first by default.
MaxSlippagePoints - maximum slippage (30 points).
MaxSpreadPoints - trading pauses above this spread (7500 points).
MinSecondsBetweenClosures - minimum pause between two closures on the same side (5 seconds).
CloseAttemptsPerLeg - send attempts before a leg moves to the retry queue (3).
VerifyTimeoutSeconds - how long a stuck leg keeps being checked (90 seconds).
DeferWhenMarketClosed - waits for the session instead of halting when the market is closed (on).
MarketClosedRetrySeconds - retry interval while the broker refuses orders (30 seconds).
AutoResumeAfterSeconds - clears a halt by itself after this many seconds (300; 0 waits for the panel button).
NoPartialRetryMinutes - tries partial closes again this many minutes after a broker refusal (15; 0 never).
AbortIfBookChanged - drops a plan if a leg changed between the scan and the send (on).
UseFullCommission - counts commission for both sides of a trade (on).
CommissionPerLot - fallback commission when history has none (0 reads it from history).
CloseOrderComment - the comment on closing deals.
Hedge cycle
EnableHedgeCycle - off by default.
HedgeSymbols - comma-separated list of hedge symbols; repeating one gives it more turns (XAGUSD).
HedgeSymbolRotation - how the next cycle's symbol is picked (per cycle).
HedgeMaxSymbolsInTester - limits rotation in the Strategy Tester only (2; 0 means no limit).
HedgeCycleLots - lots on each side of the balanced pair (0.01).
HedgeSliceLots - lots retired from each side per slice (0.01).
HedgeFragmentBonus - extra amount added on top of the slice cost (100).
HedgeBonusIsPercent - the bonus is a percent of the slice cost; false makes it a fixed amount (on).
HedgeMaxSurcharge - money cap on what one closure may be surcharged (0 = no cap).
HedgeMaxSurchargePercent - the most the hedge may raise any closure target, in percent (50).
HedgeMagicNumber - the hedge legs' ID; it must differ from the grid's (9754341).
HedgeReopenOnFinish - opens a fresh cycle when one finishes (on).
HedgeStartRequiresTrade - waits for the grid to open something before the first cycle (on).
HedgeIntegritySeconds - how often both legs are checked to be equal (5 seconds).
HedgeAutoRepair - repairs a lone leg automatically (on).
HedgeNakedAction - what to do with a lone leg; re-hedge by default.
HedgeMaxSpreadPoints - no hedge orders above this spread (0 = off).
HedgeSlippagePoints - maximum slippage on hedge orders (30 points).
HedgeAttemptsPerLeg - send attempts per hedge leg (3).
HedgeVerifyTimeout - how long a stuck hedge leg keeps being checked (90 seconds).
HedgeCommissionPerLot - fallback hedge commission (0 reads it from history).
HedgeOrderComment - the comment on hedge deals.
Weekly cash day
WeeklyCashDay - no new hedge cycle and no slice during your withdrawal window (off).
CashDayOfWeek - 0 Sunday, 1 Monday and so on (1).
CashCutoffHour - server hour after which no new slice is fired (21).
Panel and chart
ShowPanel - shows or hides the panel.
PanelX and PanelY - panel offsets from the chart edges (12 and 15).
PanelFontSize - base font size (9).
ShowArabic - adds an Arabic line under the English on the panel (on).
ShowChartMarks - draws plans and levels on the chart (on).
MaxTableRows - order rows shown per grid (13).
PanelCorner - the chart corner the panel is anchored to.
Entry trigger
EntryTriggerMode - the Hull strategy arms the first level by default.
SignalBarShift - 1 means the last closed bar.
SignalBarsDelay - bars that must pass between accepted signals (30; 0 accepts every signal).
SignalValidBars - a signal stays usable for this many bars (3).
SignalAllowBuy and SignalAllowSell - turn each direction on or off separately.
SignalReverse - inverts the direction (off).
Hull Moving Average - the signal
InpHMAPeriod - the Hull line length (21; 4 or more). It sets the two weighted averages and the final smoothing.
InpHMAPrice - the price the line is built on (close).
InpHMASideAgree - a BUY only when the close is above the line and a SELL only when it is below (on).
InpHMAThrustMinATR - Hull Thrust Guard: the smallest height of the turn on the signal bar, in ATR (0.10; 0 = off).
InpHMADepthMinATR - Turn Depth Guard: the smallest distance between the close and the line, in ATR (0.10; 0 = off).
InpHMADepthMaxATR - Turn Depth Guard: the largest accepted distance in ATR, so over-stretched spike bars are skipped (2.00; 0 = off).
InpHMAGuardATR - the ATR length both guards use (14).
InpHMATrendFilter - 1 trades with the EMA side (default), 2 trades against it as a fade, 0 is off.
InpHMATrendMAPeriod - the trend EMA length (200).
InpShowSignalArrows - arrows on the candles where a cycle was armed (on).
InpShowHMAOnChart - draws the two-colour Hull line over recent bars in the main chart window of the live chart (on).
Debug
DebugMode - detailed journal logging (off).
Margin timeframe safety
UseMarginTFSafety - off by default.
Level1MarginPct and Level1TF - at or below 6000 percent margin level, work on M15.
Level2MarginPct and Level2TF - at or below 5000 percent, work on H1.
MarginTFHysteresisPct - how far margin must recover above a level before stepping back (500).
Honest expectations
A grid carries real risk. It adds to positions while the market moves against them, there is no stop loss, and a long one-way move can hold the book open for a long time or, with too large a lot for the balance, lead to a stop-out and heavy loss. A qualified Hull turn can still fail straight away. Grid Hull Moving Average EA is careful about when a cycle begins and works steadily on each old order, but no result is promised. Pick a lot your account can carry through a bad run, test on your own broker first, and trade live only what you can afford to lose. It runs on any symbol and timeframe and needs no DLLs and no extra files.
If you try it, a short and honest review of how it behaved on your account, good or bad, helps other traders make their choice.
