OPENSTRATS

Dow 30 overnight after a down day 0.90×

Research

Long test −$29,014.00 net, 39.53% maximum equity drawdown. Shorter test $11,415.43 net, 4.00% maximum equity drawdown.

SYM US30TF H1TEST 2016-02-01 → 2025-06-30UPDATED VIEWS 0DOWNLOADS 0#mean-reversion

BACKTESTS · 2

1 of 2
NET PROFIT · USD
-29,014
from 100,000 USD
RETURN
-29.0%
CAGR
-3.6%
9.4 yrs
PROFIT FACTOR
0.88
SHARPE
-0.78
MAX DD
-39.5%
equity, relative
RECOVERY
-0.73
TRADES
1842
47.9% win

EQUITY · BALANCE (USD)

IDX_US30_Overnight090 · US30 H1 · quality 87% real ticks · drag to zoom, double-click to reset

MONTHLY RETURNS

% of balance at month start
YearJanFebMarAprMayJunJulAugSepOctNovDecYear
2016·-3.5%0.7%-0.1%1.6%-0.8%-0.4%-0.1%-0.7%-1.1%0.4%0.8%-3.4%
2017-0.9%0.9%-1.0%-0.0%-2.2%0.9%-0.6%-0.6%0.2%0.8%0.3%0.3%-2.0%
20180.1%-0.2%-0.1%2.4%-3.1%-0.1%0.1%0.7%0.9%-0.4%-1.6%-5.1%-6.5%
20190.3%-1.2%-0.8%-0.6%-4.4%1.7%-1.4%0.0%0.8%-1.8%0.7%-1.4%-7.8%
20200.8%-5.5%-16.4%0.2%-2.1%1.9%2.2%1.4%1.4%-0.4%2.0%-0.6%-15.7%
20210.7%1.1%1.8%0.2%0.1%0.0%1.2%-0.2%2.0%1.4%-2.1%0.9%+7.2%
2022-0.8%-2.0%3.8%-0.0%0.5%-1.1%-1.4%1.2%-0.5%3.0%4.2%-2.1%+4.6%
20230.4%-0.3%2.6%-0.5%-2.8%-2.0%-0.1%1.1%-0.3%1.0%0.8%0.6%+0.4%
2024-0.4%-0.8%-0.3%-1.8%-1.6%-0.5%0.3%0.3%-0.8%-1.0%0.3%-0.8%-7.0%
2025-0.3%0.2%-4.8%1.9%0.6%1.0%······-1.5%

TRADE STATS

Gross profit214,195.23Gross loss-243,209.23
Expected payoff-15.75Total deals3630
Long trades1842 (47.9%)Short trades0 (0.0%)
Largest win2,099.57Largest loss-6,815.59
Average win242.58Average loss-253.61
Max consec. wins8Max consec. losses11
Balance DD max37,117.34 (37.1%)Equity DD max39,618.80 (39.5%)
Leverage1:100Brokerafx Markets Ltd
All report fields (46)
History Quality87% real ticks
Bars55791
Ticks457366583
Symbols1
Total Net Profit-29 014.00
Balance Drawdown Absolute37 117.34
Equity Drawdown Absolute39 403.93
Gross Profit214 195.23
Balance Drawdown Maximal37 117.34 (37.12%)
Equity Drawdown Maximal39 618.80 (39.53%)
Gross Loss-243 209.23
Balance Drawdown Relative37.12% (37 117.34)
Equity Drawdown Relative39.53% (39 618.80)
Profit Factor0.88
Expected Payoff-15.75
Margin Level9908.68%
Recovery Factor-0.73
Sharpe Ratio-0.78
Z-Score1.50 (86.64%)
AHPR0.9998 (-0.02%)
LR Correlation-0.81
OnTester result70986
GHPR0.9998 (-0.02%)
LR Standard Error6 231.31
Total Trades1842
Short Trades (won %)0 (0.00%)
Long Trades (won %)1842 (47.94%)
Total Deals3630
Profit Trades (% of total)883 (47.94%)
Loss Trades (% of total)959 (52.06%)
Largest profit trade2 099.57
Largest loss trade-6 815.59
Average profit trade242.58
Average loss trade-253.61
Maximum consecutive wins ($)8 (618.55)
Maximum consecutive losses ($)11 (-1 885.66)
Maximal consecutive profit (count)3 710.99 (4)
Maximal consecutive loss (count)-6 838.93 (2)
Average consecutive wins2
Average consecutive losses2
Correlation (Profits,MFE)0.52
Correlation (Profits,MAE)0.68
Correlation (MFE,MAE)-0.0971
Minimal position holding time0:59:16
Maximal position holding time42:00:02
Average position holding time10:50:56

NOTES

After a lower completed broker daily close, enter long outside 10:00–16:00 New York local time. Target cash during those six hours and after other daily closes. The EA treats broker-hour labels as UTC and converts for US daylight saving time.

Compile the supplied source and use MT5 Strategy Tester on US30 H1. Each test starts with USD 100,000, uses 1:100 account leverage, real-tick mode and a fixed 100 ms execution delay. The EA resizes on a new broker date or a change of target. Net results include the broker’s spread, booked swaps and closing commissions under its 0.0014% exit schedule. The source is tester-only.

The 0.90× exposure was selected retrospectively on the recent period. The 113-month earlier test lost $29,014.00 with 39.53% maximum equity drawdown. Recorded real ticks began in April 2017, after that test started. The earlier and recent windows are disjoint and each starts with fresh capital.

Requested period, inclusive Net USD Max equity DD Trades Eligible months Swaps USD Exit fees USD Rejections
2016-02-01 to 2025-06-30 −$29,014.00 39.53% 1,842 113/113 −$35,861.85 $1,818.50 51,786
2025-10-01 to 2026-10-31 $11,415.43 4.00% 203 13/13 −$2,561.25 $267.18 9,074

The monthly CSV reports native month-end equity and leaves missing months blank. Eligible monthly changes are based on equity including open positions. The website’s deal-balance chart uses realized balances. All maximum drawdowns above are the tester’s relative equity drawdowns.

InputValueOptimise (start / step / stop)Section
TesterOnlytrue
AuditToken0
Exposure0.90
IDX_US30_Overnight090.mq5288 lines · 11.1 KB · 2026-11-29 ↓ download
View source
#property strict
#property version "1.00"
#define DEFAULT_EXPOSURE 0.90
const string LockedAnchor="US30";
const ulong LockedMagic=606450993;
const bool MonthlyRebalance=false;
string LegNames[]={"US30"};
string MapNames[]={"US30"};
string MapSymbols[]={"US30"};
double LegWeights[]={1.0};
datetime ixSizedDate[];
double ixSizedWeight[],ixPendingWeight[];
// Retrospective NAS100 equity overnight inventory study. Broker server labels treated as UTC.
// The 2007 US DST rules apply throughout the available 2022–26 CFD series.
datetime ixSunday(const int year,const int month,const int ordinal,const int utcHour)
{
   MqlDateTime t={}; t.year=year; t.mon=month; t.day=1; t.hour=utcHour;
   const datetime first=StructToTime(t); TimeToStruct(first,t);
   return first+(datetime)(((7-t.day_of_week)%7+7*(ordinal-1))*86400);
}
bool SelectedWeight(const int id,const string sym,const datetime hour,double &weight)
{
   MqlDateTime t;
   if(!TimeToStruct(hour,t)) return false;
   const datetime daylight=ixSunday(t.year,3,2,7), standard=ixSunday(t.year,11,1,6);
   const int offset=(hour>=daylight && hour<standard)?-4:-5;
   const int localHour=(t.hour+24+offset)%24;
   weight=0;
   if(localHour>=10 && localHour<16) return true;
   static datetime cached=0;
   static double stored=0;
   const datetime day=hour-hour%86400;
   if(day!=cached)
   {
      MqlRates r[];
      const int got=CopyRates(sym,PERIOD_D1,day-1,2,r);
      if(got<0 || !SeriesInfoInteger(sym,PERIOD_D1,SERIES_SYNCHRONIZED)) return false;
      stored=got==2 && r[1].time<day && r[1].close<r[0].close?1.0:0.0;
      cached=day;
   }
   weight=stored; 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_US30_Overnight090_monthly_equity.csv latestNative intratest USD equity marks by requested calendar month. Empty cells indicate missing observations or an ineligible monthly change. The platform’s deal-balance charts use a different series.12.7 KB0f8c0f4150ff62026-11-29 01:21
BACKTESTIDX_US30_Overnight090_2025-10-01_to_2026-10-31.html latestMT5 real-tick mode. 13 eligible months of 13 requested. Financing −$2,561.25. Closing fees $267.18.309.4 KB0c51e569cc0fb2026-11-29 01:21
BACKTESTIDX_US30_Overnight090_2016-02-01_to_2025-06-30.html latestMT5 real-tick mode. 113 eligible months of 113 requested. Financing −$35,861.85. Closing fees $1,818.50.1.7 MB0463e7d0051322026-11-29 01:20
PARAMSIDX_US30_Overnight090.set latestTested economic inputs. The internal monthly recording identifier has been reset to zero.94 B09beb5ccbd3572026-11-29 01:20
SOURCEIDX_US30_Overnight090.mq5 latestOriginal compiled-and-tested MQL5 source. The EA requires MT5 Strategy Tester and a USD account.11.1 KB03d31d40451bf2026-11-29 01:20

MORE INDICES STRATEGIES

all Indices →