Loading…

Triangular Consistency Checker

Three related quotes should always multiply out to roughly the same relationship: EURUSD times USDJPY should sit close to EURJPY, within a spread's worth of noise. When it does not, something is off - a feed lag on one leg, a synthetic cross the broker constructs from stale legs, or a real arbitrage window that closes again in seconds. Either way, a trader working that triangle wants to know before placing an order against the wrong number. This script takes three symbols and a relationship - whether the third should equal the product or the quotient of the other two - and compares the quoted mid price against what the other two legs imply, reporting the drift in pips. A drift alone does not say which leg is wrong; all three prices individually could be fine and simply not perfectly synchronised for a moment. What narrows it down is quote age. The script reads each symbol's last tick time and flags whichever leg is both older than a configurable threshold and clearly older than the other two - not just marginally behind, but the one genuinely lagging - as the prime suspect. That is the single most common real-world cause of a triangle that briefly stops adding up: a feed that has gone quiet on one symbol while the other two keep ticking. Notes and limitations - Uses mid prices (average of bid and ask) with no spread modelled on any leg, so the reported drift is an approximation, not an exact arbitrage figure - real executable prices differ by each leg's own spread. - The relationship (product or quotient) must be set correctly by the user; the script has no way to know which one applies to an arbitrary set of three symbol names. - A symbol not already visible in Market Watch is selected automatically, but its price may take a moment to arrive - if a symbol reports no price, wait a few seconds and run the script again. - This is a one-shot snapshot, not a continuous monitor. Run it again to recheck, or adapt it into an indicator if continuous monitoring is wanted. - Triangular inconsistencies on a real broker are usually small and brief; a large, persistent drift more often means a wrong relationship setting or a genuinely broken synthetic cross than a tradeable arbitrage.

Script · MT5 · v1.0 · Free

About Triangular Consistency Checker

Triangular Consistency Checker is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message and shows several symbols in one panel. It has 6 settings, such as Symbol ab, Symbol bc and Symbol ac. MQL source code included.

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

Settings

SettingDefaultWhat it does
Symbol abEURUSDLeg AB
Symbol bcUSDJPYLeg BC
Symbol acEURJPYLeg AC (the cross under test)
Ac is producttruetrue: AC should equal AB*BC false: AC should equal AB/BC
Tolerance pips3.0Flag when the drift exceeds this many pips on AC
Stale seconds20A leg older than this, and clearly older than the others, is called stale

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 → Scripts.
  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 script onto a chart to run it once.

Download the PDF guide

Tags: Arbitrage · EURUSD · USDJPY · Alerts · Dashboards & Scanners · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria