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
| Setting | Default | What it does |
|---|---|---|
| Short vol period | 10 | Bars in the short-horizon realised volatility window |
| Long vol period | 50 | Bars in the long-horizon realised volatility window (baseline) |
| Min cross margin | 1.10 | Short vol must exceed long vol by this ratio to count as a real cross |
| Confirm ma period | 20 | Moving average period used for directional confirmation |
| Confirm bars | 1 | Consecutive closed bars required on the confirmed side of the MA |
| Use risk sizing | true | Size by percent risk to the stop instead of a fixed lot |
| Risk percent | 1.0 | Percent of equity risked per trade, when risk sizing is on |
| Fixed lots | 0.10 | Lot size when risk sizing is off, or as a sizing fallback |
| Stop atr multiple | 1.5 | Initial stop distance as a multiple of the short-window ATR-equivalent |
| Reward risk ratio | 1.5 | Take-profit distance as a multiple of the stop distance |
| Magic number | 43731 | Magic number for orders opened by this EA |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Max retries | 5 | Attempts per trade action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Experts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Moving Average · Buy/Sell Arrows · Risk & Lot Size · MT4 Expert Advisor · MQL4 Source Code