FX daily Hodrick–Prescott trend
ResearchCompares five-day and twenty-day moving averages of causally filtered daily closes. MT5 fills with separately estimated exit commission.
EQUITY · BALANCE (USD)
FX_HPTrend · EURGBP Daily · quality 99% real ticks · drag to zoom, double-click to resetMONTHLY RETURNS
% of balance at month start| Year | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec | Year |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2020 | -0.2% | · | -0.6% | 0.3% | -0.1% | -0.2% | -0.9% | -0.1% | -0.7% | -0.7% | · | 0.2% | -2.9% |
| 2021 | · | · | 1.7% | -0.8% | -0.1% | · | 0.4% | -0.2% | -0.5% | -0.6% | -0.8% | -0.9% | -1.8% |
| 2022 | 0.3% | -0.2% | -0.3% | -0.5% | 0.2% | -0.3% | -0.5% | 0.1% | · | 0.9% | -1.0% | -0.4% | -1.6% |
| 2023 | 0.1% | -1.1% | -0.4% | -0.3% | -0.4% | 0.4% | -0.9% | -0.4% | -0.1% | -0.2% | -0.2% | -0.0% | -3.7% |
| 2024 | -0.3% | 0.2% | -0.3% | -0.5% | -0.8% | · | -0.3% | -0.3% | · | 0.2% | -0.5% | 0.2% | -2.4% |
| 2025 | · | 0.1% | -0.4% | -1.1% | · | 0.2% | · | 0.6% | -0.1% | -0.4% | -0.1% | -0.2% | -1.4% |
| 2026 | 0.1% | -0.5% | -0.3% | -0.1% | -0.3% | -0.2% | 0.2% | -0.0% | -0.1% | 0.2% | · | · | -1.2% |
TRADE STATS
| Gross profit | 7,197.72 | Gross loss | -21,362.21 |
| Expected payoff | -133.63 | Total deals | 212 |
| Long trades | 53 (18.9%) | Short trades | 53 (32.1%) |
| Largest win | 1,660.42 | Largest loss | -806.59 |
| Average win | 266.58 | Average loss | -270.41 |
| Max consec. wins | 3 | Max consec. losses | 9 |
| Balance DD max | 14,626.88 (14.6%) | Equity DD max | 16,337.47 (16.1%) |
| Leverage | 1:100 | Broker | afx Markets Ltd |
All report fields (46)
| History Quality | 99% real ticks |
| Bars | 2136 |
| Ticks | 155359110 |
| Symbols | 1 |
| Total Net Profit | -14 164.49 |
| Balance Drawdown Absolute | 14 626.88 |
| Equity Drawdown Absolute | 14 637.37 |
| Gross Profit | 7 197.72 |
| Balance Drawdown Maximal | 14 626.88 (14.63%) |
| Equity Drawdown Maximal | 16 337.47 (16.06%) |
| Gross Loss | -21 362.21 |
| Balance Drawdown Relative | 14.63% (14 626.88) |
| Equity Drawdown Relative | 16.06% (16 337.47) |
| Profit Factor | 0.34 |
| Expected Payoff | -133.63 |
| Margin Level | 33219.03% |
| Recovery Factor | -0.87 |
| Sharpe Ratio | -1.05 |
| Z-Score | -0.19 (15.07%) |
| AHPR | 0.9986 (-0.14%) |
| LR Correlation | -0.99 |
| OnTester result | 0 |
| GHPR | 0.9986 (-0.14%) |
| LR Standard Error | 778.89 |
| Total Trades | 106 |
| Short Trades (won %) | 53 (32.08%) |
| Long Trades (won %) | 53 (18.87%) |
| Total Deals | 212 |
| Profit Trades (% of total) | 27 (25.47%) |
| Loss Trades (% of total) | 79 (74.53%) |
| Largest profit trade | 1 660.42 |
| Largest loss trade | -806.59 |
| Average profit trade | 266.58 |
| Average loss trade | -270.41 |
| Maximum consecutive wins ($) | 3 (1 862.75) |
| Maximum consecutive losses ($) | 9 (-3 093.62) |
| Maximal consecutive profit (count) | 1 862.75 (3) |
| Maximal consecutive loss (count) | -3 093.62 (9) |
| Average consecutive wins | 1 |
| Average consecutive losses | 4 |
| Correlation (Profits,MFE) | 0.69 |
| Correlation (Profits,MAE) | 0.75 |
| Correlation (MFE,MAE) | 0.2800 |
| Minimal position holding time | 73:57:50 |
| Maximal position holding time | 1510:02:10 |
| Average position holding time | 403:24:20 |
NOTES
Compares five-day and twenty-day moving averages of causally filtered daily closes. Each endpoint uses the latest 120 observations and a smoothing parameter of 1,600. The tested notional is 0.30 times equity.
HPTrend, Jan 2020–Oct 2026. Fixed-fill exit-fee estimates give +$3,967.14 on $100,000, +0.047% compounded monthly. The original MT5 statement booked +$4,004.72 with zero exit commission. Estimated maximum equity drawdown bounds are 4.04% to 4.08%.
HPTrend, Jan 2025–Oct 2026. Fixed-fill exit-fee estimates give +$3,284.88 on $100,000, +0.147% compounded monthly. The original MT5 statement booked +$3,294.89 with zero exit commission. Estimated maximum equity drawdown bounds are 1.89% to 1.90%.
Six FX pairs were tested. The attached calendar windows overlap.
PARAMETERS
↓ FX_HPTrend.set| Input | Value | Optimise (start / step / stop) | Section |
|---|---|---|---|
| Exposure | 0.30 | ||
| TesterOnly | true |
View source
// Causal endpoint HP crossover, adapted from Kakushadze & Serur, section 8.1.
// Fixed daily research horizons: 120 observations, HP lambda 1600, SMA 5/20.
// Each endpoint is estimated using a window ending at that historical close.
#property strict
#property version "1.00"
#include <Trade/Trade.mqh>
#define HP_WINDOW 120
#define FAST 5
#define SLOW 20
#define OBSERVATIONS (HP_WINDOW + SLOW - 1)
const double LAMBDA = 1600.0;
const ulong MAGIC = 324786501;
input double Exposure = 0.30; // Entry notional as a multiple of equity
input bool TesterOnly = true;
CTrade trade;
double weights[HP_WINDOW];
datetime signalBar = 0, completedBar = 0, nextAttempt = 0;
int target = 0;
bool IsMajorCurrency(const string currency)
{
return StringFind("|USD|EUR|JPY|GBP|CHF|CAD|AUD|NZD|", "|" + currency + "|") >= 0;
}
void BuildEndpointWeights()
{
// Solve (I + lambda D'D)w = e_last once. D is the second-difference matrix.
// The symmetric system has two nonzero subdiagonals, as does its Cholesky factor.
double diag[HP_WINDOW], sub1[HP_WINDOW], sub2[HP_WINDOW], rhs[HP_WINDOW];
for(int i = 0; i < HP_WINDOW; i++)
{
const int dist = (i < HP_WINDOW-1-i ? i : HP_WINDOW-1-i);
const double a = 1 + LAMBDA * (dist == 0 ? 1 : dist == 1 ? 5 : 6);
sub2[i] = i > 1 ? LAMBDA / diag[i-2] : 0;
sub1[i] = 0;
if(i > 0)
{
const double b = (i == 1 || i == HP_WINDOW-1 ? -2 : -4) * LAMBDA;
sub1[i] = (b - sub2[i] * sub1[i-1]) / diag[i-1];
}
diag[i] = MathSqrt(a - sub1[i]*sub1[i] - sub2[i]*sub2[i]);
rhs[i] = i == HP_WINDOW-1 ? 1.0 / diag[i] : 0;
}
for(int i = HP_WINDOW-1; i >= 0; i--)
{
double v = rhs[i];
if(i+1 < HP_WINDOW) v -= sub1[i+1] * weights[i+1];
if(i+2 < HP_WINDOW) v -= sub2[i+2] * weights[i+2];
weights[i] = v / diag[i];
}
}
bool Signal(int &side)
{
double prices[OBSERVATIONS];
if(CopyClose(_Symbol, PERIOD_D1, 1, OBSERVATIONS, prices) != OBSERVATIONS)
return false;
double slowSum = 0, fastSum = 0;
for(int end = 0; end < SLOW; end++)
{
double endpoint = 0;
for(int j = 0; j < HP_WINDOW; j++)
endpoint += weights[j] * prices[end+j];
slowSum += endpoint;
if(end >= SLOW - FAST) fastSum += endpoint;
}
const double delta = fastSum/FAST - slowSum/SLOW;
side = delta > 0 ? 1 : delta < 0 ? -1 : 0;
return true;
}
bool EntryLots(const double price, double &lots)
{
const string account = AccountInfoString(ACCOUNT_CURRENCY);
const double contract = SymbolInfoDouble(_Symbol, SYMBOL_TRADE_CONTRACT_SIZE);
double notional = contract;
if(SymbolInfoString(_Symbol, SYMBOL_CURRENCY_BASE) != account)
{
if(SymbolInfoString(_Symbol, SYMBOL_CURRENCY_PROFIT) == account)
notional = contract * price;
else
{
// Translate one lot's quote-currency notional into account currency.
double profit = 0;
if(!OrderCalcProfit(ORDER_TYPE_BUY, _Symbol, 1, price, price*1.01, profit))
return false;
notional = MathAbs(profit) * 100;
}
}
const double step = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);
if(notional <= 0 || step <= 0) return false;
const double desired = AccountInfoDouble(ACCOUNT_EQUITY) * Exposure / notional;
lots = NormalizeDouble(MathFloor(MathMin(desired, SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX))/step + 1e-10) * step, 8);
if(lots < SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN)) lots = 0;
return true;
}
bool Filled(const bool sent)
{
if(sent && trade.ResultRetcode() == TRADE_RETCODE_DONE) return true;
PrintFormat("HP trade retry: %u %s", trade.ResultRetcode(), trade.ResultRetcodeDescription());
return false;
}
bool AlignPosition(const int side)
{
// Re-read current state on retry; never close another strategy's position.
bool holding = false;
for(int i = PositionsTotal() - 1; i >= 0; i--)
{
const ulong ticket = PositionGetTicket(i);
if(ticket == 0 || PositionGetString(POSITION_SYMBOL) != _Symbol) continue;
if((ulong)PositionGetInteger(POSITION_MAGIC) != MAGIC) return true;
const int direction = PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY ? 1 : -1;
if(direction == side) holding = true;
else if(!Filled(trade.PositionClose(ticket))) return false;
}
if(holding || side == 0) return true;
MqlTick tick;
if(!SymbolInfoTick(_Symbol, tick) || tick.bid <= 0 || tick.ask <= 0) return false;
double lots = 0;
if(!EntryLots(side > 0 ? tick.ask : tick.bid, lots)) return false;
if(lots == 0) return true;
return Filled(side > 0 ? trade.Buy(lots, _Symbol) : trade.Sell(lots, _Symbol));
}
int OnInit()
{
if(TesterOnly && !MQLInfoInteger(MQL_TESTER))
{
Print("HP research EA requires Strategy Tester with default settings.");
return INIT_FAILED;
}
if(Exposure <= 0 || Exposure > 1 ||
!IsMajorCurrency(SymbolInfoString(_Symbol, SYMBOL_CURRENCY_BASE)) ||
!IsMajorCurrency(SymbolInfoString(_Symbol, SYMBOL_CURRENCY_PROFIT)))
return INIT_PARAMETERS_INCORRECT;
trade.SetExpertMagicNumber(MAGIC);
if(!trade.SetTypeFillingBySymbol(_Symbol)) return INIT_FAILED;
BuildEndpointWeights();
return INIT_SUCCEEDED;
}
void OnTick()
{
const datetime bar = iTime(_Symbol, PERIOD_D1, 0);
if(bar <= 0 || bar == completedBar || TimeCurrent() < nextAttempt) return;
nextAttempt = TimeCurrent() + 60;
if(signalBar != bar)
{
if(!Signal(target)) return;
signalBar = bar;
}
if(AlignPosition(target)) completedBar = bar;
}
FILES
every upload is kept| Type | File | Notes | Size | DL | SHA-256 | Uploaded |
|---|---|---|---|---|---|---|
| BACKTEST | FX_HPTrend_GBPUSD_2025-01-01_2026-11-01_holdout_MT5.html latest | real-tick mode. 2025-01-01 through 2026-10-31. MT5 booked $-4,103.34 with zero commission. The fixed-fill replay of the 0.0014% exit fee estimates $-4,113.76 net without resizing. Every deal and 4 original chart images are included. Orders table omitted to reduce file size. | 115.0 KB | 0 | 799a24dac3a5 | 2026-11-29 08:14 |
| BACKTEST | FX_HPTrend_GBPUSD_2020-01-01_2026-11-01_full_MT5.html latest | real-tick mode. 2020-01-01 through 2026-10-31. MT5 booked $-2,073.51 with zero commission. The fixed-fill replay of the 0.0014% exit fee estimates $-2,110.61 net without resizing. Every deal and 4 original chart images are included. Orders table omitted to reduce file size. | 154.7 KB | 0 | 16e159862193 | 2026-11-29 08:14 |
| BACKTEST | FX_HPTrend_AUDUSD_2025-01-01_2026-11-01_holdout_MT5.html latest | real-tick mode. 2025-01-01 through 2026-10-31. MT5 booked $-2,833.54 with zero commission. The fixed-fill replay of the 0.0014% exit fee estimates $-2,845.58 net without resizing. Every deal and 4 original chart images are included. Orders table omitted to reduce file size. | 120.0 KB | 0 | 4c9ef351562b | 2026-11-29 08:14 |
| BACKTEST | FX_HPTrend_AUDUSD_2020-01-01_2026-11-01_full_MT5.html latest | real-tick mode. 2020-01-01 through 2026-10-31. MT5 booked $7,586.73 with zero commission. The fixed-fill replay of the 0.0014% exit fee estimates $7,544.92 net without resizing. Every deal and 4 original chart images are included. Orders table omitted to reduce file size. | 152.0 KB | 0 | 3a81e7fe2934 | 2026-11-29 08:14 |
| BACKTEST | FX_HPTrend_USDJPY_2025-01-01_2026-11-01_holdout_MT5.html latest | real-tick mode. 2025-01-01 through 2026-10-31. MT5 booked $-4,131.32 with zero commission. The fixed-fill replay of the 0.0014% exit fee estimates $-4,142.05 net without resizing. Every deal and 4 original chart images are included. Orders table omitted to reduce file size. | 119.4 KB | 0 | 3a54323ca903 | 2026-11-29 08:14 |
| BACKTEST | FX_HPTrend_USDJPY_2020-01-01_2026-11-01_full_MT5.html latest | real-tick mode. 2020-01-01 through 2026-10-31. MT5 booked $5,666.55 with zero commission. The fixed-fill replay of the 0.0014% exit fee estimates $5,630.41 net without resizing. Every deal and 4 original chart images are included. Orders table omitted to reduce file size. | 148.3 KB | 0 | 9a54cabaeb42 | 2026-11-29 08:14 |
| BACKTEST | FX_HPTrend_EURGBP_2025-01-01_2026-11-01_holdout_MT5.html latest | real-tick mode. 2025-01-01 through 2026-10-31. MT5 booked $-2,504.73 with zero commission. The fixed-fill replay of the 0.0014% exit fee estimates $-2,516.93 net without resizing. Every deal and 4 original chart images are included. Orders table omitted to reduce file size. | 116.1 KB | 0 | 532a0571573a | 2026-11-29 08:14 |
| BACKTEST | FX_HPTrend_EURGBP_2020-01-01_2026-11-01_full_MT5.html latest | real-tick mode. 2020-01-01 through 2026-10-31. MT5 booked $-14,164.49 with zero commission. The fixed-fill replay of the 0.0014% exit fee estimates $-14,204.58 net without resizing. Every deal and 4 original chart images are included. Orders table omitted to reduce file size. | 156.8 KB | 0 | 9b04b9fe26d1 | 2026-11-29 08:14 |
| BACKTEST | FX_HPTrend_GBPJPY_2025-01-01_2026-11-01_holdout_MT5.html latest | real-tick mode. 2025-01-01 through 2026-10-31. MT5 booked $-7,365.72 with zero commission. The fixed-fill replay of the 0.0014% exit fee estimates $-7,377.93 net without resizing. Every deal and 4 original chart images are included. Orders table omitted to reduce file size. | 117.5 KB | 0 | f7492d270cb7 | 2026-11-29 08:14 |
| BACKTEST | FX_HPTrend_GBPJPY_2020-01-01_2026-11-01_full_MT5.html latest | real-tick mode. 2020-01-01 through 2026-10-31. MT5 booked $-9,824.24 with zero commission. The fixed-fill replay of the 0.0014% exit fee estimates $-9,862.88 net without resizing. Every deal and 4 original chart images are included. Orders table omitted to reduce file size. | 161.1 KB | 0 | 5faba783a975 | 2026-11-29 08:14 |
| BACKTEST | FX_HPTrend_EURUSD_2020-01-01_to_2025-01-01_early.html latest | FX_HPTrend on EURUSD, Jan 2020–Dec 2024. The original MT5 statement booked +$738.12 with zero exit commission. Repricing the same fills for the 0.0014% exit fee gives +$710.19. Daily host, MT5 real-tick mode. Includes native settings, results and every deal. Order-request rows are omitted. | 143.1 KB | 0 | c89ffd53b097 | 2026-11-29 01:22 |
| BACKTEST | FX_HPTrend_EURUSD_2025-01-01_to_2026-11-01_holdout.html latest | FX_HPTrend on EURUSD, Jan 2025–Oct 2026. The original MT5 statement booked +$3,294.89 with zero exit commission. Repricing the same fills for the 0.0014% exit fee gives +$3,284.88. Daily host, MT5 real-tick mode. Includes native settings, results and every deal. Order-request rows are omitted. | 116.0 KB | 0 | 8af8603dfa3d | 2026-11-29 01:22 |
| BACKTEST | FX_HPTrend_EURUSD_2020-01-01_to_2026-11-01_full.html latest | FX_HPTrend on EURUSD, Jan 2020–Oct 2026. The original MT5 statement booked +$4,004.72 with zero exit commission. Repricing the same fills for the 0.0014% exit fee gives +$3,967.14. Daily host, MT5 real-tick mode. Includes native settings, results and every deal. Order-request rows are omitted. | 156.5 KB | 0 | e31e7a36fc3c | 2026-11-29 01:22 |
| FILE | hp-trend-test-windows.csv latest | All measured windows, separately reported by source, size, instrument, tick model and commission treatment. Native P&L and fixed-fill fee estimates have separate columns. | 6.1 KB | 0 | b76c575b0eed | 2026-11-29 01:22 |
| PARAMS | FX_HPTrend.set latest | Test inputs from the matching source. The public preset uses tester mode and a neutral journal token where supported. | 66 B | 0 | cb862bfc1b5c | 2026-11-29 01:22 |
| SOURCE | FX_HPTrend.mq5 latest | Original MQL5 source, matched to the frozen SHA-256. | 5.5 KB | 0 | fa9e5247c339 | 2026-11-29 01:22 |