OPENSTRATS

Germany 40 weekly volatility target 1.00× | native losses

Research

Both complete MT5 statements lost money. The earlier 48-month model validation gained $3,590.81 with a 23.36% drawdown bound.

SYM GER40TF H1TEST 2012-09-01 → 2026-10-31UPDATED VIEWS 1DOWNLOADS 0#volatility-targeting

BACKTESTS · 2

1 of 2
NET PROFIT · USD
-54,207
from 100,000 USD
RETURN
-54.2%
CAGR
-5.4%
14.2 yrs
PROFIT FACTOR
0.52
SHARPE
-0.45
MAX DD
-62.7%
equity, relative
RECOVERY
-0.72
TRADES
801
51.6% win

EQUITY · BALANCE (USD)

IDX_GER40_Vol100 · GER40 H1 · quality 36% real ticks · drag to zoom, double-click to reset

MONTHLY RETURNS

% of balance at month start
YearJanFebMarAprMayJunJulAugSepOctNovDecYear
2012········0.0%··0.0%0.0%
20130.4%-0.2%0.0%-0.5%0.0%-1.9%-0.0%-0.0%0.0%0.1%0.0%2.1%+0.1%
20142.1%0.3%-0.1%0.0%0.0%0.0%-0.3%-0.8%-0.3%-2.4%0.1%-0.3%-1.7%
2015-0.2%0.3%1.3%1.2%2.6%-0.3%-0.1%-4.1%-0.3%0.3%0.2%0.1%+1.0%
2016-0.3%0.1%0.5%0.7%0.3%-1.8%-0.1%0.5%0.1%-0.1%-0.4%2.5%+1.9%
20170.0%··0.0%0.5%0.1%0.5%-0.1%0.0%·1.8%-0.0%+2.9%
20180.1%0.2%0.4%0.0%0.1%0.5%-0.2%-0.4%0.3%-3.1%-0.4%0.0%-2.4%
2019-0.7%-0.5%-0.3%0.0%1.1%0.2%-0.1%-3.0%0.1%-0.7%0.0%0.2%-3.7%
20201.2%0.6%-11.0%0.1%0.6%0.5%0.4%-0.2%-0.2%0.0%-2.5%0.6%-9.9%
20210.2%-0.3%0.4%0.0%2.0%-0.0%0.3%0.0%-0.6%-0.2%-0.4%0.9%+2.2%
2022-0.7%-3.3%0.3%-0.1%-0.7%-1.2%0.2%-1.3%-0.3%-0.4%0.2%-1.0%-8.1%
20230.1%0.0%-0.0%0.0%0.1%0.1%-0.8%-0.1%-0.0%-1.4%-0.1%·-2.0%
20240.2%··1.5%1.0%0.6%0.3%0.5%-0.5%0.2%-0.0%-0.2%+3.6%
2025·3.4%3.5%6.9%0.1%0.1%0.1%·0.0%0.4%-0.8%0.0%+14.4%
2026·0.4%-4.8%0.1%-46.7%-0.0%0.0%0.2%-0.1%-6.9%··-52.4%

TRADE STATS

Gross profit58,936.22Gross loss-113,143.23
Expected payoff-67.67Total deals1228
Long trades801 (51.6%)Short trades0 (0.0%)
Largest win1,388.95Largest loss-6,609.89
Average win142.70Average loss-291.61
Max consec. wins19Max consec. losses24
Balance DD max59,874.54 (56.7%)Equity DD max74,831.61 (62.7%)
Leverage1:100Brokerafx Markets Ltd
All report fields (46)
History Quality36% real ticks
Bars60480
Ticks766608845
Symbols1
Total Net Profit-54 207.01
Balance Drawdown Absolute54 207.01
Equity Drawdown Absolute55 555.22
Gross Profit58 936.22
Balance Drawdown Maximal59 874.54 (56.66%)
Equity Drawdown Maximal74 831.61 (62.74%)
Gross Loss-113 143.23
Balance Drawdown Relative56.66% (59 874.54)
Equity Drawdown Relative62.74% (74 831.61)
Profit Factor0.52
Expected Payoff-67.67
Margin Level7092.82%
Recovery Factor-0.72
Sharpe Ratio-0.45
Z-Score-14.34 (99.74%)
AHPR0.9990 (-0.10%)
LR Correlation-0.72
OnTester result45792.99
GHPR0.9990 (-0.10%)
LR Standard Error9 092.31
Total Trades801
Short Trades (won %)0 (0.00%)
Long Trades (won %)801 (51.56%)
Total Deals1228
Profit Trades (% of total)413 (51.56%)
Loss Trades (% of total)388 (48.44%)
Largest profit trade1 388.95
Largest loss trade-6 609.89
Average profit trade142.70
Average loss trade-291.61
Maximum consecutive wins ($)19 (7 022.27)
Maximum consecutive losses ($)24 (-42 997.66)
Maximal consecutive profit (count)7 022.27 (19)
Maximal consecutive loss (count)-42 997.66 (24)
Average consecutive wins4
Average consecutive losses4
Correlation (Profits,MFE)0.43
Correlation (Profits,MAE)0.75
Correlation (MFE,MAE)-0.0961
Minimal position holding time0:19:00
Maximal position holding time86375:59:30
Average position holding time6605:20:35

NOTES

At the start of each broker week calculate the annualized standard deviation of 21 previously completed daily log returns. The long weight is the lesser of one and 10% divided by that volatility. The rest stays in cash. The EA resizes on a new broker date or a change in target.

The long MT5 test lost $54,207.01 with 62.74% relative equity drawdown. The shorter test restarted in January 2025 and lost $53,183.52 with 60.32% drawdown. Both used USD 100,000, real-tick mode, 100 ms fixed delay and the broker’s 0.0014% closing commission schedule.

GER40 changed price units on May 6, 2026. The long run held 0.23 lots through that hour, implying a gross hourly mark of −$51,623.27. A separate check of recorded month ends already found a 32.45% decline before the change. Daily or intermittent H1 prints occur early in the history. July–September 2025 also contains a quote outage. The native losses and drawdowns appear as booked.

MT5 period, inclusive Net USD Maximum equity DD Trades Swap USD Exit fees USD Rejected requests
2012-09-01 to 2026-10-31 −$54,207.01 62.74% 801 −$52,908.92 $38.55 5,428
2025-01-01 to 2026-10-31 −$53,183.52 60.32% 111 −$6,706.89 $5.81 1,290

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.

The training and validation dates were specified before the later-window evaluation. The 48-month positive validation is a complete separate bar test and exceeded 10% drawdown. The remaining H1 rows show all contiguous eligible segments of the long and recent native plans. Their break dates omit quote outages and the May 2026 price-unit change. They cannot recover losses on positions carried across the break.

Broker-bar window, inclusive Scope Modeled net USD Geometric return per month Hourly drawdown bound
2012-09-01 to 2025-06-30 long $11,148.72 +0.069% 33.06%
2025-10-01 to 2026-04-30 long and recent −$4,776.34 -0.697% 12.03%
2026-06-01 to 2026-10-31 long and recent −$376.17 -0.075% 6.96%
2025-01-01 to 2025-06-30 recent $8,984.08 +1.444% 11.01%
2012-08-01 to 2020-12-31 train −$1,142.46 -0.011% 29.04%
2021-01-01 to 2024-12-31 validation $3,590.81 +0.074% 23.36%
InputValueOptimise (start / step / stop)Section
TesterOnlytrue
AuditToken0
Exposure1.00
IDX_GER40_Vol100.mq5318 lines · 11.9 KB · 2026-11-29 ↓ download
View source
#property strict
#property version "1.00"
#define DEFAULT_EXPOSURE 1.00
const string LockedAnchor="GER40";
const ulong LockedMagic=3434801559;
const bool MonthlyRebalance=false;
string LegNames[]={"GER40"};
string MapNames[]={"GER40"};
string MapSymbols[]={"GER40"};
double LegWeights[]={1.0};
datetime ixSizedDate[];
double ixSizedWeight[],ixPendingWeight[];
// Index-versus-cash volatility allocation from Kakushadze & Serur, section 6.5.
// The locked broker symbols are populated by assemble.py. Every source refuses non-tester use.
datetime ixPeriod(const datetime hour)
{
   MqlDateTime t;
   TimeToStruct(hour,t);
   t.hour=0; t.min=0; t.sec=0;
   if(MonthlyRebalance) { t.day=1; return StructToTime(t); }
   return StructToTime(t)-(datetime)(((t.day_of_week+6)%7)*86400);
}

bool ixComponent(const string sym,const datetime cut,const int lookback,double &result,bool &eligible)
{
   result=0; eligible=false;
   // A cutoff identifies the first midnight in the new week/month. Only earlier D1 bars qualify.
   MqlRates r[];
   const int warm=ArraySize(LegNames)>1?64:lookback+1;
   const int got=CopyRates(sym,PERIOD_D1,cut-1,warm,r);
   if(got<0 || !SeriesInfoInteger(sym,PERIOD_D1,SERIES_SYNCHRONIZED)) return false;
   if(got<warm) return true;
   if(r[got-1].time>=cut || r[got-1].close<=0) return false;
   if(ArraySize(LegNames)>1 && (cut-r[got-1].time)>7*86400) return true;
   double sum=0, sum2=0;
   for(int a=got-lookback;a<got;a++)
   {
      if(r[a].close<=0 || r[a-1].close<=0) return false;
      const double x=MathLog(r[a].close/r[a-1].close);
      sum+=x; sum2+=x*x;
   }
   const double variance=(sum2-sum*sum/lookback)/(lookback-1);
   if(variance<=0) return true;
   result=MathMin(1.0,0.10/MathSqrt(252.0*variance)); eligible=true;
   return true;
}

bool SelectedWeight(const int id,const string sym,const datetime hour,double &weight)
{
   static datetime cached=0;
   static double weights[];
   const datetime cut=ixPeriod(hour);
   if(cut!=cached)
   {
      const int n=ArraySize(LegNames);
      ArrayResize(weights,n);
      int eligible=0;
      for(int j=0;j<n;j++)
      {
         bool use=false;
         if(!ixComponent(LegNames[j],cut,21,weights[j],use)) return false;
         if(use) eligible++;
      }
      if(n>1)
      {
         for(int j=0;j<n;j++) weights[j]=eligible>=2?weights[j]/eligible:0;
      }
      cached=cut;
   }
   weight=weights[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_GER40_Vol100_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.14.7 KB0c87e978623ff2026-11-29 01:22
FILEIDX_GER40_Vol100_broker_bar_windows.csv latestModeled windows, independently reset USD equity, estimated financing, commission, execution friction and drawdown bounds.1.4 KB0d19723661c6a2026-11-29 01:22
BACKTESTIDX_GER40_Vol100_2025-01-01_to_2026-10-31.html latestOriginal MT5 statement with 21 of 22 monthly marks. GER40 underwent a price-unit change during both windows.183.3 KB0ae31f601d5fe2026-11-29 01:22
BACKTESTIDX_GER40_Vol100_2012-09-01_to_2026-10-31.html latestOriginal MT5 statement with 166 of 170 monthly marks. GER40 underwent a price-unit change during both windows.682.7 KB048235d67bad32026-11-29 01:21
PARAMSIDX_GER40_Vol100.set latestReproduction preset for GER40 H1 at 1.00× exposure. The optional internal monthly recorder is disabled.94 B0b57dcabaca262026-11-29 01:21
SOURCEIDX_GER40_Vol100.mq5 latestExact MQL5 source verified against the successful MetaEditor build. This source runs in Strategy Tester.11.9 KB073dcf07e74ac2026-11-29 01:21

MORE INDICES STRATEGIES

all Indices →