Loading…

Momentum Persistence System

"The trend is old, it must reverse soon" is a common instinct with no statistical grounding behind it unless someone actually measures how long runs on this specific symbol tend to last. This system does that measurement directly from the symbol's own closed-bar history rather than assuming a fixed number: it scans InpMeasurementBars of history, breaks the close-to- close direction sequence into consecutive same-direction runs, and averages their lengths into a single "measured persistence" figure in bars. A continuation trade is only opened while the CURRENT run (counted back from the last closed bar) is both at least InpMinRunBars long (some confirmation required) and still shorter than the measured persistence length - i.e. on the evidence gathered from this symbol's own history, a run this length has more often kept going than reversed. Once the current run reaches the measured length, the system stops opening new continuation trades in that direction; it is not betting against its own measurement by chasing an already-extended move. The measurement is not fixed at attach time - it is recomputed every InpRemeasureEveryBars closed bars, since a value baked in once would quietly stop matching the symbol as its volatility regime shifts over weeks or months. An open position is closed the moment the run actually breaks (a close prints against the held direction), independent of where price sits relative to its stop or target, since the persistence thesis for that trade is over the instant continuity breaks. Position sizing is risk-based off the symbol's own tick value and tick size, never a hardcoded contract size. Exit management runs through a ticket- collect-first loop scoped to this system's own magic number. Notes and limitations Runs are measured on close-to-close direction, a simple definition that ignores intrabar structure and wicks entirely - two very different-looking bars with the same net direction count identically. The measured persistence figure is a plain average of historical run lengths, not a percentile or confidence interval; it describes typical behaviour, not a guaranteed ceiling, and is only ever a description of the past InpMeasurementBars bars, not a forecast. Only one position per magic/symbol is held at a time. Grid, martingale and averaging are NOT used; every position is single, risk-sized and independently stopped.

Expert advisor · MT5 · v1.0 · Free

About Momentum Persistence System

Momentum Persistence System is an expert advisor (trading robot) for MetaTrader 5 based on ATR. It can size trades from your balance and risk percent. It has 11 settings, such as Magic, Measurement bars and Remeasure every bars. MQL source code included.

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

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

Settings

SettingDefaultWhat it does
Magic20261303Magic number for this system's own orders
Measurement bars500Bars of history scanned each remeasurement to build the run-length statistic
Remeasure every bars50Remeasure persistence length every N new bars
Min run bars2Minimum current run length required before a continuation entry is considered
Atr period14ATR period for stop/target distance
Atr stop multiple1.5Stop distance as a multiple of ATR
Atr target multiple2.5Take-profit distance as a multiple of ATR
Risk percent1.0Risk % of balance per trade
Slippage points5Slippage tolerance, in points
Max retries5Attempts per order 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 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: Momentum · Trend · Risk & Lot Size · ATR · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria