Loading…

Volatility Term Crossover System

A single volatility filter ("trade only when StdDev is above X") tells you the market is currently noisy, but says nothing about whether that noise is new. This EA instead compares two separate realised-volatility windows - InpShortVolPeriod and InpLongVolPeriod bars of log returns - and watches for the moment the short window's volatility overtakes the long window's by at least InpMinCrossMargin. While the short window sits below the long one, the market is in its normal compressed state relative to its own recent history; the cross is the point something started expanding that the slower baseline has not caught up to yet. A raw volatility-expansion cross fires just as often on directionless chop as on a real move, so entry additionally requires the last InpConfirmBars closed bars to sit consistently on one side of an InpConfirmMaPeriod moving average - confirmation that the market is actually moving one way, not just getting louder. The initial stop is scaled to the very volatility expansion that triggered the trade (the larger of the last bar's range and the measured short-horizon volatility in price terms, times InpStopAtrMultiple), so a stop sized for yesterday's calm market is not left in place through today's expansion. Notes and limitations - The cross is detected on the bar it happens and is a one-shot signal - it does not re-fire every bar the term structure stays expanded, only the transition bar. - If neither directional confirmation side is satisfied on the crossing bar, the signal is logged and skipped entirely - the EA does not wait for confirmation to arrive later on the same cross. - Realised volatility here is a standard deviation of log returns, not an options-implied measure - it describes what the market has just done, not what it is priced to do next. - Lot sizing uses MODE_TICKVALUE/MODE_TICKSIZE, not a hardcoded contract size, so it is correct on gold, indices and JPY crosses as well as plain FX pairs. - Only one position at a time.

Expert advisor · MT4 · v1.0 · Free

About Volatility Term Crossover System

Volatility Term Crossover System is an expert advisor (trading robot) for MetaTrader 4. It can size trades from your balance and risk percent. It has 14 settings, such as Short vol period, Long vol period and Min cross margin. MQL source code included.

Files in the download: VolTermCrossoverSystem.ex4, VolTermCrossoverSystem.mq4, VolTermCrossoverSystem.txt.

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

Settings

SettingDefaultWhat it does
Short vol period10Bars in the short-horizon realised volatility window
Long vol period50Bars in the long-horizon realised volatility window (baseline)
Min cross margin1.10Short vol must exceed long vol by this ratio to count as a real cross
Confirm ma period20Moving average period used for directional confirmation
Confirm bars1Consecutive closed bars required on the confirmed side of the MA
Use risk sizingtrueSize by percent risk to the stop instead of a fixed lot
Risk percent1.0Percent of equity risked per trade, when risk sizing is on
Fixed lots0.10Lot size when risk sizing is off, or as a sizing fallback
Stop atr multiple1.5Initial stop distance as a multiple of the short-window ATR-equivalent
Reward risk ratio1.5Take-profit distance as a multiple of the stop distance
Magic number43731Magic number for orders opened by this EA
Slippage pips3Slippage tolerance, in pips
Max retries5Attempts per trade action before giving up
Retry wait ms500Pause between attempts, milliseconds

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Experts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 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: Moving Average · Buy/Sell Arrows · Risk & Lot Size · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria