Trading strategy Logic and function tested

GDI Dollar Index Divergence EA

Trades gold when it moves against the US Dollar Index, and stays flat when the two move together.

  • Version2.00
  • Last updated2026-12-05
  • SymbolGold (XAUUSD) only
  • TimeframeM5

Download GDI_Dollar_Index_Divergence_EA.ex5 ↓ Settings file (.set) ↓ Get a GDI Key (7-day free trial) →

Status. The logic and the operation of this EA have been tested. 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.

What it is

A short-term gold strategy that uses the usual opposite relationship between gold and the US Dollar Index. It trades XAUUSD only; the index is read, never traded.

The three operating modes

ModeWhat the EA does
Alert only (default)Never opens a position. Each entry signal raises an alert (once per bar and direction) in the Experts tab, as a pop-up and, if you switch it on, as a phone notification. Positions opened earlier by the EA keep their server stop and the EA may still close them.
Auto trading standardAt most one position or pending order of this EA at a time, and never more than one entry in the same trading session. The strategy's own stop, target and trade management apply.
Auto trading light gridThe first entry follows the standard rules. The EA may then add layers at a fixed distance, with the same lot and in the same direction, up to the maximum number of layers, under one common stop, one basket target and a maximum basket loss.

The selector is the first input in the window (InpOperatingMode). 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

Who it suits

Traders who watch the dollar next to gold and whose broker lists a dollar index contract.

What happens behind the scenes

  1. On start the EA checks that the chart is gold (XAUUSD with any broker suffix, or GOLD); on any other symbol it stops with a message and does not trade.
  2. 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. A lapsed key never closes positions that are already open.
  3. The strategy evaluates its signal and its own filters. Every order, market or pending, then passes through one common gate, which checks in turn: gold and chart symbol, licence, operating mode, magic number, real-account confirmation, one order at a time, one entry per session, grid pause, no opposite gold position, and the lot ceiling and broker lot step.
  4. If the gate refuses, nothing is sent and the reason is written in the Experts tab.
  5. The session already used is kept in memory, in a terminal global variable named GDIS_account_magic and in the deal history.
  6. In light grid mode the common stop, basket target, basket loss limit and new layers are managed on every tick, so the terminal must stay open and connected. The common stop is also on the server.

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.

SessionServer time (default)
Asia00:00 to 10:00
London10:00 to 15:00
New York15: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

Worked example of the distances (not a forecast)

A buy of 0.01 lots at 4,000.00 with the defaults: layers can be added at 3,992.00 and 3,984.00, and the common stop sits at 3,976.00. With a 100-ounce contract, the three layers stopped there would lose about 24 + 16 + 8 = 48 USD, before spread, swap and slippage. If the 2 per cent basket limit is smaller than that on your balance, the basket is closed earlier. With only the first order open, the target is 4,006.00; with two layers the average is 3,996.00 and the target 4,002.00.

A light grid increases the amount at risk while price moves against you. Gaps and slippage can make a loss larger than the figures above.

Requirements

RequirementDetail
PlatformMetaTrader 5 (.ex5 file; MetaTrader 4 is not supported).
SymbolXAUUSD with any broker suffix, or GOLD.
TimeframeM5
Account typeHedging account for the light grid. Alert only and standard also run on netting accounts.
GDI KeyRequired. The file itself is free to download.
Terminal settingsTools > Options > Expert Advisors: tick 'Allow WebRequest for listed URL' and add https://sync.golddailyinsights.com. For the automatic modes, allow Algo Trading.
ComputerThe 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_Dollar_Index_Divergence_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: 35c7336ba28022b3c8b58d407b9e30e57084492adf0e4b2c8b5ca8ef8902f3ca.

How the key works: GDI Key and licence check.

Installation and first run

  1. Copy the .ex5 file into MQL5/Experts in your MetaTrader 5 data folder (File > Open Data Folder) and refresh the Navigator.
  2. In Tools > Options > Expert Advisors, tick 'Allow WebRequest for listed URL' and add https://sync.golddailyinsights.com.
  3. Open an XAUUSD chart and drag the EA onto it. On the Inputs tab press Load and choose the .set file.
  4. Paste your GDI Key into InpGdiKey. Leave InpOperatingMode on Alert only for the first sessions.
  5. Check the Experts tab: the licence is confirmed and the operating mode is shown.
  6. 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 InpModeAllowReal set 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 (46 inputs)

Listed in the order of the MetaTrader inputs window. Distances marked 'points' are broker points unless the text says otherwise.

Operating mode

InputDefaultWhat it does and how to use it
InpOperatingMode1) ALERT ONLY: opens no order, only sends alertsOperating mode. Choose this first. Alert only is the safe start. Options: 1) ALERT ONLY: opens no order, only sends alerts; 2) AUTO TRADING STANDARD: one order, one entry per session; 3) AUTO TRADING LIGHT GRID: capped layers, same lot.
InpModeAllowRealfalseI confirm this is a real account I want to trade. Leave false until you really intend to trade a real account.
InpModeMaxLot0.10Lot ceiling for any single order. A safety ceiling: a larger lot is reduced to this value.
InpModeAlertPopuptrueAlert only mode: pop-up alert. Affects messages only.
InpModeAlertPushfalseAlert only mode: push notification to the phone. Affects messages only.

Trading sessions (broker server time)

InputDefaultWhat it does and how to use it
InpSessLondonHour10London session starts (server hour); Asia runs from 00:00. Adjust to your broker's server clock.
InpSessNewYorkHour15New York session starts (server hour), runs to 24:00. Adjust to your broker's server clock.

Light grid (used only in mode 3). 100 points = 1.00 USD

InputDefaultWhat it does and how to use it
InpLgStepPoints800Fixed distance between layers (points). Only read in the light grid mode.
InpLgMaxLevels3Maximum layers, first order included (2 to 5). Only read in the light grid mode.
InpLgTargetPoints600Basket target from the average price (points). Only read in the light grid mode.
InpLgStopPoints800Common stop: this far beyond the last layer (points). Only read in the light grid mode.
InpLgMaxLossPct2.0Basket maximum loss, % of balance (closes all layers). Only read in the light grid mode.
InpLgMinMinutes15Minimum minutes between layers. Only read in the light grid mode.
InpLgTrendBlocktrueNo new layer against a strong trend. Only read in the light grid mode.
InpLgTrendTfH1Strong-trend filter: timeframe. Only read in the light grid mode.
InpLgTrendAdxPer14Strong-trend filter: ADX period. Only read in the light grid mode.
InpLgTrendAdx25.0Strong-trend filter: ADX at or above this is strong. Only read in the light grid mode.
InpLgPauseHours24Pause after a basket is stopped out (hours). Only read in the light grid mode.

Gold Daily Insights Licence

InputDefaultWhat it does and how to use it
InpGdiKeyempty: paste your keyGDI Key. Paste your personal key here; the EA sends no order and no alert without a valid key.

Symbols (the dollar index contract is followed automatically)

InputDefaultWhat it does and how to use it
InpDollarIndexSymbolemptyUS Dollar Index symbol (empty = found automatically, including every futures roll; type the exact broker name only to force one).
InpGoldSymXAUUSDGold sym.
InpSuffixemptyExtra broker suffix if your account uses one (e.g. .a) - applied to both symbols.

Dollar Index session filter (check the hours with your broker)

InputDefaultWhat it does and how to use it
InpCheckDollarIndexSessiontrueCheck dollar index session. Hours follow the broker's server time.
InpDollarIndexSessionStartHour3Session open hour (server/broker time). Hours follow the broker's server time.
InpDollarIndexSessionEndHour23Session close hour (server/broker time). Hours follow the broker's server time.

News filter (native MT5 economic calendar)

InputDefaultWhat it does and how to use it
InpUseNewsFiltertruePause new orders around calendar news. Uses the MetaTrader economic calendar, which is not available inside the Strategy Tester.
InpNewsMinImportanceMODERATELowest news importance that counts. Uses the MetaTrader economic calendar, which is not available inside the Strategy Tester.
InpNewsMinutesBefore15Minutes before a news event during which nothing new is opened. Uses the MetaTrader economic calendar, which is not available inside the Strategy Tester.
InpNewsMinutesAfter15Minutes after a news event during which nothing new is opened. Uses the MetaTrader economic calendar, which is not available inside the Strategy Tester.
InpNewsCurrencyUSDCurrency filter for the calendar (USD drives both Dollar Index and gold). Uses the MetaTrader economic calendar, which is not available inside the Strategy Tester.

Momentum (timeframe and thresholds)

InputDefaultWhat it does and how to use it
InpTFM5Working timeframe (M5 suggested; M15 is more conservative). Any MetaTrader timeframe; 'current' follows the chart.
InpMomentumBars5Closed bars used to measure momentum. Counted in bars. Shorter reacts faster and gives more false signals; longer is slower and steadier.
InpMinDollarIndexMove0.04Minimum Dollar Index move (index points) to count as valid momentum.
InpMinGoldMoveUSD0.60Minimum gold move (USD) to count as valid momentum.

Rolling correlation filter (Pearson)

InputDefaultWhat it does and how to use it
InpCorrBars60Window (bars) used for the rolling correlation. Counted in bars. Shorter reacts faster and gives more false signals; longer is slower and steadier.
InpMaxCorr-0.20Only trade if correlation <= this value (more negative = stricter).

Risk management / scalping

InputDefaultWhat it does and how to use it
InpLots0.01Lot size of an order. Start with 0.01. On a standard gold contract, 0.01 lots gain or lose about 1 USD for each 1.00 USD move.
InpSL_Points250Stop loss in XAUUSD points. In broker points.
InpTP_Points180Take profit in XAUUSD points. In broker points.
InpMaxSpreadPts35Maximum allowed spread in points (scalping filter). Raise it if your broker's gold spread is normally wider; lower it to be stricter.
InpUseTrailingtrueUse the trailing stop. Trailing locks in part of a move but can close a trade early. Ignored while the light grid is active.
InpTrailStart120Profit (points) needed before trailing starts. Trailing locks in part of a move but can close a trade early. Ignored while the light grid is active.
InpTrailStep40Trailing stop distance (points). Trailing locks in part of a move but can close a trade early. Ignored while the light grid is active.
InpMaxHoldMin45Maximum time (minutes) a position may stay open.
InpMagic778241Magic. Keep it unique for each copy of an EA on the same account; do not change it while the EA has open positions.
InpDebugCommenttrueShow a debug panel on the chart. true switches it on, false switches it off.

Messages and troubleshooting

Message in the Experts tabWhat it means
licence: ...The key is missing, expired, in use on another IP, or the server address is not allowed in the terminal options.
this is a real account and 'I confirm this is a real account' is not tickedSet InpModeAllowReal to true only if you really want to trade that account.
one order at a timeThe EA already has a position or pending order.
one entry per session: already usedWait for the next session.
light grid pause after a stopped basketThe pause set in InpLgPauseHours is running.
a message about an opposite gold position or orderSomething on the account is open in the other direction; the EA will not hedge it.
the lot is below the broker minimumRaise InpModeMaxLot or the lot input to at least your broker's minimum.

Risks

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

Related EAs

Next steps

GDI Key and plans Getting started Ask a question All GDI EAs

Version 2.00, last updated 2026-12-05.