Trading strategy Logic and function tested
GDI Trend Pullback EA
Gold only. Buys dips in an uptrend and sells rallies in a downtrend. Three operating modes: Alert only (default), Automatic trading - standard, and Automatic trading - light grid.
- Version8.13
- Last updated2026-12-05
- SymbolGold (XAUUSD) only
- TimeframeAny; M15 or H1 is the usual choice
Download GDI_Trend_Pullback_EA.ex5 ↓ Settings file (.set) ↓ Get a GDI Key (7-day free trial) →
What it is
A trend-following pull-back strategy for gold. The Awesome Oscillator and ADX (with its +DI and -DI lines) decide whether there is a trend and which way it runs. An envelope around a moving average marks the dip or rally worth trading. An extreme CCI reading can close a single order early.
The three operating modes
| Mode | What the EA does |
|---|---|
| Alert only (default) | Never sends an order. Each entry signal raises an alert with price, suggested stop and target. |
| Auto trading standard | One order at a time and never more than one new entry in the same trading session. Stop and target are set on the server. |
| Auto trading light grid | The first entry follows the standard rules. Further levels are added only 800 points (8.00 USD) apart, with the same lot and direction, up to 3 levels in total, with a maximum basket loss of 2 per cent of the balance. |
The selector is the first input in the window (InpMode). There is no martingale in any mode (the lot is never increased after a loss) and no hedging (the EA never opens against an open gold position or order on the account). Where the strategy text allows several trades a day or several open positions, the operating mode is the stricter rule and wins.
The strategy: how it decides
- Trend: Awesome Oscillator side of zero and the directional lines agree, with ADX at least
InpAdxMin. - Entry: price touches the outer envelope band against the trend and closes back inside it.
- Early exit: CCI reaching plus or minus
InpCciExitcan close a single order. - Protection: ATR-based stop and target, optional break-even and trailing, daily and equity limits, news, spread, session and trend filters.
- At most one new entry per trading session.
Who it suits
Traders who prefer to join a trend on a pull-back and accept that sideways markets produce false starts.
What happens behind the scenes
- On start the EA checks that the chart is gold (XAUUSD with any broker suffix, or GOLD); on any other symbol it does not trade.
- It verifies the GDI Key with sync.golddailyinsights.com when it starts and again periodically. Without a valid key it sends no order and no signal alert.
- The signal is evaluated once per new bar by default. Before any new order it checks, in turn: trading permission, one entry per session, protection and risk limits, trading days and hours, direction, news, spread and the trend filter.
- Open positions are managed on every pass: stop, target, break-even, trailing, strategy exit and basket rules.
- State is rebuilt from the open positions and the deal history after a restart. Messages explaining every skipped signal appear in the Experts tab and on the panel.
Trading sessions and the one-entry rule
Sessions follow your broker's server time. The defaults suit brokers on GMT+2 or GMT+3 and can be changed with InpSessLondonHour and InpSessNewYorkHour.
| Session | Server time (default) |
|---|---|
| Asia | 00:00 to 10:00 |
| London | 10:00 to 15:00 |
| New York | 15:00 to 24:00 |
In both automatic modes there is at most one new entry per session, even if the first trade has already closed. The EA checks its memory and the account's deal history, so restarting the terminal does not reset the count. If the history cannot be read, it does not open.
The light grid in detail
- Distance between levels: a fixed 800 points (8.00 USD on gold),
InpGridSpacing. - Levels: 3 at most, the first order included (
InpGridMaxLevels). Every level has the same lot. - A new level also needs a new signal bar, 60 minutes since the previous level, trading hours, spread and news permission, and no strong trend against the basket.
- Exit: basket target and optional basket trailing; a mandatory maximum basket loss (2 per cent of the balance) with a safety stop on the server.
- Total basket volume is capped at 0.10 lots; after a stopped basket the EA waits 24 hours.
- A hedging account is required. On a netting account no levels are added.
A light grid increases the amount at risk while price moves against you. Use it only if you accept the full basket loss.
Requirements
| Requirement | Detail |
|---|---|
| Platform | MetaTrader 5 (.ex5 file; MetaTrader 4 is not supported). |
| Symbol | XAUUSD with any broker suffix, or GOLD. |
| Timeframe | Any; M15 or H1 is the usual choice |
| Account type | Hedging account for the light grid. |
| GDI Key | Required. The file itself is free to download. |
| Terminal settings | Tools > Options > Expert Advisors: tick 'Allow WebRequest for listed URL' and add https://sync.golddailyinsights.com. For the automatic modes, allow Algo Trading. |
| Computer | The terminal must stay open and connected while the EA works; a VPS is the usual choice. |
Download and licence
You receive the compiled file only: GDI_Trend_Pullback_EA.ex5, with a settings file holding every input at its default and an empty key. The EA works only with a valid GDI Key typed into InpGdiKey.
Compiled with MetaEditor: 0 errors, 0 warnings. SHA-256 of the .ex5 file: 866531d838e6c71d4a1ac556fbc5bc38ece9bb1b3c607882198c877cf1fad9b1.
How the key works: GDI Key and licence check.
Installation and first run
- Copy the
.ex5file intoMQL5/Expertsin your MetaTrader 5 data folder (File > Open Data Folder) and refresh the Navigator. - In Tools > Options > Expert Advisors, tick 'Allow WebRequest for listed URL' and add
https://sync.golddailyinsights.com. - Open an XAUUSD chart and drag the EA onto it. On the Inputs tab press Load and choose the
.setfile. - Paste your GDI Key into
InpGdiKey. LeaveInpModeon Alert only for the first sessions. - Check the Experts tab: the licence is confirmed and the operating mode is shown.
- When you choose an automatic mode, start with the smallest lot, preferably on a demo account, and tick the Common tab option 'Allow Algo Trading'. A real account also needs
InpAllowRealset to true.
Running your own backtest
Open the Strategy Tester (Ctrl+R), choose the EA, an XAUUSD symbol and a period, load the settings file and select the operating mode you want to study. The key is not checked in the tester. The economic calendar and push notifications do not work inside the tester, so news filters behave differently there. Backtests are in progress and will be published on each EA's page. Backtesting is the user's own responsibility: whoever pays for the key may use and test every product.
Inputs: the complete manual (110 inputs)
Listed in the order of the MetaTrader inputs window. Distances marked 'points' are broker points unless the text says otherwise.
Operating mode and general
| Input | Default | What it does and how to use it |
|---|---|---|
InpMode | 1) Alert only (default): no orders at all | Operating mode. Choose this first. Alert only is the safe start. Options: 1) Alert only (default): no orders at all; 2) Automatic trading - standard: one order at a time; 3) Automatic trading - light grid: max 3 levels, fixed lot, basket max loss. |
InpGdiKey | empty: paste your key | GDI Key. Paste your personal key here; the EA sends no order and no alert without a valid key. |
InpMagic | 26120001 | Magic number (0 is not accepted). Keep it unique for each copy of an EA on the same account; do not change it while the EA has open positions. |
InpAllowReal | false | I confirm this is a real account I want to trade. Leave false until you really intend to trade a real account. |
InpComment | GDI_Trend_Pullback_EA | Order comment. |
InpSymbolSuffix | empty | Symbol suffix (not used: gold only, the chart symbol is always the one traded). |
Alerts (types used in every mode)
| Input | Default | What it does and how to use it |
|---|---|---|
InpAlertPopup | true | Pop-up alert on screen. Affects messages only. |
InpAlertPush | false | Push notification to phone. Affects messages only. |
InpAlertEmail | false | E-mail. Affects messages only. |
InpAlertSound | false | Sound. Affects messages only. |
InpAlertFile | alert.wav | Sound file. Affects messages only. |
InpAlertSignals | true | Alert on entry signals. Affects messages only. |
InpAlertOrders | true | Alert on orders opened and closed. Affects messages only. |
InpAlertLimits | true | Alert on protection and risk limits. Affects messages only. |
InpAlertGapMin | 5 | Minutes between repeated alerts per symbol. Affects messages only. |
Execution
| Input | Default | What it does and how to use it |
|---|---|---|
InpDirection | Buy and sell (never both on one symbol) | Allowed direction. Options: Buy and sell (never both on one symbol); Buy only; Sell only. |
InpEvaluate | Once per new bar | Evaluate the entry signal. Options: Once per new bar; On every check (about once a second). |
InpOpposite | Ignore it | On an opposite signal. Options: Ignore it; Close what is open; Close, then open the other way. |
InpMaxTradesDay | 0 | Max new trades per day (0 = no limit). |
InpCooldownBars | 1 | Cooldown after closing, in bars (0 = none). Counted in bars. Shorter reacts faster and gives more false signals; longer is slower and steadier. |
Entry signal
| Input | Default | What it does and how to use it |
|---|---|---|
InpSignalTf | current chart | Signal timeframe (current = chart). Any MetaTrader timeframe; 'current' follows the chart. |
InpAdxMin | 22.0 | The trend must be at least this strong (ADX). |
InpEnvPeriod | 20 | Envelope: average period. Counted in bars. Shorter reacts faster and gives more false signals; longer is slower and steadier. |
InpEnvWidth | 0.20 | Envelope: width on each side (% of price). |
InpCciPeriod | 14 | CCI period (used to close early). Counted in bars. Shorter reacts faster and gives more false signals; longer is slower and steadier. |
InpCciExit | 150.0 | Close early at CCI plus or minus (0 = never). |
Money management
| Input | Default | What it does and how to use it |
|---|---|---|
InpLotMode | Fixed lot | Lot mode. Options: Fixed lot; Risk per cent of balance; Fixed lot per balance step. |
InpFixedLot | 0.01 | Fixed lot (0 = smallest of the symbol). Start with 0.01. On a standard gold contract, 0.01 lots gain or lose about 1 USD for each 1.00 USD move. |
InpRiskPercent | 0.5 | Risk per trade, % of balance (single order). A smaller number means a smaller position for the same stop distance. |
InpBalanceStep | 1000.0 | Balance step for one fixed lot. |
InpMaxLot | 1.0 | Maximum lot per order (0 = broker limit). Start with 0.01. On a standard gold contract, 0.01 lots gain or lose about 1 USD for each 1.00 USD move. |
Stops, targets and exits (single order)
| Input | Default | What it does and how to use it |
|---|---|---|
InpStopUnit | ATR multiples | Stop and target unit. Options: ATR multiples; Points. |
InpAtrPeriod | 14 | ATR period (signal timeframe). Counted in bars. Shorter reacts faster and gives more false signals; longer is slower and steadier. |
InpStopLoss | 2.0 | Stop loss (0 = no stop). |
InpTakeProfit | 3.0 | Take profit (0 = no target). |
InpUseBreakEven | false | Use break-even. Moves the stop to the entry area once the trade is in profit. Ignored while the light grid is active. |
InpBeTrigger | 1.0 | Break-even trigger. Moves the stop to the entry area once the trade is in profit. Ignored while the light grid is active. |
InpBeOffset | 0.1 | Break-even offset beyond entry. Moves the stop to the entry area once the trade is in profit. Ignored while the light grid is active. |
InpUseTrailing | false | Use the trailing stop. Trailing locks in part of a move but can close a trade early. Ignored while the light grid is active. |
InpTrailStart | 1.5 | Trailing start. Trailing locks in part of a move but can close a trade early. Ignored while the light grid is active. |
InpTrailDistance | 1.0 | Trailing distance. Trailing locks in part of a move but can close a trade early. Ignored while the light grid is active. |
InpTrailStep | 0.1 | Trailing step (0 = every improvement). Trailing locks in part of a move but can close a trade early. Ignored while the light grid is active. |
InpPartialAt | 0.0 | Partial close at (0 = none; hedging account). Needs a position large enough to be split at your broker's lot step. Ignored while the light grid is active. |
InpPartialPct | 50.0 | Partial close, % of the volume. Needs a position large enough to be split at your broker's lot step. Ignored while the light grid is active. |
InpUseOwnExit | true | Use the strategy's own exit signal. true switches it on, false switches it off. |
InpMaxBarsOpen | 0 | Close after this many bars (0 = no limit). |
Light grid
| Input | Default | What it does and how to use it |
|---|---|---|
InpGridAtrTf | H4 | ATR timeframe for spacing. Any MetaTrader timeframe; 'current' follows the chart. |
InpGridSpacing | 800.0 | Fixed distance between levels (points, 100 = 1.00 USD). |
InpGridMaxLevels | 3 | Max levels incl. the first (1 to 3). Moving the level further from the middle gives fewer signals. |
InpGridNewBarOnly | true | New level only on a new signal bar. true switches it on, false switches it off. |
InpGridMinMinutes | 60 | Minimum minutes between levels. |
Light grid: basket exit and safety
| Input | Default | What it does and how to use it |
|---|---|---|
InpBasketUnit | ATR multiples from the average price | Basket target and trailing unit. Options: ATR multiples from the average price; Money (account currency); Percent of balance; Points from the average price. |
InpBasketTarget | 1.0 | Basket profit target. |
InpBasketTrailStart | 0.0 | Basket trailing start (0 = off). Trailing locks in part of a move but can close a trade early. Ignored while the light grid is active. |
InpBasketTrailDist | 0.0 | Basket trailing distance (0 = off). Trailing locks in part of a move but can close a trade early. Ignored while the light grid is active. |
InpBasketMaxLossPct | 2.0 | Max basket loss, % balance (mandatory). A protective limit; check it against your balance. |
InpGridSafetyMult | 1.25 | Server stop at max basket loss distance x this (1 to 2; 0 = off). |
InpBasketMaxLots | 0.10 | Max total lots per basket (mandatory). Start with 0.01. On a standard gold contract, 0.01 lots gain or lose about 1 USD for each 1.00 USD move. |
InpBasketMaxHours | 0 | Max basket age, hours (0 = no limit). Hours follow the broker's server time. |
InpStopCooldownHrs | 24 | Cooldown after a basket or float stop, hours. |
InpCloseBeforeWkend | false | Close baskets before the weekend. true switches it on, false switches it off. |
InpFinishOnly | false | No new baskets, only finish the open ones. true switches it on, false switches it off. |
Equity protection (trailing lock)
| Input | Default | What it does and how to use it |
|---|---|---|
InpEqLevels | Percent of start-of-day balance | Levels are set as. Moving the level further from the middle gives fewer signals. Options: Money (account currency); Percent of start-of-day balance; Points x open volume (per symbol only). |
InpEqUseTrailing | false | Use the equity trailing lock. Trailing locks in part of a move but can close a trade early. Ignored while the light grid is active. |
InpEqTrailStart | 1.0 | Trailing lock starts at floating profit. Trailing locks in part of a move but can close a trade early. Ignored while the light grid is active. |
InpEqTrailLock | 0.5 | Profit secured once started. Trailing locks in part of a move but can close a trade early. Ignored while the light grid is active. |
InpEqUseTarget | false | Use an equity profit target. true switches it on, false switches it off. |
InpEqTarget | 2.0 | Close when floating profit reaches. |
Risk management (this robot only)
| Input | Default | What it does and how to use it |
|---|---|---|
InpRiskMode | Percent of start-of-day balance | Limits are set as. Options: Money (account currency); Percent of start-of-day balance. |
InpUseDailyLimit | true | Use daily loss limit (from today's peak). A protective limit; check it against your balance. |
InpDailyLimit | 5.0 | Daily loss limit. A protective limit; check it against your balance. |
InpDailyAction | Close the positions | When the daily limit is reached. A protective limit; check it against your balance. Options: Close the positions; Alert only. |
InpUseFloatLimit | true | Use floating loss limit. true switches it on, false switches it off. |
InpFloatLimit | 4.0 | Floating loss limit. |
InpFloatAction | Close the positions | When the floating limit is reached. Options: Close the positions; Alert only. |
InpUseLossCount | false | Stop after a number of losing trades. true switches it on, false switches it off. |
InpMaxLossCount | 5 | Losing trades allowed per day. A protective limit; check it against your balance. |
InpLossCountAction | Close the positions | When that number is reached. Options: Close the positions; Alert only. |
Trading time (broker server time)
| Input | Default | What it does and how to use it |
|---|---|---|
InpSessionFrom | 07:00 | Session start HH:MM (both empty = 24h). Hours follow the broker's server time. |
InpSessionTo | 21:00 | Session end HH:MM. Hours follow the broker's server time. |
InpSessLondonHour | 10 | One entry per session: London starts (server hour; Asia from 00:00). Adjust to your broker's server clock. |
InpSessNewYorkHour | 15 | One entry per session: New York starts (server hour), to 24:00. Adjust to your broker's server clock. |
InpTradingDays | 12345 | Trading days (1 Mon to 7 Sun; empty = all). |
InpOutside | No new orders (keep managing) | Outside trading hours. Options: No new orders (keep managing); No new orders, alert signals only; Close the positions. |
InpFridayLast | 20:00 | Friday: last new trade HH:MM (empty = none). |
News filter (MT5 calendar)
| Input | Default | What it does and how to use it |
|---|---|---|
InpNewsFilter | true | Pause new trades around news. Uses the MetaTrader economic calendar, which is not available inside the Strategy Tester. |
InpNewsImportance | HIGH | Minimum importance. Uses the MetaTrader economic calendar, which is not available inside the Strategy Tester. |
InpNewsBefore | 20 | Minutes before. Uses the MetaTrader economic calendar, which is not available inside the Strategy Tester. |
InpNewsAfter | 20 | Minutes after. Uses the MetaTrader economic calendar, which is not available inside the Strategy Tester. |
InpNewsCurrencies | empty | Extra currencies (symbol's own always count). Uses the MetaTrader economic calendar, which is not available inside the Strategy Tester. |
InpNewsBlockLevels | true | Also block new grid levels during news. Uses the MetaTrader economic calendar, which is not available inside the Strategy Tester. |
InpNewsCloseLoser | false | Close a losing basket when news arrives. Uses the MetaTrader economic calendar, which is not available inside the Strategy Tester. |
InpNewsCloseLoss | 1.0 | Minimum basket loss for that cut, % balance. Uses the MetaTrader economic calendar, which is not available inside the Strategy Tester. |
Spread and execution
| Input | Default | What it does and how to use it |
|---|---|---|
InpSpreadRatio | 4.0 | Wait if spread above N x usual (0 = off). Raise it if your broker's gold spread is normally wider; lower it to be stricter. |
InpMaxSpreadPts | 0 | Max spread in points, all symbols (0 = off). Raise it if your broker's gold spread is normally wider; lower it to be stricter. |
InpSlippagePts | 0 | Max slippage in points (0 = automatic). |
InpOrderTries | 3 | Order attempts. |
InpRetryPauseMs | 300 | Pause between attempts, ms. |
InpScalePoints | true | Scale point inputs to each symbol. In broker points. |
Trend filter (trade with the higher trend)
| Input | Default | What it does and how to use it |
|---|---|---|
InpTrendSwitch | Automatic (on in Light grid, off otherwise) | Only start trades with the trend. Options: Automatic (on in Light grid, off otherwise); On; Off. |
InpTrendTf | H4 | Trend timeframe. Any MetaTrader timeframe; 'current' follows the chart. |
InpTrendPeriod | 200 | Trend average period (0 = filter off). Counted in bars. Shorter reacts faster and gives more false signals; longer is slower and steadier. |
InpTrendMethod | EMA | Trend average method. |
InpTrendMaxAdx | 0.0 | Max ADX to start a grid (0 = off). |
InpTrendBlockLevels | true | Block new levels against the trend. Moving the level further from the middle gives fewer signals. |
Gold (XAUUSD) settings
| Input | Default | What it does and how to use it |
|---|---|---|
InpG2Spread | 60 | Max spread on gold, points (0 = general). Raise it if your broker's gold spread is normally wider; lower it to be stricter. |
Panel and testing
| Input | Default | What it does and how to use it |
|---|---|---|
InpShowPanel | true | Show the panel on the chart. Display only; it does not change any trade. |
InpPanelSymbols | 8 | Symbols listed on the panel (0 = summary only). Display only; it does not change any trade. |
InpDetailedLog | false | Detailed log. true switches it on, false switches it off. |
InpTesterReport | true | Write the test report file in the Strategy Tester. true switches it on, false switches it off. |
Risks
- Gold moves fast; spreads widen around news and at the daily rollover, and stops can be filled worse than requested.
- A signal that worked in one market condition can fail in another.
- The light grid adds exposure against the move by design, within the limits above.
- If the terminal, the computer or the connection stops, only what is on the server (stop and target) stays in force.
- Settings are your responsibility. Check the lot and the loss limits against your balance before any automatic mode.
Frequently asked questions
- Which symbol does it trade?
- Gold only: XAUUSD with any broker suffix, or GOLD. On any other symbol it does not trade.
- Does it open orders as soon as I attach it?
- No. The default mode is Alert only. Orders are sent only after you choose one of the two automatic modes, and on a real account only after you also tick the real-account confirmation.
- Does it use martingale or hedging?
- No. The lot is never increased after a loss and the EA never opens against an open gold position or order on the account.
- Why did it not enter on a second signal?
- In the automatic modes there is at most one entry per trading session and one order at a time.
- Do I need a GDI Key?
- Yes. The file is free to download and works only with a valid GDI Key. In the MetaTrader Strategy Tester the key is not checked.
- Is the source code available?
- No. You receive the compiled .ex5 file and a settings file.
- Are there backtest results?
- Backtests are in progress and will be published on each EA's page. Backtesting is the user's own responsibility: whoever pays for the key may use and test every product.
- Is profit guaranteed?
- No. Trading carries a high level of risk and an EA can lose money.
Trading carries risk. An EA can lose money, and nothing here is advice. Risk disclosure
Next steps
GDI Key and plans Getting started Ask a question All GDI EAs
Version 8.13, last updated 2026-12-05.