Loading…

Basket Delta Neutraliser

A book of EURUSD, GBPUSD and EURGBP longs looks diversified by symbol count, but the actual currency exposure can be heavily concentrated in one currency - EUR, in that example - because all three symbols share a leg. Reading that concentration from the ticket list means doing the base/quote decomposition and the currency conversion by hand for every open position, every time the book changes. This script does that decomposition automatically. Every open position is split into its base and quote currency legs, converted into account currency using whichever pair orientation is available in Market Watch, and accumulated into a per-currency net exposure table. The currency with the largest absolute net exposure - excluding the account currency itself, which is not a "problem" to hedge away - is identified as the target, and the script sizes the one trade against the account currency that would bring that currency's net exposure closest to zero. With InpConfirmTrade left at its default of false, the script only reports the recommended trade; nothing is sent. Setting it to true sends a real market order, so review the recommendation first. Notes and limitations - Only 6-letter symbol names (standard forex/metal naming, e.g. EURUSD or XAUUSD, ignoring any broker suffix beyond the first six characters) are decomposed into currency legs. Indices and other instrument types are skipped with a note in the log, since a base/quote split has no meaning for them. - A currency leg with no conversion pair available in Market Watch (neither orientation) is excluded from the exposure table with a note - the reported figures then understate true exposure for that currency. Add the missing pair to Market Watch and re-run for a complete picture. - The recommended trade only offsets the single most-exposed currency against the account currency directly. A book with several large, unrelated currency imbalances needs more than one run - re-run after the first offsetting trade to address the next-largest exposure. - Anything that sends a real order can lose money. Review the printed recommendation before setting InpConfirmTrade to true, and confirm AutoTrading is enabled deliberately.

Script · MT5 · v1.0 · Free

About Basket Delta Neutraliser

Basket Delta Neutraliser is an expert advisor (trading robot) for MetaTrader 5. It has 4 settings, such as Magic filter, Confirm trade and Offset magic. MQL source code included.

Files in the download: BasketDeltaNeutraliser.ex5, BasketDeltaNeutraliser.mq5, BasketDeltaNeutraliser.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Magic filter-1Magic number filter for positions considered (-1 = every magic)
Confirm tradefalseActually send the offsetting trade (false = report only)
Offset magic900001Magic number stamped on the offsetting trade
Slippage points30Allowed slippage in points for the offsetting trade

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: EURUSD · GBPUSD · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria