Loading…

Triple Timeframe Alignment System

The classic three-timeframe agreement idea is simple to state and easy to implement wrong: read a fast/slow moving-average relationship on three timeframes, and only trade when all three agree. The naive version breaks by reading shift 0 - the currently-forming bar - on the higher timeframes, which repaints. A still-forming H4 bar's close keeps changing as the chart's own M15 bars close underneath it, so a signal built on that value can flicker in and out of existence within the same H4 candle, and a backtest run on repainted values will show trades that could never actually have fired live. This implementation reads every one of the three timeframes - including the chart's own - at explicit shift 1, the last fully closed bar of that series, with no exceptions. A trade is only evaluated once, on the bar the chart timeframe itself closes, so an intrabar wobble in a higher timeframe's still-forming bar can never retroactively change a decision that has already been made. Trend on each timeframe is judged the same simple way: a fast EMA above a slow EMA is bullish, below is bearish. All three bullish opens a long, all three bearish opens a short. Losing agreement while a position is open closes it - this system trades the agreement itself, not a fixed holding period. Notes and limitations Only one position is held at a time and only on the chart's own symbol - this is a single-instrument system, not a portfolio scanner. The trend filter is a plain EMA cross on each timeframe, not a more sophisticated regime classifier; it will whipsaw during ranging conditions like any moving-average system, particularly if the two higher timeframes are close together in duration. Alignment loss closes the position at market on the next tick after the losing bar closes, not intrabar, consistent with the same closed-bar-only evaluation used for entries.

Expert advisor · MT4 · v1.0 · Free

About Triple Timeframe Alignment System

Triple Timeframe Alignment System is an expert advisor (trading robot) for MetaTrader 4 based on Moving Average and ATR. It can size trades from your balance and risk percent. It has 14 settings, such as Fast period, Slow period and Mid tf. MQL source code included.

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

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

Settings

SettingDefaultWhat it does
Fast period8Fast EMA period, applied identically on all three timeframes
Slow period21Slow EMA period, applied identically on all three timeframes
Mid tfPERIOD_H1Middle confirming timeframe
High tfPERIOD_H4Highest confirming timeframe
Atr mult sl2.0Stop loss distance, multiples of chart-timeframe ATR
Atr mult tp3.0Take profit distance, multiples of chart-timeframe ATR
Atr period14ATR period used for the stop/target distance
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
Magic number33101Magic 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: Trend · Risk & Lot Size · Moving Average · ATR · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria