OPENSTRATS

Gold and silver hedging-pressure quintiles at 0.50×

Research

Jan 2009–Oct 2026 MT5 results showed +$3,661.48 net and 9.62% maximum equity drawdown.

SYM XAUUSD, XAGUSDTF H1TEST 2025-01-01 → 2026-10-31UPDATED VIEWS 0DOWNLOADS 0#mean-reversion

BACKTESTS · 2

2 of 2
NET PROFIT · USD
+7,793
from 100,000 USD
RETURN
+7.8%
CAGR
+4.2%
1.8 yrs
PROFIT FACTOR
9.02
SHARPE
0.59
MAX DD
-8.2%
equity, relative
RECOVERY
0.81
TRADES
48
95.8% win

EQUITY · BALANCE (USD)

Metals_PressureQuintiles050 · XAUUSD H1 · quality 100% real ticks · drag to zoom, double-click to reset

MONTHLY RETURNS

% of balance at month start
YearJanFebMarAprMayJunJulAugSepOctNovDecYear
20250.0%0.5%·1.2%1.8%0.0%···0.5%··+4.1%
20261.2%0.3%0.0%0.4%0.1%····1.5%··+3.6%

TRADE STATS

Gross profit8,764.77Gross loss-971.89
Expected payoff162.35Total deals88
Long trades48 (95.8%)Short trades0 (0.0%)
Largest win1,274.68Largest loss-967.63
Average win190.54Average loss-485.94
Max consec. wins26Max consec. losses1
Balance DD max967.63 (0.9%)Equity DD max9,642.33 (8.2%)
Leverage1:100BrokerWithheld
All report fields (46)
History Quality100% real ticks
Bars10995
Ticks204690051
Symbols1
Total Net Profit7 792.88
Balance Drawdown Absolute0.00
Equity Drawdown Absolute128.60
Gross Profit8 764.77
Balance Drawdown Maximal967.63 (0.91%)
Equity Drawdown Maximal9 642.33 (8.21%)
Gross Loss-971.89
Balance Drawdown Relative0.91% (967.63)
Equity Drawdown Relative8.21% (9 642.33)
Profit Factor9.02
Expected Payoff162.35
Margin Level42136.64%
Recovery Factor0.81
Sharpe Ratio0.59
Z-Score1.39 (83.55%)
AHPR1.0016 (0.16%)
LR Correlation0.87
OnTester result107792.88
GHPR1.0016 (0.16%)
LR Standard Error967.21
Total Trades48
Short Trades (won %)0 (0.00%)
Long Trades (won %)48 (95.83%)
Total Deals88
Profit Trades (% of total)46 (95.83%)
Loss Trades (% of total)2 (4.17%)
Largest profit trade1 274.68
Largest loss trade-967.63
Average profit trade190.54
Average loss trade-485.94
Maximum consecutive wins ($)26 (5 779.71)
Maximum consecutive losses ($)1 (-967.63)
Maximal consecutive profit (count)5 779.71 (26)
Maximal consecutive loss (count)-967.63 (1)
Average consecutive wins15
Average consecutive losses1
Correlation (Profits,MFE)0.84
Correlation (Profits,MAE)0.12
Correlation (MFE,MAE)0.0277
Minimal position holding time1:00:00
Maximal position holding time11445:54:59
Average position holding time1566:56:30

NOTES

Ranks published commercial and speculative futures positioning across five metals and trades qualifying gold or silver CFDs. Twice a year the model ranks 26 weekly CFTC Legacy futures-only observations. A qualifying gold or silver leg receives ±25% of equity. The embedded historical formation table governs the available decisions. Gold accounted for all executions in the reported tests. Positions can accrue significant swap and orders may be rejected while the market is closed.

Jan 2009–Oct 2026: +$3,661.48 net, +$17.11 per month, 0.017% compounded monthly, 9.62% maximum equity drawdown. Jan 2025–Oct 2026: +$7,792.88 net, +$354.22 per month, 0.342% compounded monthly, 8.21% maximum equity drawdown. Each MT5 window starts with USD 100,000. The later windows overlap the long history. The tester booked 0.0014% of closing notional, with swap and spread reflected in the net results. Tick coverage varies over time. Real gold and silver tick history begins in January 2019. The tester used generated prices during earlier periods and during later quote gaps, including gaps in gold during 2025. MT5 logged rejected trade requests (Jan 2009–Oct 2026: 967, Jan 2025–Oct 2026: 1,270). These counts include retries.

InputValueOptimise (start / step / stop)Section
TesterOnlytrue
EquityLogId0
Exposure0.5
Metals_PressureQuintiles050.mq5307 lines · 13.1 KB · 2026-11-29 ↓ download
View source
#property strict
#property description "Tester-only five-metal positioning research"
const ulong LockedMagic=764885678;
const string LockedAnchor="XAUUSD";
string LegNames[]={"XAUUSD","XAGUSD"},MapNames[]={"XAUUSD","XAGUSD"},MapSymbols[]={"XAUUSD","XAGUSD"};
double LegWeights[]={0.5,0.5};
// CFTC Legacy futures-only CSV SHA256 21d79e7d2a33792b9e37f5d56a145c21c80cf8b226a570ca47b67cc713db54e3
// Frozen rule SHA256 f10ea580f0089e717f38f7aa315db31a41bdaffb8e64cb953ec4022dc1f529ed
// Formation ledger SHA256 73a559bb1f0d629aa747f2c37cb5788ed8ff8fd7617c17237c6ddb15abd47282
// 2009-01-02 | XAUUSD hedge=4 spec=5 side=0 | XAGUSD hedge=3 spec=4 side=0
// 2009-07-01 | XAUUSD hedge=3 spec=4 side=0 | XAGUSD hedge=4 spec=3 side=0
// 2010-01-03 | XAUUSD hedge=2 spec=5 side=0 | XAGUSD hedge=4 spec=4 side=0
// 2010-07-01 | XAUUSD hedge=3 spec=3 side=0 | XAGUSD hedge=4 spec=4 side=0
// 2011-01-03 | XAUUSD hedge=4 spec=3 side=0 | XAGUSD hedge=3 spec=2 side=0
// 2011-07-04 | XAUUSD hedge=4 spec=3 side=0 | XAGUSD hedge=3 spec=2 side=0
// 2012-01-02 | XAUUSD hedge=3 spec=3 side=0 | XAGUSD hedge=4 spec=2 side=0
// 2012-07-01 | XAUUSD hedge=3 spec=5 side=0 | XAGUSD hedge=4 spec=2 side=0
// 2013-01-01 | XAUUSD hedge=2 spec=5 side=0 | XAGUSD hedge=4 spec=3 side=0
// 2013-07-01 | XAUUSD hedge=3 spec=3 side=0 | XAGUSD hedge=4 spec=2 side=0
// 2014-01-02 | XAUUSD hedge=3 spec=3 side=0 | XAGUSD hedge=4 spec=2 side=0
// 2014-07-01 | XAUUSD hedge=4 spec=3 side=0 | XAGUSD hedge=3 spec=2 side=0
// 2015-01-02 | XAUUSD hedge=3 spec=3 side=0 | XAGUSD hedge=4 spec=2 side=0
// 2015-07-01 | XAUUSD hedge=3 spec=3 side=0 | XAGUSD hedge=4 spec=2 side=0
// 2016-01-03 | XAUUSD hedge=3 spec=3 side=0 | XAGUSD hedge=4 spec=2 side=0
// 2016-07-01 | XAUUSD hedge=4 spec=3 side=0 | XAGUSD hedge=3 spec=5 side=0
// 2017-01-02 | XAUUSD hedge=2 spec=5 side=0 | XAGUSD hedge=3 spec=3 side=0
// 2017-07-02 | XAUUSD hedge=4 spec=2 side=0 | XAGUSD hedge=3 spec=5 side=0
// 2018-01-02 | XAUUSD hedge=3 spec=4 side=0 | XAGUSD hedge=4 spec=3 side=0
// 2018-07-01 | XAUUSD hedge=3 spec=4 side=0 | XAGUSD hedge=4 spec=2 side=0
// 2019-01-02 | XAUUSD hedge=2 spec=4 side=0 | XAGUSD hedge=4 spec=2 side=0
// 2019-07-01 | XAUUSD hedge=4 spec=4 side=0 | XAGUSD hedge=3 spec=2 side=0
// 2020-01-02 | XAUUSD hedge=3 spec=4 side=0 | XAGUSD hedge=4 spec=2 side=0
// 2020-07-01 | XAUUSD hedge=2 spec=5 side=0 | XAGUSD hedge=4 spec=2 side=0
// 2021-01-03 | XAUUSD hedge=1 spec=5 side=1 | XAGUSD hedge=3 spec=3 side=0
// 2021-07-01 | XAUUSD hedge=1 spec=5 side=1 | XAGUSD hedge=3 spec=3 side=0
// 2022-01-02 | XAUUSD hedge=1 spec=5 side=1 | XAGUSD hedge=3 spec=4 side=0
// 2022-07-01 | XAUUSD hedge=1 spec=5 side=1 | XAGUSD hedge=2 spec=4 side=0
// 2023-01-02 | XAUUSD hedge=1 spec=5 side=1 | XAGUSD hedge=2 spec=4 side=0
// 2023-07-02 | XAUUSD hedge=1 spec=5 side=1 | XAGUSD hedge=3 spec=3 side=0
// 2024-01-01 | XAUUSD hedge=1 spec=5 side=1 | XAGUSD hedge=3 spec=3 side=0
// 2024-07-01 | XAUUSD hedge=1 spec=5 side=1 | XAGUSD hedge=2 spec=4 side=0
// 2025-01-01 | XAUUSD hedge=1 spec=5 side=1 | XAGUSD hedge=2 spec=4 side=0
// 2025-07-01 | XAUUSD hedge=1 spec=5 side=1 | XAGUSD hedge=2 spec=4 side=0
// 2026-01-01 | XAUUSD hedge=1 spec=5 side=1 | XAGUSD hedge=2 spec=4 side=0
// 2026-07-01 | XAUUSD hedge=1 spec=5 side=1 | XAGUSD hedge=3 spec=4 side=0
const int FormationDates[]={1230854400,1246406400,1262476800,1277942400,1294012800,1309737600,1325462400,1341100800,1356998400,1372636800,1388620800,1404172800,
1420156800,1435708800,1451779200,1467331200,1483315200,1498953600,1514851200,1530403200,1546387200,1561939200,1577923200,1593561600,
1609632000,1625097600,1641081600,1656633600,1672617600,1688256000,1704067200,1719792000,1735689600,1751328000,1767225600,1782864000};
const int GoldSides[]={0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1};
const int SilverSides[]={0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0};
double MetalExternal(const datetime cutoff,const int &events[],const int &states[])
{
   int lo=0,hi=ArraySize(events)-1;
   while(lo<=hi){int m=(lo+hi)/2;if(events[m]<=(long)cutoff)lo=m+1;else hi=m-1;}
   return hi<0?0:states[hi];
}

bool SelectedWeight(const int slot, const string sym, const datetime hour, double &w)
{
   w=0.0;
   if(hour>=D'2026.11.01 00:00') return true;
   if(slot==0 && sym=="XAUUSD") w=0.5*MetalExternal(hour,FormationDates,GoldSides);
   else if(slot==1 && sym=="XAGUSD") w=0.5*MetalExternal(hour,FormationDates,SilverSides);
   else return false;
   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 EquityLogId = 0;
input double Exposure = 0.5;
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)
{
   return canonical=="XAUUSD" || canonical=="XAGUSD";
}

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 string account=AccountInfoString(ACCOUNT_CURRENCY);
   const string base=SymbolInfoString(sym,SYMBOL_CURRENCY_BASE);
   const string quote=SymbolInfoString(sym,SYMBOL_CURRENCY_PROFIT);
   double notional=contract;
   if(base!=account)
   {
      if(quote==account) notional=contract*price;
      else
      {
         double move=0;
         if(!OrderCalcProfit(ORDER_TYPE_BUY,sym,1.0,price,price*1.01,move) || move<=0) return false;
         notional=move*100;
      }
   }
   double raw=dsOpeningEquity*Exposure*allocation/notional;
   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((!TesterOnly || !MQLInfoInteger(MQL_TESTER)) || Exposure!=0.5 || !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(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;
      if(SymbolInfoString(dsSymbols[i],SYMBOL_CURRENCY_PROFIT)!="USD" || AccountInfoString(ACCOUNT_CURRENCY)!="USD") return INIT_PARAMETERS_INCORRECT;
      total+=LegWeights[i];
   }
   if(total<=0 || _Symbol!=LockedAnchor) return INIT_PARAMETERS_INCORRECT;
   if(MQLInfoInteger(MQL_TESTER) && EquityLogId>0)
   {
      const string fn="StrategyResearch\\monthly-"+IntegerToString((long)EquityLogId)+".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);
         if(!DSSized(sym,side,tick,MathAbs(weight),dsVolumes[i])) { all=false; continue; }
         dsSides[i]=side;
         dsReady[i]=true;
      }
      dsDone[i]=DSAlign(sym,dsSides[i],dsVolumes[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
FILEMetals_PressureQuintiles050_monthly_equity.csv latestMonth-end marked equity by independent MT5 account. A partial month is identified by its observed broker timestamps.24.0 KB050b1815dbb912026-11-29 01:24
BACKTESTMetals_PressureQuintiles050_holdfee.html latestMT5 Strategy Tester, USD 100,000 initial capital. 48 closed trades. Native net P&L includes −$2.89 commission and −$2,880.72 swap. MT5 history quality: 100% real ticks. Rejected requests: 1,270.145.0 KB048476765f77f2026-11-29 01:24
BACKTESTMetals_PressureQuintiles050_continuousfee.html latestMT5 Strategy Tester, USD 100,000 initial capital. 194 closed trades. Native net P&L includes −$6.55 commission and −$14,059.47 swap. MT5 history quality: 43% real ticks. Rejected requests: 967.280.8 KB0d3e57fb4d1ea2026-11-29 01:23
PARAMSMetals_PressureQuintiles050.set latestStrategy MT5 Strategy Tester preset. Exposure 0.5×.94 B0294b4b3a36432026-11-29 01:23
SOURCEMetals_PressureQuintiles050.mq5 latestStrategy MQL5 source. Trade rules and sizing are preserved. The optional equity log uses a public identifier.13.1 KB06564a63ae4042026-11-29 01:23

MORE METALS STRATEGIES

all Metals →