OPENSTRATS

Three-index low-volatility rotation 2.09×

Research

MT5 Strategy Tester results and a separate broker-bar comparison. The notes give the tested dates and quote coverage.

SYM GER40, SP500, US30TF H1TEST 2026-06-01 → 2026-10-31UPDATED VIEWS 0DOWNLOADS 0#volatility-targeting

BACKTESTS · 3

2 of 3
NET PROFIT · USD
-16,133
from 100,000 USD
RETURN
-16.1%
CAGR
-34.3%
0.4 yrs
PROFIT FACTOR
0.02
SHARPE
-1.60
MAX DD
-20.0%
equity, relative
RECOVERY
-0.78
TRADES
116
25.0% win

EQUITY · BALANCE (USD)

IDX_Regional_LowVol209 · SP500 H1 · quality 100% · drag to zoom, double-click to reset

MONTHLY RETURNS

% of balance at month start
YearJanFebMarAprMayJunJulAugSepOctNovDecYear
2026·····-0.7%-0.5%-3.5%-0.3%-11.9%··-16.1%

TRADE STATS

Gross profit261.17Gross loss-16,394.08
Expected payoff-139.08Total deals173
Long trades116 (25.0%)Short trades0 (0.0%)
Largest win58.81Largest loss-6,870.67
Average win9.01Average loss-188.44
Max consec. wins6Max consec. losses26
Balance DD max16,132.91 (16.1%)Equity DD max20,663.62 (20.0%)
Leverage1:100Brokerafx Markets Ltd
All report fields (46)
History Quality100%
Bars2517
Ticks603202
Symbols2
Total Net Profit-16 132.91
Balance Drawdown Absolute16 132.91
Equity Drawdown Absolute17 412.12
Gross Profit261.17
Balance Drawdown Maximal16 132.91 (16.13%)
Equity Drawdown Maximal20 663.62 (20.01%)
Gross Loss-16 394.08
Balance Drawdown Relative16.13% (16 132.91)
Equity Drawdown Relative20.01% (20 663.62)
Profit Factor0.02
Expected Payoff-139.08
Margin Level2341.71%
Recovery Factor-0.78
Sharpe Ratio-1.60
Z-Score-6.73 (99.74%)
AHPR0.9985 (-0.15%)
LR Correlation-0.91
OnTester result83867.09
GHPR0.9985 (-0.15%)
LR Standard Error1 958.94
Total Trades116
Short Trades (won %)0 (0.00%)
Long Trades (won %)116 (25.00%)
Total Deals173
Profit Trades (% of total)29 (25.00%)
Loss Trades (% of total)87 (75.00%)
Largest profit trade58.81
Largest loss trade-6 870.67
Average profit trade9.01
Average loss trade-188.44
Maximum consecutive wins ($)6 (44.08)
Maximum consecutive losses ($)26 (-8 043.38)
Maximal consecutive profit (count)102.97 (5)
Maximal consecutive loss (count)-8 043.38 (26)
Average consecutive wins4
Average consecutive losses10
Correlation (Profits,MFE)-0.93
Correlation (Profits,MAE)0.86
Correlation (MFE,MAE)-0.6246
Minimal position holding time23:00:00
Maximal position holding time1079:17:59
Average position holding time526:18:11

NOTES

At the start of each broker month rank GER40, SP500 and US30 by the annualized standard deviation of 63 previously completed daily log returns. Buy the least volatile market when at least two are eligible. Otherwise hold cash. The exposure input is 2.09 times equity. SP500 supplies the H1 tester clock.

The figures in this section are from the separate broker H1 bar model.

Each modeled interval starts with a fresh USD 100,000. Costs include 0.75 times the preceding quoted full spread per side, a two-basis-point spread fallback, a 0.0014% commission on closing notional and a 5% annual overnight financing allowance. The model rounds to broker lot steps. The hourly high/low estimate bounds simulated equity drawdown within available bars. Losses during missing quotes remain unobserved.

Exposure was selected retrospectively on the regional basket. The first monthly window begins in August 2012, when quotes start on August 5. Early H1 histories can contain only a daily print. The GER40 price-unit change in May 2026 can affect the later 63-day ranking. The two periods have separate capital and are disjoint.

Broker-bar window, inclusive Scope Modeled net USD Geometric return per month Hourly drawdown bound
2012-08-01 to 2025-06-30 covered155 $369,039.23 +1.002% 62.72%
2026-06-01 to 2026-10-31 downside5 −$15,091.64 -3.219% 19.45%

MT5 Strategy Tester results

Each test started with $100,000 in MT5. The statements include the 0.0014% exit commission schedule and the spreads and swaps recorded by the tester. M1 OHLC simulates the intraminute path from one-minute bars. Real-tick mode may generate ticks for missing or inconsistent intervals. OpenStrats draws its curves from realized deal balances. The attached CSVs include marked equity while trades were open.

The August 2012 to June 2025 figures above come from the broker-bar simulation. MT5 did not complete that window or the February 2016 to June 2025 window. The broker-bar download preserves the original monthly data.

  • IDX_Regional_LowVol209 · M1 OHLC · 2024-01-01 to 2025-06-30. +33,530.98 USD net, 36.70% maximum equity drawdown and 356 trades. 18 complete observed calendar months. MT5 history quality is 99%. The tester recorded 6,815 order error responses.
  • IDX_Regional_LowVol209 · M1 OHLC · 2026-06-01 to 2026-10-31. −16,132.91 USD net, 20.01% maximum equity drawdown and 116 trades. 5 complete observed calendar months. MT5 history quality is 100%. The tester recorded 1,898 order error responses.
  • IDX_Regional_LowVol209 · Real-tick mode · 2026-06-01 to 2026-10-31. −16,078.67 USD net, 19.90% maximum equity drawdown and 117 trades. 5 complete observed calendar months. MT5 history quality is 100% real ticks. The tester recorded 3,159 order error responses.
InputValueOptimise (start / step / stop)Section
TesterOnlytrue
AuditToken0
Exposure2.09
IDX_Regional_LowVol209.mq5306 lines · 11.6 KB · 2026-11-29 ↓ download
View source
#property strict
#property version "1.00"
#define DEFAULT_EXPOSURE 2.09
const string LockedAnchor="SP500";
const ulong LockedMagic=3627454416;
const bool MonthlyRebalance=true;
string LegNames[]={"GER40","SP500","US30"};
string MapNames[]={"GER40","SP500","US30"};
string MapSymbols[]={"GER40","SP500","US30"};
double LegWeights[]={1.0,1.0,1.0};
datetime ixSizedDate[];
double ixSizedWeight[],ixPendingWeight[];
// Weekly and intraday rules are absent. At the broker month's first quoted day,
// buy the least volatile third of distinct equity index CFDs, with stable declared-order ties.
bool SelectedWeight(const int id,const string sym,const datetime hour,double &weight)
{
   static datetime cached=0;
   static double allocation[];
   MqlDateTime t;
   if(!TimeToStruct(hour,t)) return false;
   t.hour=0; t.min=0; t.sec=0;
   const datetime decisionDay=StructToTime(t);
   t.day=1;
   const datetime period=StructToTime(t);
   if(cached!=period)
   {
      const int n=ArraySize(LegNames);
      ArrayResize(allocation,n); ArrayInitialize(allocation,0);
      double vols[];
      ArrayResize(vols,n);ArrayInitialize(vols,DBL_MAX);
      int eligible=0;
      for(int j=0;j<n;j++)
      {
         MqlRates r[];
         const int got=CopyRates(LegNames[j],PERIOD_D1,period-1,64,r);
         if(got<0 || !SeriesInfoInteger(LegNames[j],PERIOD_D1,SERIES_SYNCHRONIZED)) return false;
         if(got<64 || r[got-1].time>=period || decisionDay-r[got-1].time>7*86400) continue;
         double sum=0,sum2=0;
         for(int k=1;k<64;k++)
         {
            if(r[k].close<=0 || r[k-1].close<=0) return false;
            const double x=MathLog(r[k].close/r[k-1].close);
            sum+=x;sum2+=x*x;
         }
         vols[j]=MathSqrt(MathMax(0,(sum2-sum*sum/63.0)/62.0)*252.0); eligible++;
      }
      if(eligible>=2)
      {
         const int count=(eligible+2)/3;
         for(int j=0;j<count;j++)
         {
            const int best=ArrayMinimum(vols);
            if(best<0 || vols[best]==DBL_MAX) return false;
            allocation[best]=1.0/count;vols[best]=DBL_MAX;
         }
      }
      cached=period;
   }
   weight=allocation[id];return true;
}

// Shared MT5 execution for explicitly frozen, per-symbol H1-opening targets.
// The assembler declares LegNames, the maximum LegWeights, the
// broker symbol map, default exposure, and the SelectedWeight() callback.
#include <Trade/Trade.mqh>
input bool TesterOnly = true;
input ulong AuditToken = 0;
input double Exposure = DEFAULT_EXPOSURE;
CTrade dsTrade;
string dsSymbols[];
bool dsDone[],dsReady[];
int dsSides[];
double dsVolumes[];
datetime dsHour=0, dsWake=0;
double dsOpeningEquity=0;
bool dsFinished=false;
uint dsErrors=0;
int dsMonthlyFile=INVALID_HANDLE;
datetime dsMonthStart=0,dsNextMonth=0,dsLastTick=0,dsFirstMonthTick=0;
double dsLastMarkedEquity=0,dsLastMarkedBalance=0;

void DSWriteMonth(const bool finalRow,const double ending)
{
   if(dsMonthlyFile==INVALID_HANDLE || dsLastTick<=0) return;
   FileWrite(dsMonthlyFile,TimeToString(dsMonthStart,TIME_DATE),TimeToString(dsFirstMonthTick,TIME_DATE|TIME_SECONDS),
             TimeToString(dsLastTick,TIME_DATE|TIME_SECONDS),DoubleToString(dsLastMarkedEquity,2),
             DoubleToString(dsLastMarkedBalance,2),finalRow?DoubleToString(ending,2):"");
   FileFlush(dsMonthlyFile);
   PrintFormat("Research tester monthly equity %s %.2f",TimeToString(dsMonthStart,TIME_DATE),dsLastMarkedEquity);
}

void DSObserveMonth(const datetime now)
{
   if(dsMonthlyFile==INVALID_HANDLE) return;
   if(now>=dsNextMonth)
   {
      DSWriteMonth(false,0);
      MqlDateTime t;
      if(!TimeToStruct(now,t)) return;
      t.day=1; t.hour=0; t.min=0; t.sec=0;
      dsMonthStart=StructToTime(t); dsFirstMonthTick=now;
      if(t.mon==12) { t.year++; t.mon=1; } else t.mon++;
      dsNextMonth=StructToTime(t);
   }
   dsLastTick=now;
   dsLastMarkedEquity=AccountInfoDouble(ACCOUNT_EQUITY);
   dsLastMarkedBalance=AccountInfoDouble(ACCOUNT_BALANCE);
}

string DSBrokerSymbol(const string canonical)
{
   for(int i=0;i<ArraySize(MapNames);i++)
      if(MapNames[i]==canonical) return MapSymbols[i];
   return "";
}

bool DSAllowed(const string canonical)
{
   for(int i=0;i<ArraySize(LegNames);i++) if(canonical==LegNames[i]) return true;
   return false;
}

bool DSSized(const string sym,const int side,const MqlTick &tick,const double allocation,double &lots)
{
   lots=0;
   if(side==0) return true;
   const double price=(tick.bid+tick.ask)/2;
   const double contract=SymbolInfoDouble(sym,SYMBOL_TRADE_CONTRACT_SIZE);
   const double step=SymbolInfoDouble(sym,SYMBOL_VOLUME_STEP);
   if(price<=0 || contract<=0 || step<=0 || dsOpeningEquity<=0) return false;
   const int digits=(int)SymbolInfoInteger(sym,SYMBOL_DIGITS);
   const double ref=NormalizeDouble(price*1.01,digits);
   double movement=0, margin=0;
   const ENUM_ORDER_TYPE sideType=side>0?ORDER_TYPE_BUY:ORDER_TYPE_SELL;
   if(ref<=price || !OrderCalcProfit(ORDER_TYPE_BUY,sym,1.0,price,ref,movement) || movement<=0 ||
      !OrderCalcMargin(sideType,sym,1.0,price,margin) || margin<=0)
   {
      static int failures=0;
      failures++;
      if(failures<=3 || failures%10000==0) PrintFormat("Index USD sensitivity or margin unavailable %s events=%d",sym,failures);
      return false;
   }
   const double notional=movement*price/(ref-price);
   // Reserve at least 20% of account equity even if the contract margin rate changes.
   double raw=MathMin(dsOpeningEquity*Exposure*allocation/notional,0.80*dsOpeningEquity*allocation/margin);
   const double bound=SymbolInfoDouble(sym,SYMBOL_VOLUME_LIMIT);
   if(bound>0) raw=MathMin(raw,bound);
   lots=NormalizeDouble(MathFloor(raw/step+1e-10)*step,8);
   if(lots<SymbolInfoDouble(sym,SYMBOL_VOLUME_MIN)) lots=0;
   return true;
}

bool DSFilled(const bool sent,const string symbol)
{
   const uint rc=dsTrade.ResultRetcode();
   if(sent && (rc==TRADE_RETCODE_DONE || rc==TRADE_RETCODE_DONE_PARTIAL)) return true;
   dsErrors++;
   if(dsErrors<=8 || dsErrors%500==0)
      PrintFormat("Research execution %s: %u %s (events %u)",symbol,rc,dsTrade.ResultRetcodeDescription(),dsErrors);
   return false;
}

bool DSAlign(const string sym,int side,const double lots)
{
   // Return true only after actual position volume has been confirmed.
   if(lots==0) side=0;
   const bool hedge=AccountInfoInteger(ACCOUNT_MARGIN_MODE)==ACCOUNT_MARGIN_MODE_RETAIL_HEDGING;
   double owned=0;
   ulong reduceTicket=0;
   double reduceLots=0;
   if(!dsTrade.SetTypeFillingBySymbol(sym)) return false;
   for(int i=PositionsTotal()-1;i>=0;i--)
   {
      const ulong ticket=PositionGetTicket(i);
      if(ticket==0 || PositionGetString(POSITION_SYMBOL)!=sym) continue;
      if((ulong)PositionGetInteger(POSITION_MAGIC)!=LockedMagic)
      {
         if(!hedge) return true; // Shared net position cannot be attributed safely.
         continue;
      }
      const int held=PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY?1:-1;
      const double v=PositionGetDouble(POSITION_VOLUME);
      if(held!=side)
      {
         DSFilled(dsTrade.PositionClose(ticket),sym);
         return false;
      }
      owned+=v;
      if(v>reduceLots) { reduceTicket=ticket; reduceLots=v; }
   }
   const double step=SymbolInfoDouble(sym,SYMBOL_VOLUME_STEP);
   const double maximum=SymbolInfoDouble(sym,SYMBOL_VOLUME_MAX);
   const double minimum=SymbolInfoDouble(sym,SYMBOL_VOLUME_MIN);
   if(step<=0 || maximum<=0 || minimum<=0) return false;
   const double diff=NormalizeDouble(lots-owned,8);
   if(MathAbs(diff)<minimum-step*0.01) return true;
   double qty=MathMin(MathAbs(diff),maximum);
   qty=NormalizeDouble(MathFloor(qty/step+1e-8)*step,8);
   if(qty<minimum) return true;
   if(hedge && diff<0)
   {
      if(qty>=reduceLots-step*0.01)
         DSFilled(dsTrade.PositionClose(reduceTicket),sym);
      else
         DSFilled(dsTrade.PositionClosePartial(reduceTicket,qty),sym);
      return false;
   }
   const bool buy=(side>0)==(diff>0);
   DSFilled(buy?dsTrade.Buy(qty,sym):dsTrade.Sell(qty,sym),sym);
   return false;
}

int OnInit()
{
   if(!MQLInfoInteger(MQL_TESTER) || !TesterOnly || AccountInfoString(ACCOUNT_CURRENCY)!="USD") return INIT_FAILED;
   if((TesterOnly && !MQLInfoInteger(MQL_TESTER)) || Exposure<=0 || !MathIsValidNumber(Exposure)) return INIT_PARAMETERS_INCORRECT;
   const int n=ArraySize(LegNames);
   if(n==0 || n!=ArraySize(LegWeights) || ArraySize(MapNames)!=ArraySize(MapSymbols)) return INIT_PARAMETERS_INCORRECT;
   ArrayResize(dsSymbols,n); ArrayResize(dsDone,n); ArrayResize(dsReady,n);
   ArrayResize(ixSizedDate,n); ArrayResize(ixSizedWeight,n); ArrayResize(ixPendingWeight,n);
   ArrayInitialize(ixSizedDate,0); ArrayInitialize(ixSizedWeight,0);
   ArrayResize(dsSides,n); ArrayResize(dsVolumes,n);
   double total=0;
   for(int i=0;i<n;i++)
   {
      dsSymbols[i]=DSBrokerSymbol(LegNames[i]);
      if(!DSAllowed(LegNames[i]) || dsSymbols[i]=="" || LegWeights[i]<=0 || !SymbolSelect(dsSymbols[i],true)) return INIT_PARAMETERS_INCORRECT;
      total+=LegWeights[i];
   }
   if(total<=0 || _Symbol!=LockedAnchor) return INIT_PARAMETERS_INCORRECT;
   if(MQLInfoInteger(MQL_TESTER) && AuditToken>0)
   {
      const string fn="AFXResearch\\monthly-"+IntegerToString((long)AuditToken)+".csv";
      dsMonthlyFile=FileOpen(fn,FILE_WRITE|FILE_CSV|FILE_ANSI|FILE_COMMON,',');
      if(dsMonthlyFile==INVALID_HANDLE) { PrintFormat("Research tester monthly file error %d",GetLastError()); return INIT_FAILED; }
      FileWrite(dsMonthlyFile,"month","first_tick","last_tick","marked_equity","marked_balance","final_tester_equity");
   }
   dsTrade.SetExpertMagicNumber(LockedMagic);
   dsTrade.SetAsyncMode(false);
   return INIT_SUCCEEDED;
}

void OnTick()
{
   const datetime now=TimeCurrent();
   DSObserveMonth(now);
   const datetime hour=(datetime)(((long)now/3600)*3600);
   if(hour!=dsHour)
   {
      dsHour=hour;
      dsWake=0;
      dsFinished=false;
      dsOpeningEquity=AccountInfoDouble(ACCOUNT_EQUITY);
      ArrayInitialize(dsDone,false);
      ArrayInitialize(dsReady,false);
   }
   if(dsFinished || now<dsWake) return;
   bool all=true;
   for(int i=0;i<ArraySize(dsSymbols);i++)
   {
      if(dsDone[i]) continue;
      MqlTick tick;
      const string sym=dsSymbols[i];
      if(!SymbolInfoTick(sym,tick) || tick.time<hour || tick.time>now || tick.bid<=0 ||
         tick.ask<tick.bid || iTime(sym,PERIOD_H1,0)!=hour) { all=false; continue; }
      if(!dsReady[i])
      {
         double weight=0;
         if(!SelectedWeight(i,sym,hour,weight) || !MathIsValidNumber(weight) ||
            MathAbs(weight)>LegWeights[i]+1e-8) { all=false; continue; }
         const int side=weight>0?1:(weight<0?-1:0);
         // Research weights rebalance at first executable bar per broker date or weight change.
         const datetime today=hour-hour%86400;
         if(ixSizedDate[i]==today && MathAbs(weight-ixSizedWeight[i])<1.e-9)
         { dsDone[i]=true; continue; }
         if(!DSSized(sym,side,tick,MathAbs(weight),dsVolumes[i])) { all=false; continue; }
         ixPendingWeight[i]=weight;
         dsSides[i]=side;
         dsReady[i]=true;
      }
      dsDone[i]=DSAlign(sym,dsSides[i],dsVolumes[i]);
      if(dsDone[i]) { ixSizedDate[i]=hour-hour%86400; ixSizedWeight[i]=ixPendingWeight[i]; }
      if(!dsDone[i]) all=false;
   }
   if(dsMonthlyFile!=INVALID_HANDLE)
   {
      dsLastMarkedEquity=AccountInfoDouble(ACCOUNT_EQUITY);
      dsLastMarkedBalance=AccountInfoDouble(ACCOUNT_BALANCE);
   }
   dsFinished=all;
   dsWake=now+(now-hour<30?1:30);
}

double OnTester()
{
   const double ending=TesterStatistics(STAT_INITIAL_DEPOSIT)+TesterStatistics(STAT_PROFIT);
   DSWriteMonth(true,ending);
   return ending;
}

void OnDeinit(const int reason)
{
   if(dsMonthlyFile!=INVALID_HANDLE) FileClose(dsMonthlyFile);
   PrintFormat("Research execution ended, trade error responses=%u.",dsErrors);
}

FILES

every upload is kept
TypeFileNotesSizeDLSHA-256Uploaded
FILEIDX_Regional_LowVol209_downside5_MT5_monthly_equity.csv latestNative monthly MT5 equity marks for 2026-06-01 through 2026-10-31, Real-tick mode. Includes observed first and last quotes and full-month eligibility.741 B06c88f80542aa2026-11-29 10:44
BACKTESTIDX_Regional_LowVol209_downside5_2026-06-01_to_2026-11-01_MT5.html latestReal-tick mode. 2026-06-01 through 2026-10-31. SP500 H1, $100,000 starting capital, 1:100 account leverage and 100 ms delay. The statement booked USD 8.95 in exit commission at the supplied 0.0014% schedule, with USD -5,152.65 swap. Native month-end marks span 2026.06.01 00:00:00 to 2026.10.30 20:59:30 broker time. 4 original images and all deals are included. Orders table omitted. MT5 may generate ticks in intervals with missing or inconsistent real ticks. The tester journal recorded 3159 order error responses.132.2 KB08d40be5703932026-11-29 10:44
FILEIDX_Regional_LowVol209_covered18m1_MT5_monthly_equity.csv latestNative monthly MT5 equity marks for 2024-01-01 through 2025-06-30, M1 OHLC. Includes observed first and last quotes and full-month eligibility.2.2 KB05b126c9b8db32026-11-29 09:44
BACKTESTIDX_Regional_LowVol209_covered18m1_2024-01-01_to_2025-07-01_MT5.html latestM1 OHLC. 2024-01-01 through 2025-06-30. SP500 H1, $100,000 starting capital, 1:100 account leverage and 100 ms delay. The statement booked USD 31.69 in exit commission at the supplied 0.0014% schedule, with USD -24,503.83 swap. Native month-end marks span 2024.01.01 22:00:00 to 2025.06.30 23:59:59 broker time. 4 original images and all deals are included. Orders table omitted. M1 OHLC uses four simulated prices per minute. The tester journal recorded 6815 order error responses.215.5 KB0a34fae7b0d902026-11-29 09:44
FILEIDX_Regional_LowVol209_downside5m1_MT5_monthly_equity.csv latestNative monthly MT5 equity marks for 2026-06-01 through 2026-10-31, M1 OHLC. Includes observed first and last quotes and full-month eligibility.741 B01edaff25e62a2026-11-29 08:26
BACKTESTIDX_Regional_LowVol209_downside5m1_2026-06-01_to_2026-11-01_MT5.html latestM1 OHLC. 2026-06-01 through 2026-10-31. SP500 H1, $100,000 starting capital, 1:100 account leverage and 100 ms delay. The statement booked USD 8.94 in exit commission at the supplied 0.0014% schedule, with USD -5,122.27 swap. Native month-end marks span 2026.06.01 00:00:00 to 2026.10.30 20:59:59 broker time. 4 original images and all deals are included. Orders table omitted. M1 OHLC uses four simulated prices per minute. The tester journal recorded 1898 order error responses.131.8 KB0dda43c8298922026-11-29 08:26
FILEIDX_Regional_LowVol209_broker_bar_monthly_equity.csv latestBroker-bar month-end ledger for the independently funded, native-plan-aligned intervals. Dollar figures are modeled. Blank intervals have no valuation.13.5 KB0715f31236a872026-11-29 01:21
FILEIDX_Regional_LowVol209_broker_bar_windows.csv latestModeled windows, independently reset USD equity, estimated financing, commission, execution friction and drawdown bounds.605 B0349a5cc7ea452026-11-29 01:21
PARAMSIDX_Regional_LowVol209.set latestReproduction preset for SP500 H1 at 2.09× exposure. The optional internal monthly recorder is disabled.94 B084b58b72981e2026-11-29 01:21
SOURCEIDX_Regional_LowVol209.mq5 latestExact MQL5 source verified against the successful MetaEditor build. This source runs in Strategy Tester.11.6 KB0533f212b7b5c2026-11-29 01:21

MORE INDICES STRATEGIES

all Indices →