Grid Bollinger Bands EA
- Experts
-
AL MOOSAWI ABDULLAH JAFFER BAQER
To trade successfully we need to go through the proven path that others had gone and reached!
Here are 17 quotes from such successful investors:
1- Limit your size in any position so that fear does not become the prevailing instinct guiding your judgment.
Joe Vidich - Versione: 3.15
- Attivazioni: 5
See it with your own eyes before you spend anything: run Grid Bollinger Bands EA in the MetaTrader 5 Strategy Tester in visual mode and watch price stretch outside a band, snap back inside, and the grid start building only after that snap-back is confirmed on a closed candle.
BUY THE SNAP-BACK, NOT THE STRETCH.
Grid Bollinger Bands EA lets John Bollinger's famous volatility envelope decide when an overshoot has ended, then gives the position to a full grid management engine that keeps cutting the oldest exposure down a piece at a time.
Five things to know in ten seconds
• A cycle begins only when a candle closes back inside the bands after the previous candle closed outside them, read on closed bars only, so nothing repaints.
• The new Squeeze Guard ignores band touches while the bands are pinched unusually tight, the moment when a touch is more often the start of a breakout than the end of an overshoot.
• Profits are banked by groups of the oldest and newest orders, and an oversized old order is retired in partial slices instead of being left to wait.
• There is no stop loss and no forced close-all; when a limit is hit, new levels are refused and the existing book keeps being managed.
• Hedging and netting accounts both work, and every limit is an input you can see and change.
START HERE
First chart: EURUSD H1 or XAUUSD D1. Lot: the default 0.01 with the additive ladder. First mode: Scan only, so the panel shows you every plan before a single order is sent; switch to Armed when you are comfortable. Test on your own broker's data first, because spreads, swaps and commissions vary from one broker to another. With a small balance, keep the default lot and let the Strategy Tester show how deep the book gets on your symbol.
Why the bands, and why they suit a grid
Bollinger Bands draw a moving average with an upper and a lower line set a number of standard deviations away from it. When markets are calm the lines move closer; when they get busy the lines spread apart. Because the distance adapts to volatility, a close outside a band means something unusual happened relative to recent behaviour, whatever the symbol or timeframe. Here the EA is careful: being outside the band is not the trigger. Price can ride a band for a long time in a strong move. The trigger is the return, the first closed candle that comes back inside after closing outside. That return shows the push has paused, and that is when the grid is allowed to start.
What is new in this release
The Squeeze Guard is this EA's own improvement. Every trader who has used the bands knows the trap: after a long quiet spell the bands become very narrow, price slips through one side and appears to come back, and then the real breakout tears away in that same direction. The guard compares the current band width with its own average over a window of bars you choose. When the bands are much tighter than usual, the return is ignored, because in a squeeze a return inside means little. Once the bands open up to a normal width, returns count again. Set the ratio to 0 to switch the guard off. A BB SQUEEZE row on the panel shows the live width as a multiple of its average and whether the guard currently says OPEN or SQUEEZE hold. Margin-level timeframe safety is also included and is off by default.
How one cycle runs
1. The read. At every closed bar the EA takes the base line, the upper band and the lower band from the built-in MetaTrader 5 Bollinger Bands indicator. The forming candle is never used, so what you see on history is exactly what the EA saw at the time.
2. The return. A BUY cycle is considered when a candle closes back above the lower band after the previous candle closed below it; a SELL cycle is the mirror at the upper band. An optional wick mode also accepts a candle that pushes through a band with its shadow and closes inside on the correct side of the base line.
3. The depth check. If you want a firmer return, you can require the close to sit a minimum number of points inside the band.
4. The Squeeze Guard. The band width on the signal bar must be at least your chosen multiple of its average width.
5. The optional trend filter. An EMA can confirm the side: trade only with it, trade only against it as a fade, or leave it off.
6. The rhythm. A quiet gap of bars between accepted signals stops a nervous session from firing one cycle after another, and a signal stays valid for a few bars when a level cannot be placed straight away.
7. The ladder. Levels are spaced by a fixed distance or by ATR, with a floor, a ceiling 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.
8. The harvest. The closer looks for groups made 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 that is already open.
9. The safety checks. A reopen guard blocks a 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.
10. The optional hedge cycle. Off by default. When enabled it holds a balanced pair on a symbol you choose and retires it in equal slices, paid for by a small surcharge on closures the grid is already making.
The panel
The panel sits on the left side of the chart, leaving 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 profit, the book in lots with its net result, the closing plan for each side with its own close button, and the order list. A BB PULSE row shows the live %B position inside the bands, whether price is in the upper half, lower half or outside a band, and how many bars have passed since the last return. The BB SQUEEZE row shows the width ratio, the guard state and the trend filter. Buttons switch Armed / Scan only, Pause / Resume, chart marks and slicing. The Hedge Vault card sits directly under the main panel and follows it when you drag or minimise. On a live chart the bands themselves are drawn for you, and arrows mark the candles where a cycle was armed. The panel scales with the screen and 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 throws away 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.
On netting accounts the margin of the merged position is capped as a percentage of equity.
Optional margin-level timeframe safety moves signals and spacing to a higher timeframe when the margin level falls to your levels, and moves back only after margin recovers past a cushion. Off by default.
Each 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 is for, and who it is not for
It fits traders who want a clear, visual reason for every new cycle, who like many small closures more than one big target, and who are willing to size the lot for their own account. It does not fit anyone who wants a stop loss on every order, a promised monthly figure, or a set-and-forget robot with large lots on a tiny balance.
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 (9754240).
GridOrderComment - the comment on each grid order (GBB).
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 corresponds to 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 (9754241).
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).
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 Bollinger 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).
Bollinger Bands - the signal
InpBBPeriod - bars in the base moving average and the deviation (20).
InpBBShift - horizontal shift of the bands in bars (0).
InpBBDeviation - how many standard deviations the bands sit from the base line (2.0).
InpBBPrice - the price the bands are built on (close).
InpBBPierceMode - 0 needs a close outside followed by a close back inside; 1 also accepts a wick through the band that closes inside (0).
InpBBMinReentryPts - the minimum distance, in points, the return close must sit inside the band (0 = off).
InpBBSqueezeRatio - Squeeze Guard: band width must be at least this multiple of its average (0.80; 0 = off).
InpBBSqueezeLookback - bars used for the average band width (100).
InpBBTrendFilter - 0 off, 1 trade with the EMA side, 2 trade against it as a fade.
InpBBTrendMAPeriod - the trend EMA length (200).
InpShowSignalArrows - arrows on the candles where a cycle was armed (on).
InpShowBandsOnChart - draws the Bollinger Bands on the live chart for you (on).
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).
Debug
DebugMode - detailed journal logging (off).
Honest expectations
A grid manages a position; it cannot see the future. Grid Bollinger Bands EA is choosy about when a cycle begins and works steadily to keep each cycle short and each old order shrinking, but a strong trend can walk along a band for a long time and keep the book open. Pick 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 go live. It runs on any symbol and timeframe and needs no DLLs and no extra files.
If you use it, an honest review of how it worked on your account, good or bad, helps other traders decide.
