Grid MFI Oscillator EA
- Uzmanlar
- Sürüm: 3.15
- Etkinleştirmeler: 5
Test it for free first: open Grid MFI Oscillator EA in the MetaTrader 5 Strategy Tester, turn on visual mode, and see which turns in money flow it accepts and which it walks past.
PRICE TELLS YOU WHERE. VOLUME TELLS YOU HOW MANY CAME ALONG.
A plain oscillator counts only price, so a drift on a handful of ticks scores the same as a move the whole market joined. The Money Flow Index weighs every bar by its activity first. Grid MFI Oscillator EA waits for that reading to reach an exhausted zone and then come back out of it, on a closed bar, with the slow trend on its side. Only then does a grid cycle begin, and a full management engine works down the oldest exposure through group closures and partial slices.
At a glance
- A BUY cycle can begin only when MFI rises back through its lower level (20) on a closed bar. A SELL needs the mirror move through the upper level (80). Closed bars only, so an accepted signal does not repaint.
- MFI is worked out inside the EA from each bar's high, low, close and tick volume over 14 bars. No custom indicator file and no DLL.
- New in this product: the Participation Guard, an optional check that the signal bar carried real activity. It is OFF by default, because in our runs it took profit away and did not reduce drawdown. The numbers are below, and the panel shows its reading either way.
- The Depth Guard wants a true visit beyond the level, so a brush against it does not count.
- The Snap Guard wants MFI to move with some force on the signal bar itself.
- The EMA 200 filter is on by default, so a cycle starts as a pullback on the side of the slow trend. Switch it off, or use it to fade.
- Past crossings are marked on the live candles: a small arrow when one passed, a grey dot when it was refused.
- No stop loss and no forced close-all. A reached limit refuses new levels while the book keeps being managed, which also means the EA does not cap your losses.
START HERE
Open EURUSD H1, keep the 0.01 starting lot and the additive ladder, and set RunMode to Scan only for the first session. The panel then shows each plan while no order is sent, and one button moves it to Armed when you are ready. Repeat the runs below on your own broker's data, since spreads, swaps, commissions and tick counts all differ. The figures use default inputs, so there is nothing to type in to reproduce the method.
What our tests showed, and what they did not
Default inputs, Strategy Tester, 1 minute OHLC model, leverage 1:100, 2025.01.01 to 2026.09.30, one broker's demo data:
- EURUSD H1, $10,000 deposit: net result +376.49, maximal equity drawdown 351.06 (3.48%), 145 trades, no stop-out and no margin refusals.
- EURUSD H1, $1,000,000 deposit: net result +376.49, maximal equity drawdown 351.06 (0.04%), 145 trades, no stop-out and no margin refusals.
- XAUUSD D1, $10,000 deposit: net result +6.03, maximal equity drawdown 23.63 (0.24%), 2 trades, no stop-out and no margin refusals.
- XAUUSD D1, $1,000,000 deposit: net result +6.03, maximal equity drawdown 23.63 (0.00%), 2 trades, no stop-out and no margin refusals.
These are simulations of one past period, not a forecast. The money drawdown is the same at both deposits because lots do not grow with the balance, so it would be a much larger share of a small account. Deposits under $10,000 were not tested. Two XAUUSD trades prove nothing at all, and that chart was very quiet at these settings.
The guard comparison, stated plainly. We built the Participation Guard expecting it to help, ran it at a minimum of 1.0, and it did not earn its place. Guard on, EURUSD H1 at $10,000: net +335.90, drawdown 351.06 (3.47%), 98 trades. Guard off: net +376.49, drawdown 351.06 (3.48%), 145 trades. On XAUUSD D1 at $10,000 both runs were the same 2 trades. So it removed about a third of the trades, cut net by about 11%, and left the deepest drawdown where it was. That is why it ships off. This is one in-sample run per setting, so it does not prove the guard is useless either; other symbols or minimums may behave differently, and you can test that yourself.
We also looked once at wider levels, 30/70. EURUSD H1 at $10,000 with the guard off gave net +1,518.30, drawdown 1,020.90 (9.39%), 525 trades. With the guard on: net +1,219.54, drawdown 9.63%, 366 trades. XAUUSD D1 gave 5 and 2 trades. Those levels traded more and nearly tripled the drawdown. We kept the classic 20/80, so the defaults were not changed to suit the result, and nothing was optimised.
Not verified: netting accounts (the code has a netting cap, but no netting run was confirmed, so treat netting as untested), the hedge cycle and the margin timeframe safety (both off in every run), the panel with live open positions and the Hedge Vault card on screen (no positions and hedge off at our screenshot), the Participation Guard on any symbol beyond these two, and any live trading.
Why volume is worth asking about
The Money Flow Index is often called a volume-weighted RSI. Each bar's typical price is multiplied by its volume, then the flow of rising bars is compared with the flow of falling bars. A high reading means most recent money arrived on up bars; a low reading means the opposite. A grid has no stop to undo a poor start, so a false turn sits on the book until the engine works it off. A reading that already includes activity is a reasonable thing to consult before that first order.
One honest limit: on spot forex and most CFDs, MetaTrader offers tick volume, a count of price changes rather than money traded. It tends to follow activity but it is a proxy, and it differs between brokers. The name of the indicator is traditional; no one can see the real money from a retail feed.
The improvement in this release
The Participation Guard is this EA's own addition. It compares the signal bar's tick volume with the average of the 20 bars before it. Set InpMFIPartMin to 1.0 to demand at least average activity, higher for a stricter test, or leave 0 to keep it off. The PARTICIPATION row shows the live ratio as PART 0.41, with off, OPEN or HOLD beside it, so you can watch how the check would behave before deciding. Margin-level timeframe safety is included and is off by default.
One cycle, step by step
1. The read. On each closed bar the EA computes the typical price, weighs it by tick volume, and sorts it into rising or falling flow.
2. The crossing. MFI must come back through your level on the signal bar: up through the lower one, or down through the upper one.
3. The Depth Guard. In the bars before the crossing, MFI must have gone far enough beyond that level.
4. The Snap Guard. MFI must move toward the trade by your minimum on the signal bar.
5. The Participation Guard. Off by default. When on, the signal bar must carry enough tick volume.
6. The trend filter. By default the close must sit on the trade's side of the slow EMA. Switch it off, or set it to fade.
7. The rhythm. A quiet gap of bars separates accepted signals, 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. BUY and SELL grids can run together or in one direction only.
9. The harvest. The closer searches groups of the oldest and newest orders and closes a group once its combined result, after swap and commission, beats your target. If the oldest order is still too heavy, only a slice of it goes.
10. The safety checks. A reopen guard blocks a closure that would put the same level straight back on. Every leg is checked against the deal history, failed legs wait in a retry queue, and a plan is dropped if the book changes before sending.
11. The optional hedge cycle. Off by default and not exercised in our tests. When 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 and keeps the right side and the price scale clear. It shows the symbol and magic number, a status pill, grid mode, lot step, spacing, banked result, the book, the closing plan for each side and the order list. The MFI PULSE row gives MFI on the last closed bar and the bar before it, your levels, the favoured side, and how many bars ago the last crossing happened. The PARTICIPATION row gives DEEP, SNAP and PART with their state, then the EMA side. Buttons switch Armed / Scan only, Pause / Resume, chart marks and slicing. The Hedge Vault card is built to dock under the main panel; it was not on screen in our screenshot because the hedge is off by default. 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.
The code caps the margin of a merged position on netting accounts as a percentage of equity; this has not been verified by our tests, so try it first in the tester on your own netting account.
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 after margin recovers past a cushion. Off by default and not tested by us.
Every copy isolates itself by symbol and magic numbers, so several charts do not touch each other's orders or saved state.
Scan only mode shows every decision without sending any order.
Quick answers
Does it repaint? No. By default signals come from closed bars, and a closed bar's values do not change.
Why does it trade so rarely? 20 and 80 are rarely reached and left, the Depth Guard asks for more, and the trend filter removes one side at a time. XAUUSD D1 gave 2 trades in 21 months.
Can I make it busier? Yes. Levels closer to 50 and lower guard minimums give more cycles and, in our one look at 30/70, a much deeper drawdown.
Do I need to attach an indicator? No. Crossings are marked on the live chart and the readings are shown as numbers on the panel, with no sub-window.
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 (9754410).
GridOrderComment - the comment on each grid order (GMFI).
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 (9754411).
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 Money Flow Index 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).
MFI - the signal
InpMFIPeriod - bars in the money flow sum (14; 2 or more).
InpMFIBuyLevel - MFI must rise back through this lower level for a BUY (20).
InpMFISellLevel - MFI must fall back through this upper level for a SELL (80).
InpMFIDepthPts - Depth Guard: points MFI must have gone beyond the level (5; 0 = off).
InpMFIDepthBars - Depth Guard: bars checked before the crossing (10; 0 = off).
InpMFISnapMin - Snap Guard: the smallest MFI move toward the trade on the signal bar (1.0; 0 = off).
InpMFIPartMin - Participation Guard: signal bar tick volume against the recent average (0 = off, the default; 1.0 asks for at least average).
InpMFIPartBars - Participation Guard: bars in that average (20).
InpMFITrendFilter - 0 off, 1 trade with the EMA side, 2 trade against it as a fade (1).
InpMFITrendMAPeriod - the trend EMA length (200).
InpShowSignalArrows - arrows on the candles where a cycle was armed (on).
InpShowMFIOnChart - marks recent level crossings on the live chart candles, arrows for passed and grey dots for refused (on; no extra sub-window).
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 manages a position; it cannot see the future, and it can lose a large part of an account. An exhausted reading can stay exhausted, and a clean exit from the zone can fail a few bars later. With no stop loss the book then stays open and grows while the move runs, up to the limits you set. Choose a lot your account can carry through that, test on your own broker first, and let the Strategy Tester show you how it behaves before you trade it live. It runs on any symbol and timeframe, and needs no DLLs and no extra files.
If you use it, a short and honest review of how it went on your account, good or bad, helps the next trader decide.
