AUDCAD four-hour RSI reversal
ResearchTrades reversals in a 14-period RSI on completed four-hour AUDCAD bars, using 30 and 70 as the entry thresholds and 50 for exits. MT5 results with booked exit commission.
EQUITY · BALANCE (USD)
FX_AUDCAD_RSI1 · AUDCAD H1 · quality 100% 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2025 | -0.5% | 0.3% | 0.8% | -1.7% | 0.9% | 0.4% | 1.3% | 1.3% | -0.8% | 0.7% | · | 0.3% | +2.9% |
| 2026 | -1.4% | 1.6% | 2.3% | -0.2% | -0.4% | -0.1% | 1.3% | 0.2% | · | 0.0% | · | · | +3.2% |
TRADE STATS
| Gross profit | 12,593.84 | Gross loss | -6,339.91 |
| Expected payoff | 14.18 | Total deals | 678 |
| Long trades | 78 (66.7%) | Short trades | 363 (47.7%) |
| Largest win | 1,323.31 | Largest loss | -1,819.95 |
| Average win | 55.97 | Average loss | -29.35 |
| Max consec. wins | 18 | Max consec. losses | 18 |
| Balance DD max | 1,926.42 (1.9%) | Equity DD max | 4,588.64 (4.6%) |
| Leverage | 1:100 | Broker | afx Markets Ltd |
All report fields (46)
| History Quality | 100% real ticks |
| Bars | 11394 |
| Ticks | 97667790 |
| Symbols | 1 |
| Total Net Profit | 6 253.93 |
| Balance Drawdown Absolute | 1 398.55 |
| Equity Drawdown Absolute | 3 856.90 |
| Gross Profit | 12 593.84 |
| Balance Drawdown Maximal | 1 926.42 (1.92%) |
| Equity Drawdown Maximal | 4 588.64 (4.56%) |
| Gross Loss | -6 339.91 |
| Balance Drawdown Relative | 1.92% (1 926.42) |
| Equity Drawdown Relative | 4.56% (4 588.64) |
| Profit Factor | 1.99 |
| Expected Payoff | 14.18 |
| Margin Level | 9477.83% |
| Recovery Factor | 1.36 |
| Sharpe Ratio | 1.45 |
| Z-Score | -12.30 (99.74%) |
| AHPR | 1.0001 (0.01%) |
| LR Correlation | 0.91 |
| OnTester result | 106253.93 |
| GHPR | 1.0001 (0.01%) |
| LR Standard Error | 969.54 |
| Total Trades | 441 |
| Short Trades (won %) | 363 (47.66%) |
| Long Trades (won %) | 78 (66.67%) |
| Total Deals | 678 |
| Profit Trades (% of total) | 225 (51.02%) |
| Loss Trades (% of total) | 216 (48.98%) |
| Largest profit trade | 1 323.31 |
| Largest loss trade | -1 819.95 |
| Average profit trade | 55.97 |
| Average loss trade | -29.35 |
| Maximum consecutive wins ($) | 18 (3 117.51) |
| Maximum consecutive losses ($) | 18 (-823.20) |
| Maximal consecutive profit (count) | 3 117.51 (18) |
| Maximal consecutive loss (count) | -1 823.28 (3) |
| Average consecutive wins | 5 |
| Average consecutive losses | 5 |
| Correlation (Profits,MFE) | 0.66 |
| Correlation (Profits,MAE) | 0.56 |
| Correlation (MFE,MAE) | -0.1830 |
| Minimal position holding time | 1:00:00 |
| Maximal position holding time | 180:00:14 |
| Average position holding time | 51:41:18 |
NOTES
Trades reversals in a 14-period RSI on completed four-hour AUDCAD bars, using 30 and 70 as the entry thresholds and 50 for exits. The main source targets 1.00× exposure.
AUDCAD_RSI1, Jan 2014–Oct 2026. MT5 booked +$56,167.98 on $100,000, +0.290% compounded monthly, with 8.24% maximum relative equity drawdown.
AUDCAD_RSI1, Jan 2025–Oct 2026. MT5 booked +$6,253.93 on $100,000, +0.276% compounded monthly, with 4.56% maximum relative equity drawdown.
The 5.40× source lost money in its earlier test. The 6.00× implementation has only bar-model evidence.
PARAMETERS
↓ FX_AUDCAD_RSI1.set| Input | Value | Optimise (start / step / stop) | Section |
|---|---|---|---|
| TesterOnly | true | ||
| AuditToken | 0 | ||
| Exposure | 1.0 |
View source
#property strict
#property version "1.00"
const ulong LockedMagic=170089985804075;
const string LockedAnchor="AUDCAD";
string LegNames[]={"AUDCAD"};
double LegWeights[]={1.0};
string DSUniverse[]={"AUDCAD","AUDCHF","AUDJPY","AUDNZD","AUDUSD","CADCHF","CADJPY","CHFJPY","EURAUD","EURCAD","EURCHF","EURGBP","EURJPY","EURNZD","EURUSD","GBPAUD","GBPCAD","GBPCHF","GBPJPY","GBPNZD","GBPUSD","NZDCAD","NZDJPY","NZDUSD","USDCAD","USDCHF","USDJPY"};
string MapNames[]={"EURUSD","GBPUSD","AUDUSD","NZDUSD","USDJPY","USDCHF","USDCAD","EURGBP","EURJPY","EURCHF","EURCAD","EURAUD","EURNZD","GBPJPY","GBPCHF","GBPCAD","GBPAUD","GBPNZD","AUDJPY","AUDCHF","AUDCAD","AUDNZD","NZDJPY","NZDCAD","CADJPY","CADCHF","CHFJPY"};
string MapSymbols[]={"EURUSD","GBPUSD","AUDUSD","NZDUSD","USDJPY","USDCHF","USDCAD","EURGBP","EURJPY","EURCHF","EURCAD","EURAUD","EURNZD","GBPJPY","GBPCHF","GBPCAD","GBPAUD","GBPNZD","AUDJPY","AUDCHF","AUDCAD","AUDNZD","NZDJPY","NZDCAD","CADJPY","CADCHF","CHFJPY"};
datetime MapFirstH1[]={1388610000,1388610000,1388610000,1388610000,1388610000,1388610000,1388610000,1388610000,1388610000,1388610000,1388610000,1388610000,1388610000,1388610000,1388610000,1388646000,1388646000,1388646000,1388610000,1388610000,1388610000,1388610000,1388610000,1388610000,1388646000,1388610000,1388610000};
datetime DSFirstH1(const string broker) { for(int j=0;j<ArraySize(MapSymbols);j++) if(MapSymbols[j]==broker) return MapFirstH1[j]; return 0; }
string DSBrokerSymbol(const string canonical);
// Completed broker H4/D1 bars. State is separate for each rule, symbol and timeframe.
struct DSLocalState
{
string rule;
string sym;
ENUM_TIMEFRAMES tf;
datetime seen;
datetime decision;
int count;
int side;
double previous;
double fast;
double slow;
double gain;
double loss;
};
DSLocalState dsLocalCache[];
int DSLocalSign(const double x)
{
return x>0 ? 1 : (x<0 ? -1 : 0);
}
int DSLocalSlot(const string rule,const string sym,const ENUM_TIMEFRAMES tf)
{
for(int i=0;i<ArraySize(dsLocalCache);i++)
if(dsLocalCache[i].rule==rule && dsLocalCache[i].sym==sym && dsLocalCache[i].tf==tf) return i;
int k=ArraySize(dsLocalCache);
if(ArrayResize(dsLocalCache,k+1)!=k+1) return -1;
dsLocalCache[k].rule=rule; dsLocalCache[k].sym=sym; dsLocalCache[k].tf=tf;
dsLocalCache[k].seen=0; dsLocalCache[k].decision=0; dsLocalCache[k].count=0;
dsLocalCache[k].side=0; dsLocalCache[k].previous=0;
dsLocalCache[k].fast=0; dsLocalCache[k].slow=0; dsLocalCache[k].gain=0; dsLocalCache[k].loss=0;
return k;
}
void DSStateStep(DSLocalState &s,const MqlRates &v[],const int i,const string family,
const int n,const int b,const bool fade)
{
const double close=v[i].close;
const double previous=s.previous;
s.previous=close;
s.count++;
if(family=="ema")
{
if(s.count==1) { s.fast=close; s.slow=close; }
else { s.fast+=(close-s.fast)*2/(n+1.); s.slow+=(close-s.slow)*2/(b+1.); }
s.side=s.count>=b ? DSLocalSign(s.fast-s.slow) : 0;
return;
}
if(family=="mom" || family=="reverse")
{
s.side=(s.count>n && i>=n) ? DSLocalSign(close-v[i-n].close)*(family=="reverse" ? -1 : 1) : 0;
return;
}
if(family=="rsi")
{
if(s.count<2) return;
double up=MathMax(close-previous,0.),dn=MathMax(previous-close,0.);
if(s.count==2) { s.gain=up; s.loss=dn; }
else { s.gain+=(up-s.gain)/n; s.loss+=(dn-s.loss)/n; }
if(s.count<=n || s.gain+s.loss==0) return;
double z=100*s.gain/(s.gain+s.loss)-50;
if((s.side>0 && z>=0) || (s.side<0 && z<=0)) s.side=0;
if(z>b) s.side=-1;
if(z< -b) s.side=1;
return;
}
if(family=="channel")
{
if(s.count<=n || i<n) return;
double hi=v[i-1].high,lo=v[i-1].low,hiExit=hi,loExit=lo;
for(int j=1;j<=n;j++)
{
hi=MathMax(hi,v[i-j].high);lo=MathMin(lo,v[i-j].low);
if(j<=b) { hiExit=MathMax(hiExit,v[i-j].high);loExit=MathMin(loExit,v[i-j].low); }
}
bool closeLong=fade ? close>=(hi+lo)*.5 : close<loExit;
bool closeShort=fade ? close<=(hi+lo)*.5 : close>hiExit;
if((s.side>0 && closeLong) || (s.side<0 && closeShort)) s.side=0;
int entry=close>hi ? 1 : (close<lo ? -1 : 0);
if(entry!=0) s.side=fade ? -entry : entry;
return;
}
if(family=="zfade" || family=="volbreak")
{
if(s.count<n || i<n-1) return;
double mean=0.,m2=0.;
for(int j=i-n+1;j<=i;j++)
{
double x=MathLog(v[j].close),d=x-mean;
mean+=d/(j-(i-n+1)+1);
m2+=d*(x-mean);
}
if(m2<=0) return;
double z=(MathLog(close)-mean)/MathSqrt(m2/(n-1));
const bool mr=family=="zfade";
bool closeLong=mr ? z>=0 : z<=0;
bool closeShort=mr ? z<=0 : z>=0;
if((s.side>0 && closeLong) || (s.side<0 && closeShort)) s.side=0;
if(z>b) s.side=mr ? -1 : 1;
if(z< -b) s.side=mr ? 1 : -1;
return;
}
if(family=="range")
{
s.side=0;
if(s.count<n+2 || i<n+1) return;
double sum=0;
for(int j=i-n;j<i;j++)
sum+=MathMax(v[j].high,v[j-1].close)-MathMin(v[j].low,v[j-1].close);
if(sum>0 && MathAbs(close-previous)>b*sum/n) s.side=DSLocalSign(close-previous);
}
}
bool DSLocalTarget(const string rule,const string sym,const ENUM_TIMEFRAMES tf,const datetime cutoff,int &side)
{
string parts[];
const int fields=StringSplit(rule,'_',parts);
if(fields<2) return false;
string family=parts[0];
const bool fade=family=="channel" && fields==3 && parts[1]=="fade";
const bool range=family=="range" && fields==4 && parts[1]=="exp";
const bool single=family=="mom" || family=="reverse";
if(!single && !fade && !range && family!="ema" && family!="channel" &&
family!="zfade" && family!="volbreak" && family!="rsi") return false;
const int n=(int)StringToInteger(parts[(fade||range)?2:1]);
if(n<1 || (!single && !fade && fields<3)) return false;
const int b=(single||fade) ? n : (int)StringToInteger(parts[range?3:2]);
if(b<1) return false;
int idx=DSLocalSlot(rule,sym,tf);
if(idx<0) return false;
if(dsLocalCache[idx].decision==cutoff) { side=dsLocalCache[idx].side; return true; }
const datetime first=DSFirstH1(sym);
if(first<=0) return false;
if(cutoff<=first) { side=0; return true; }
MqlRates r[];
int count=0;
if(dsLocalCache[idx].seen==0)
{
// A native first partial D1/H4 bar may differ slightly from the H1-derived
// research bar in its high/low. Subsequent completed broker bars align.
const datetime start=(datetime)((long)first/PeriodSeconds(tf)*PeriodSeconds(tf));
count=CopyRates(sym,tf,start,cutoff-1,r);
}
else
{
const int last=iBarShift(sym,tf,cutoff-1,false);
const int old=iBarShift(sym,tf,dsLocalCache[idx].seen,true);
if(last<0 || old<last) return false;
count=CopyRates(sym,tf,last,old-last+n+3,r);
}
if(count<=0) return false;
for(int i=0;i<count;i++)
{
if(r[i].time<=dsLocalCache[idx].seen || r[i].time>=cutoff) continue;
DSStateStep(dsLocalCache[idx],r,i,family,n,b,fade);
dsLocalCache[idx].seen=r[i].time;
}
dsLocalCache[idx].decision=cutoff;
side=dsLocalCache[idx].side;
return true;
}
int DSCurrencyIndex(const string currency)
{
string names[]={"USD","EUR","GBP","CHF","JPY","CAD","AUD","NZD"};
for(int j=0;j<8;j++) if(names[j]==currency) return j;
return -1;
}
bool DSStrength(const string rule,const string sym,const ENUM_TIMEFRAMES tf,
const datetime cutoff,const int lookback,const bool reversal,int &side)
{
int target=DSLocalSlot(rule,sym,tf);
if(target<0) return false;
if(dsLocalCache[target].decision==cutoff) { side=dsLocalCache[target].side; return true; }
const int n=ArraySize(DSUniverse);
datetime times[]; double changes[],scores[]; bool valid[],ranked[];
ArrayResize(times,n);ArrayResize(changes,n);ArrayResize(scores,n);
ArrayResize(valid,n);ArrayResize(ranked,n);
datetime latest=0;int base[],quote[];
ArrayResize(base,n);ArrayResize(quote,n);
for(int j=0;j<n;j++)
{
base[j]=DSCurrencyIndex(StringSubstr(DSUniverse[j],0,3));
quote[j]=DSCurrencyIndex(StringSubstr(DSUniverse[j],3,3));
valid[j]=false;ranked[j]=false;times[j]=0;changes[j]=0;
if(base[j]<0 || quote[j]<0) continue;
const string code=DSBrokerSymbol(DSUniverse[j]);
const datetime origin=DSFirstH1(code);
if(origin<=0 || cutoff<=origin) continue;
MqlRates rates[];
const int got=CopyRates(code,tf,cutoff-1,lookback+1,rates);
if(got<=0) return false;
times[j]=rates[got-1].time;
if(times[j]>latest) latest=times[j];
const datetime firstBar=(datetime)((long)origin/PeriodSeconds(tf)*PeriodSeconds(tf));
if(got!=lookback+1 || rates[0].time<firstBar) continue;
changes[j]=MathLog(rates[got-1].close/rates[0].close);
valid[j]=true;
}
double totals[8]; int counts[8]; ArrayInitialize(totals,0);ArrayInitialize(counts,0);
for(int j=0;j<n;j++) if(valid[j] && times[j]==latest)
{
totals[base[j]]+=changes[j];totals[quote[j]]-=changes[j];
counts[base[j]]++;counts[quote[j]]++;
}
int total=0;
for(int j=0;j<n;j++) if(base[j]>=0 && quote[j]>=0 && counts[base[j]]>=3 && counts[quote[j]]>=3)
{
scores[j]=totals[base[j]]/counts[base[j]]-totals[quote[j]]/counts[quote[j]];
ranked[j]=true;total++;
}
for(int j=0;j<n;j++) if(base[j]>=0 && quote[j]>=0)
{
int result=0;
if(ranked[j])
{
int lower=0,ties=0;
for(int k=0;k<n;k++) if(ranked[k])
{
if(scores[k]<scores[j]) lower++;
if(scores[k]==scores[j]) ties++;
}
double rank=(lower+(ties+1)*.5)/total;
result=(rank>.75 ? 1 : (rank<=.25 ? -1 : 0))*(reversal ? -1 : 1);
}
const int slot=DSLocalSlot(rule,DSBrokerSymbol(DSUniverse[j]),tf);
if(slot<0) return false;
dsLocalCache[slot].side=result;dsLocalCache[slot].decision=cutoff;
}
side=dsLocalCache[target].side;
return dsLocalCache[target].decision==cutoff;
}
// Relative-value regressions align broker bar opening times across the frozen universe.
// The 220 completed union bars cover the 80-bar regression, 60-bar residual
// volatility and the longest 20-bar accumulation used by a single decision.
#define DS_RV_BARS 220
#define DS_RV_PAIRS 28
double dsRVC[DS_RV_BARS][DS_RV_PAIRS];
datetime dsRVT[DS_RV_BARS];
datetime dsRVWindow=0;
ENUM_TIMEFRAMES dsRVTF=PERIOD_CURRENT;
int dsRVCount=0;
bool DSRelativeHistory(const ENUM_TIMEFRAMES tf,const datetime cutoff)
{
if(dsRVWindow==cutoff && dsRVTF==tf) return true;
int n=ArraySize(DSUniverse);
if(n>DS_RV_PAIRS || n<1) return false;
datetime merged[];
ArrayResize(merged,n*DS_RV_BARS);
int total=0;
for(int j=0;j<n;j++)
{
string sym=DSBrokerSymbol(DSUniverse[j]);
datetime origin=DSFirstH1(sym);
if(origin<=0 || cutoff<=origin) continue;
MqlRates a[];
int count=CopyRates(sym,tf,cutoff-1,DS_RV_BARS,a);
if(count<=0) return false;
datetime first=(datetime)((long)origin/PeriodSeconds(tf)*PeriodSeconds(tf));
for(int k=0;k<count;k++) if(a[k].time>=first) merged[total++]=a[k].time;
}
if(total==0) { dsRVCount=0; dsRVWindow=cutoff;dsRVTF=tf;return true; }
ArrayResize(merged,total);ArraySort(merged);
int unique=0;
for(int k=0;k<total;k++) if(k==0 || merged[k]!=merged[k-1]) merged[unique++]=merged[k];
const int rows=MathMin(unique,DS_RV_BARS);
for(int t=0;t<rows;t++)
{
dsRVT[t]=merged[unique-rows+t];
for(int j=0;j<n;j++) dsRVC[t][j]=0;
}
for(int j=0;j<n;j++)
{
string sym=DSBrokerSymbol(DSUniverse[j]);
datetime origin=DSFirstH1(sym);
if(origin<=0 || cutoff<=origin) continue;
datetime first=(datetime)((long)origin/PeriodSeconds(tf)*PeriodSeconds(tf));
MqlRates a[];
int got=CopyRates(sym,tf,cutoff-1,DS_RV_BARS,a);
if(got<=0) return false;
int t=0;
for(int k=0;k<got;k++)
{
if(a[k].time<first) continue;
while(t<rows && dsRVT[t]<a[k].time) t++;
if(t<rows && dsRVT[t]==a[k].time) dsRVC[t][j]=a[k].close;
}
}
dsRVCount=rows; dsRVWindow=cutoff; dsRVTF=tf;
return true;
}
bool DSRelative(const string rule,const string sym,const ENUM_TIMEFRAMES tf,const datetime cut,
const int n,int &side)
{
const int slot=DSLocalSlot(rule,sym,tf);
if(slot<0 || n<1 || n>20) return false;
if(dsLocalCache[slot].decision==cut) { side=dsLocalCache[slot].side; return true; }
if(!DSRelativeHistory(tf,cut)) return false;
int symbol=-1,jrisk[DS_RV_PAIRS],nr=0;
string risk="|AUDJPY|AUDCHF|NZDJPY|NZDCHF|CADJPY|CADCHF|";
for(int j=0;j<ArraySize(DSUniverse);j++)
{
if(DSBrokerSymbol(DSUniverse[j])==sym) symbol=j;
else if(StringFind(risk,"|"+DSUniverse[j]+"|")>=0) jrisk[nr++]=j;
}
if(symbol<0)return false;
side=0;
if(nr>=2 && dsRVCount>=121)
{
double factor[DS_RV_BARS],own[DS_RV_BARS],resid[DS_RV_BARS];
ArrayInitialize(factor,EMPTY_VALUE);ArrayInitialize(own,EMPTY_VALUE);ArrayInitialize(resid,EMPTY_VALUE);
for(int t=1;t<dsRVCount;t++)
{
if(dsRVC[t][symbol]>0 && dsRVC[t-1][symbol]>0)
own[t]=MathLog(dsRVC[t][symbol]/dsRVC[t-1][symbol]);
int cnt=0; double sum=0;
for(int k=0;k<nr;k++)
{
int id=jrisk[k];
if(dsRVC[t][id]>0 && dsRVC[t-1][id]>0)
{ sum+=MathLog(dsRVC[t][id]/dsRVC[t-1][id]);cnt++; }
}
if(cnt>=2)factor[t]=sum/cnt;
if(t<61 || factor[t]==EMPTY_VALUE || own[t]==EMPTY_VALUE) continue;
int nv=0,np=0;double vf=0,vff=0,sx=0,sy=0,sxy=0;
for(int k=MathMax(1,t-80);k<t;k++)
{
if(factor[k]==EMPTY_VALUE)continue;
nv++;vf+=factor[k];vff+=factor[k]*factor[k];
if(own[k]==EMPTY_VALUE)continue;
np++;sx+=factor[k];sy+=own[k];sxy+=factor[k]*own[k];
}
if(nv<60 || np<60)continue;
double variance=(vff-vf*vf/nv)/(nv-1);
if(variance>0) resid[t]=own[t]-(sxy-sx*sy/np)/(np-1)/variance*factor[t];
}
double mean=0,m2=0,move=0;int valid=0;
for(int t=dsRVCount-60;t<dsRVCount;t++)
{
if(resid[t]==EMPTY_VALUE)break;
valid++;
double d=resid[t]-mean;mean+=d/valid;m2+=d*(resid[t]-mean);
if(t>=dsRVCount-n)move+=resid[t];
}
if(valid==60 && m2>0 && MathAbs(move)>MathSqrt(m2/59*n)) side=-DSLocalSign(move);
}
dsLocalCache[slot].decision=cut;dsLocalCache[slot].side=side;return true;
}
bool SlowTarget(const string rule,const string sym,const ENUM_TIMEFRAMES tf,const datetime barOpen,int &side)
{
side=0;
const int width=PeriodSeconds(tf);
if((tf!=PERIOD_H4 && tf!=PERIOD_D1) || width<=0) return false;
const datetime cutoff=(datetime)((long)barOpen/width*width);
string parts[];
if(StringSplit(rule,'_',parts)==2 && parts[0]=="relfade")
return DSRelative(rule,sym,tf,cutoff,(int)StringToInteger(parts[1]),side);
if(StringSplit(rule,'_',parts)==2 && (parts[0]=="strength" || parts[0]=="strengthrev"))
return DSStrength(rule,sym,tf,cutoff,(int)StringToInteger(parts[1]),parts[0]=="strengthrev",side);
return DSLocalTarget(rule,sym,tf,cutoff,side);
}
double Component0[]={1.0};
bool SelectedWeight(const int leg,const string sym,const datetime hour,double &weight)
{
weight=0;
int side=0;
if(Component0[leg]>0)
{
side=0;
if(!SlowTarget("rsi_14_20",sym,PERIOD_H4,hour,side) || side< -1 || side>1) return false;
weight+=side*Component0[leg];
}
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; // Unique tag for the tester's monthly equity file.
input double Exposure = 1.0;
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)
{
if(canonical=="BTCUSD" || canonical=="SOLUSD" || canonical=="ETHUSD") return true;
if(StringLen(canonical)!=6) return false;
const string base=StringSubstr(canonical,0,3), quote=StringSubstr(canonical,3);
const string fx="|USD|EUR|GBP|JPY|CHF|CAD|AUD|NZD|";
return base!=quote && StringFind(fx,"|"+base+"|")>=0 && StringFind(fx,"|"+quote+"|")>=0;
}
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 || !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;
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);
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| Type | File | Notes | Size | DL | SHA-256 | Uploaded |
|---|---|---|---|---|---|---|
| FILE | MT5_monthly_marked_equity.csv latest | Native MT5 calendar-month equity and balance across available runs. Equity includes floating P&L. Source, symbol, date and test-window keys distinguish multiple presets and independent cash accounts. | 104.6 KB | 0 | 014170984d3f | 2026-11-29 08:13 |
| BACKTEST | FX_AUDCAD_RSI1_AUDCAD_2014-01-01_2026-11-01_full_MT5.html latest | real-tick mode. 2014-01-01 through 2026-10-31. MT5 booked $56,220.67 with zero commission. The fixed-fill replay of the 0.0014% exit fee estimates $55,675.46 net without resizing. Every deal and 4 original chart images are included. Orders table omitted to reduce file size. | 1.5 MB | 0 | 6e99d4790c5a | 2026-11-29 08:13 |
| BACKTEST | FX_AUDCAD_RSI1_AUDCAD_2025-01-01_2026-11-01_holdout_MT5.html latest | real-tick mode. 2025-01-01 through 2026-10-31. MT5 booked $6,232.33 with zero commission. The fixed-fill replay of the 0.0014% exit fee estimates $6,175.83 net without resizing. Every deal and 4 original chart images are included. Orders table omitted to reduce file size. | 254.7 KB | 0 | fd06b7c98685 | 2026-11-29 08:13 |
| BACKTEST | FX_AUDCAD_RSI540_AUDCAD_2014-01-01_2026-11-01_full_MT5.html latest | real-tick mode. 2014-01-01 through 2026-10-31. MT5 booked $686,788.95 with zero commission. The fixed-fill replay of the 0.0014% exit fee estimates $678,586.01 net without resizing. Every deal and 4 original chart images are included. Orders table omitted to reduce file size. | 6.5 MB | 0 | 8e988fa83d55 | 2026-11-29 08:13 |
| BACKTEST | FX_AUDCAD_RSI540_AUDCAD_2025-01-01_2026-11-01_holdout_MT5.html latest | real-tick mode. 2025-01-01 through 2026-10-31. MT5 booked $32,588.34 with zero commission. The fixed-fill replay of the 0.0014% exit fee estimates $32,226.24 net without resizing. Every deal and 4 original chart images are included. Orders table omitted to reduce file size. | 851.6 KB | 0 | 47024fe56b6b | 2026-11-29 08:13 |
| FILE | audcad-rsi-exit-commission-replay.csv latest | Separate H1 replays with the 0.0014% exit commission on net position reductions, estimated spread and slippage, and either zero financing or a 3% annual financing stress. Each window starts from $100,000. Daily historical broker swap rates are unavailable. | 1.6 KB | 0 | 1bae9f209481 | 2026-11-29 01:24 |
| BACKTEST | FX_AUDCAD_RSI540_AUDCAD_2008-01-01_to_2014-01-01_earlier.html latest | FX_AUDCAD_RSI540 on AUDCAD, Jan 2008–Dec 2013. The original MT5 statement booked −$23,545.98 with zero exit commission. Repricing the same fills for the 0.0014% exit fee gives −$24,435.83. H1 host, MT5 real-tick mode. Includes native settings, results and every deal. Order-request rows are omitted. | 2.7 MB | 0 | 2dade8799cf4 | 2026-11-29 01:22 |
| BACKTEST | FX_AUDCAD_RSI1_AUDCAD_2025-01-01_to_2026-11-01_holdfee.html latest | FX_AUDCAD_RSI1 on AUDCAD, Jan 2025–Oct 2026. MT5 booked +$6,253.93 including its 0.0014% exit commission. H1 host, MT5 real-tick mode. Includes native settings, results and every deal. Order-request rows are omitted. | 255.1 KB | 0 | 838e064017cb | 2026-11-29 01:22 |
| BACKTEST | FX_AUDCAD_RSI1_AUDCAD_2014-01-01_to_2026-11-01_fullfee.html latest | FX_AUDCAD_RSI1 on AUDCAD, Jan 2014–Oct 2026. MT5 booked +$56,167.98 including its 0.0014% exit commission. H1 host, MT5 real-tick mode. Includes native settings, results and every deal. Order-request rows are omitted. | 1.5 MB | 0 | 3e32626bbcb2 | 2026-11-29 01:22 |
| FILE | audcad-rsi-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.0 KB | 0 | a432ff9c8906 | 2026-11-29 01:22 |
| FILE | audcad-rsi-additional-implementations.zip latest | Additional original MQL5 source files and corresponding tester presets for FX_AUDCAD_RSI540, FX_AUDCAD_RSI6. Each variant’s evidence basis appears in the window CSV. | 15.0 KB | 0 | 2a132ec9caf9 | 2026-11-29 01:22 |
| PARAMS | FX_AUDCAD_RSI1.set latest | Test inputs from the matching source. The public preset uses tester mode and a neutral journal token where supported. | 92 B | 0 | d512c9ce096a | 2026-11-29 01:22 |
| SOURCE | FX_AUDCAD_RSI1.mq5 latest | Original MQL5 source, matched to the frozen SHA-256. | 24.2 KB | 0 | 6eb1f7f88384 | 2026-11-29 01:22 |