preview
MiniRocket: A Deterministic Time-Series Classifier and What It Finds in Seven Classic Setups

MiniRocket: A Deterministic Time-Series Classifier and What It Finds in Seven Classic Setups

MetaTrader 5 — Trading |
2 488 0
Muhammad Minhas Qamar
Muhammad Minhas Qamar

Introduction

On this platform, "machine learning for time series" has come to mean a neural network, an ONNX export, and a Python dependency kept alive alongside the terminal. The wider literature has spent years showing that cost is not always necessary: methods built on fixed, untrained convolution kernels match deep models across the standard benchmark archives at a fraction of the compute.

This article ports one of those methods, MiniRocket, to native MQL5. It turns a window of prices into roughly ten thousand features using 84 fixed convolution kernels, then hands them to a linear model. There is no training loop, no gradient descent, no ONNX, and no Python at runtime, and one window takes about two milliseconds to transform.

A classifier solves only half the problem. The second half is the one nobody writes about: when a model finds nothing in a classic setup, you cannot tell whether the setup has no edge or your pipeline is broken. Because of that, null results rarely get published, and the same setups get argued about forever. We solve that directly, with controls built into the harness that prove the measurement works and show how weak an edge it can still detect. By the end you will have a verified transform, a leak-free audit harness, and a reproducible verdict on seven setups that you can re-run on your own symbol.

We will cover:

  1. How MiniRocket Works
  2. 84 Kernels for the Price of Nine
  3. Building the Transform in MQL5
  4. Proving the Port Is Exact
  5. What the Kernels Cannot See
  6. A Ridge Classifier in the Dual
  7. The Testbed and Its Controls
  8. What the Audit Found
  9. Reading a Model Across Time Scales
  10. Scoring Triggers on a Live Chart
  11. Conclusion


How MiniRocket Works

MiniRocket is a fixed feature transform, not a model: feed it a window of numbers, get roughly ten thousand numbers in [0,1] back, then put any linear classifier on top. Its ancestor, ROCKET, generated ten thousand random convolution kernels and pooled two statistics from each. MiniRocket removes almost all of the randomness and loses almost none of the accuracy, which is what makes it worth porting rather than reinventing.

Three restrictions do the work.

Every kernel, not a sample of them

Kernels are fixed at length 9, and every weight is either -1 or 2, with exactly three of the nine positions carrying the 2. There are C(9,3) = 84 ways to choose which three, and MiniRocket uses all of them. Nothing is sampled or seeded here, so two runs on the same data produce the same 84 kernels in the same order.

The weights sum to 3*2 + 6*(-1) = 0. That zero sum decides what the transform is capable of noticing at all, and What the Kernels Cannot See returns to it.

//--- the transform is defined on length-9 kernels and nothing else;
//--- these are structural constants of the method, not tunables.
#define MR_KERNEL_LENGTH   9
#define MR_NUM_KERNELS     84
#define MR_GAMMA_ROWS      9

Enumerating them is three nested loops, in lexicographic order so that kernel index 41 means the same thing here as in the reference:

//+------------------------------------------------------------------+
//| The 84 kernels are every way of choosing which three of the nine |
//| taps carry weight 2, enumerated in lexicographic order so the    |
//| kernel index means the same thing here as in the reference.      |
//+------------------------------------------------------------------+
void CMiniRocket::BuildIndices(void)
  {
   ArrayResize(m_idx,MR_NUM_KERNELS*3);
   int p=0;
   for(int a=0;a<MR_KERNEL_LENGTH;a++)
     {
      for(int b=a+1;b<MR_KERNEL_LENGTH;b++)
        {
         for(int c=b+1;c<MR_KERNEL_LENGTH;c++)
           {
            m_idx[p*3+0]=a;
            m_idx[p*3+1]=b;
            m_idx[p*3+2]=c;
            p++;
           }
        }
     }
  }

One pooled statistic, bounded by construction

ROCKET pools the maximum and the proportion of positive values from each convolution. MiniRocket keeps only the second, PPV, the fraction of convolution outputs exceeding a threshold, which costs very little accuracy and halves the feature count.

PPV is a proportion, so every feature is already bounded in [0,1] and no standardisation step is needed anywhere in the pipeline, which removes an entire category of leakage bug.

Dilation is where the multi-scale behaviour comes from

Eighty-four shapes of nine taps would only ever see nine-bar structure. Dilation spreads those taps further apart, so the same 84 shapes apply at every scale from a nine-bar wiggle to an arc spanning almost the whole window. The spacings come from a logarithmic sequence truncated to integers, which at a 128-bar window collapses to every dilation from 1 to 15, the widest reaching across 121 bars. Nobody had to choose a lookback.

The 84 length-9 kernels and how dilation spreads their taps

Fig. 1. Enumerating the 84 kernels, and the same kernel applied at increasing dilation

The one part that touches training data is the thresholds. Each threshold is a quantile of a convolution output computed on a real training window. That is the only place the transform learns anything, so Fit() must see training windows only. Fitting thresholds on the full series puts the test period's distribution into every one of the ten thousand features at once.


84 Kernels for the Price of Nine

Applying 84 kernels at 15 dilations to a 128-bar window sounds expensive, and done naively it is: 84 nine-term dot products at every output position, at every dilation. MiniRocket runs in milliseconds instead because of one algebraic observation.

Any kernel can be written as a constant -1 plus a correction of +3 at the three chosen taps:

W[j] = -1 + 3 * [ j in S ]

Substituting that into the convolution splits it into two pieces:

C_S[t] = A[t] + G_s1[t] + G_s2[t] + G_s3[t]

Here A[t] is the negated sum of all nine dilated taps, and G_j[t] is three times the input at tap j. The important part is what is missing from A: it does not depend on S, so the same A serves all 84 kernels and is computed once per dilation. G is nine scaled copies of the input, which is where the section title comes from.

Each kernel then costs three additions per output sample instead of a nine-term dot product. That is the whole speed argument, and this is the shared half in code:

//+------------------------------------------------------------------+
//| The shared half of the convolution, computed once per dilation.  |
//|                                                                  |
//|  ca[] receives A[t], the negated sum of all nine dilated taps.   |
//|  cg[] receives the nine rows G_j[t] = 3*x[t + j*d], flattened.   |
//|  Every one of the 84 kernels is then ca plus three rows of cg,   |
//|  which is the whole speed argument made concrete.                |
//|                                                                  |
//|  The taps are laid out around a centre tap so that a kernel is   |
//|  centred on its output sample. Taps left of centre only overlap  |
//|  the input once the window has slid far enough in, which is why  |
//|  their contribution lands at the end of the output and extends   |
//|  by one dilation step per tap; taps right of centre mirror that. |
//+------------------------------------------------------------------+
void CMiniRocket::ConvolveBase(const double &x[],int d,
                               double &ca[],double &cg[]) const
  {
   int L=m_len;
   int padding=((MR_KERNEL_LENGTH-1)*d)/2;
   int mid=MR_KERNEL_LENGTH/2;

   ArrayInitialize(cg,0.0);
   for(int i=0;i<L;i++)
     {
      ca[i]=-x[i];
      cg[mid*L+i]=3.0*x[i];
     }

   int end=L-padding;
   for(int g=0;g<mid;g++)
     {
      int e=(end<L)?end:L;
      if(e>0)
        {
         int off=L-e;
         for(int j=0;j<e;j++)
           {
            ca[off+j]-=x[j];
            cg[g*L+off+j]=3.0*x[j];
           }
        }
      end+=d;
     }

   int start=d;
   for(int g=mid+1;g<MR_KERNEL_LENGTH;g++)
     {
      int m=L-start;
      for(int j=0;j<m;j++)
        {
         ca[j]-=x[start+j];
         cg[g*L+j]=3.0*x[start+j];
        }
      start+=d;
     }
  }

The two loops after the centre tap handle taps on both sides of it. An off-centre tap overlaps the input only once the window has slid far enough in, so its contribution extends by one dilation step per tap. The start accumulator tracks that shift. The gap this leaves at each end is the padded region, and it matters later, in What the Kernels Cannot See.

With A and the nine G rows in hand, one kernel is three array lookups and three adds:

//+------------------------------------------------------------------+
//| One kernel's convolution: the shared term plus its three taps.   |
//+------------------------------------------------------------------+
void CMiniRocket::KernelOut(const double &ca[],const double &cg[],
                            int k,double &c[]) const
  {
   int L=m_len;
   int i0=m_idx[k*3+0]*L;
   int i1=m_idx[k*3+1]*L;
   int i2=m_idx[k*3+2]*L;
   for(int i=0;i<L;i++)
      c[i]=ca[i]+cg[i0+i]+cg[i1+i]+cg[i2+i];
  }

The decomposition: one shared term plus nine scaled copies

Fig. 2. The shared term A is computed once per dilation, then each of the 84 kernels is three adds


Building the Transform in MQL5

The class follows a three-stage lifecycle: Configure() binds the instance to one window length and lays out the feature space, Fit() learns the thresholds from training windows, and Transform() is then callable as often as you like. It binds to a single window length because the dilation schedule is derived from it. In use:

   CMiniRocket mr;
   if(!mr.Configure(InpWindow,InpFeatures,32,InpSeed))
     {
      PrintFormat("%-18s  Configure() rejected",SetupName(s));
      return;
     }

   double train[],w[];
   ArrayResize(train,ntrain*InpWindow);
   for(int i=0;i<ntrain;i++)
     {
      LabFillWindow(sig[lo+i].bar,w);
      for(int k=0;k<InpWindow;k++)
         train[i*InpWindow+k]=w[k];
     }
   if(mr.Fit(train,ntrain)!=MR_OK)
     {
      PrintFormat("%-18s  Fit() failed",SetupName(s));
      return;
     }

   int nf=mr.FeatureCount();
   matrix X(ntrain,nf);
   int ytr[];
   ArrayResize(ytr,ntrain);
   double row[];
   for(int i=0;i<ntrain;i++)
     {
      LabFillWindow(sig[lo+i].bar,w);
      mr.Transform(w,row);
      for(int j=0;j<nf;j++)
         X[i][j]=row[j];
      ytr[i]=sig[lo+i].y;
     }

That excerpt is from the audit script, and its ordering is the whole leakage argument: Fit() sees the training block and nothing else, and only then is Transform() applied. Configure's third argument caps the number of distinct dilations at 32, as in the reference; at a 128-bar window the schedule stops at 15.

Configure does no learning. It enumerates the kernels, derives the dilation schedule, and builds the quantile positions. Two details there are worth calling out, because both are places where a port silently diverges from the reference and nothing looks wrong.

The first is the dilation schedule. With 10,000 features requested there are 119 per kernel, so truemax is the smaller of 119 and the cap of 32, and maxexp is the base-2 logarithm of (window-1)/8, which is 3.989 at a 128-bar window. The reference spreads 32 exponents over that range, then truncates 2 raised to each to an integer. Truncation is unforgiving: a value that should be 16 but arrives as 15.999999 becomes 15, and the whole schedule shifts. The library producing the sequence pins its final point exactly at the stop value rather than accumulating a step up to it. The two differ by one ulp (unit in the last place, the gap between neighbouring representable doubles), which stays invisible until the truncation exposes it. The port has to pin the endpoint the same way:

//--- logspace pins its final point at the stop value instead of
//--- accumulating i*step up to it. Truncating to int makes that one
//--- ulp visible, so reproduce the pinning or the dilation set drifts.
   int raw[];
   ArrayResize(raw,truemax);
   double step=(truemax>1)?maxexp/(double)(truemax-1):0.0;
   for(int i=0;i<truemax;i++)
     {
      double t=((truemax>1) && (i==truemax-1))?maxexp:(double)i*step;
      raw[i]=(int)MathPow(2.0,t);
     }

Those 32 exponents produce many repeats once truncated, and the repeats set how many features each dilation gets: the run length of each distinct value becomes its share of the budget.

The second detail is stranger. Threshold positions come from the golden-ratio low-discrepancy sequence, which spreads them more evenly over [0,1] than random draws would, and the reference stores that sequence at float precision, not double. A position that differs in the seventh digit moves the threshold enough to flip a PPV count on a near-tied sample, so matching that precision is what makes the two implementations comparable to the last digit:

//+------------------------------------------------------------------+
//| Quantile positions come from the golden-ratio low-discrepancy    |
//| sequence, which spreads thresholds far more evenly over [0,1]    |
//| than random draws of the same length would.                      |
//|                                                                  |
//|  The float cast is deliberate. The reference builds this array as|
//|  float32, and a threshold position that differs in the seventh   |
//|  digit moves the bias enough to flip a PPV count on a near-tied  |
//|  sample. Keeping the same precision is what makes the two        |
//|  implementations comparable to the last digit rather than to     |
//|  "close enough".                                                 |
//+------------------------------------------------------------------+
void CMiniRocket::BuildQuantiles(int n)
  {
   ArrayResize(m_quant,n);
   double phi=(MathSqrt(5.0)+1.0)/2.0;
   for(int i=1;i<=n;i++)
      m_quant[i-1]=(double)((float)MathMod((double)i*phi,1.0));
  }

Fit then walks the feature layout, drawing a training window for each kernel, convolving it, and reading the thresholds off the sorted output:

   m_rng=m_seed;

   double ca[],cg[],c[],srt[],ex[];
   ArrayResize(ca,m_len);
   ArrayResize(cg,MR_GAMMA_ROWS*m_len);
   ArrayResize(c,m_len);
   ArrayResize(srt,m_len);
   ArrayResize(ex,m_len);

   int fstart=0;
   for(int di=0;di<m_ndil;di++)
     {
      int d=m_dil[di];
      int nthis=m_nfpd[di];
      for(int k=0;k<MR_NUM_KERNELS;k++)
        {
         int pick=(int)(NextRand()%(uint)num_examples);
         for(int i=0;i<m_len;i++)
            ex[i]=X[pick*m_len+i];
         ConvolveBase(ex,d,ca,cg);
         KernelOut(ca,cg,k,c);
         ArrayCopy(srt,c);
         ArraySort(srt);
         for(int f=0;f<nthis;f++)
            m_bias[fstart+f]=Quantile(srt,m_len,m_quant[fstart+f]);
         fstart+=nthis;
        }
     }

This is an excerpt from the body of Fit(). ConvolveBase is called inside the kernel loop, which throws away the sharing we just built; that is deliberate, because each kernel draws its own training window and the shared term genuinely differs per kernel at fit time. Fit runs once; Transform runs on every window forever, which is where the hoisting pays off. The draw uses NextRand(), a small seeded generator, so a given seed and training set always reproduce the transform.

Transform pulls it together: one ConvolveBase per dilation, then 84 cheap kernels, then a PPV count per threshold:

   double ca[],cg[],c[];
   ArrayResize(ca,m_len);
   ArrayResize(cg,MR_GAMMA_ROWS*m_len);
   ArrayResize(c,m_len);

   int fstart=0;
   for(int di=0;di<m_ndil;di++)
     {
      int d=m_dil[di];
      int nthis=m_nfpd[di];
      int padding=((MR_KERNEL_LENGTH-1)*d)/2;
      ConvolveBase(x,d,ca,cg);
      for(int k=0;k<MR_NUM_KERNELS;k++)
        {
         KernelOut(ca,cg,k,c);
         int lo=(((di+k)%2)==0)?0:padding;
         int hi=(((di+k)%2)==0)?m_len:m_len-padding;
         int n=hi-lo;
         for(int fi=0;fi<nthis;fi++)
           {
            double b=m_bias[fstart+fi];
            int cnt=0;
            for(int i=lo;i<hi;i++)
              {
               if(c[i]>b)
                  cnt++;
              }
            f[fstart+fi]=(n>0)?((double)cnt/(double)n):0.0;
           }
         fstart+=nthis;
        }
     }

The lo and hi bounds alternate by dilation and kernel index, the reference's rule rather than a choice made here: half the kernels score the full padded convolution, half score only its centre. Padded outputs include samples where the kernel hangs off the edge, making those features sensitive to where a pattern sits, while the centre-only ones answer only whether it is present. Carrying both lets a linear model pick either behaviour per feature, and it has a consequence nobody mentions.


Proving the Port Is Exact

Given a seed, MiniRocket is deterministic, which turns "does my port work?" from a judgement call into an equality test: if two implementations disagree by anything at all, one of them is wrong.

The validation script builds a fixture rather than using live prices, so anyone can regenerate byte-identical input, and it is deliberately not a single sine wave:

//+------------------------------------------------------------------+
//| Build one contiguous series long enough to cut into windows.     |
//|                                                                  |
//|  The fixture mixes two incommensurate periods so that dilations  |
//|  at different scales see genuinely different structure; a single |
//|  sine would make most of the schedule redundant and hide an error|
//|  in the dilation bookkeeping behind near-identical features.     |
//+------------------------------------------------------------------+
void BuildFixture(double &s[],int n,int seed)
  {
   ArrayResize(s,n);
   MathSrand(seed);
   for(int i=0;i<n;i++)
     {
      double noise=((double)MathRand()/32767.0-0.5)*0.6;
      s[i]=MathSin(2.0*M_PI*i/20.0)+0.5*MathSin((double)i/7.0)+noise;
     }
  }

The script cuts that series into overlapping windows, fits on the first block only, transforms the rest, and writes the input matrix and the output features to the terminal's Files folder, so an external reference runs on the same numbers. Doubles are written with seventeen significant digits, which round-trips a double exactly, making the comparison bit-level rather than "agrees to six decimals":

//+------------------------------------------------------------------+
//| Write a matrix of windows so the reference implementation can be |
//| run on byte-identical input. Seventeen significant digits round  |
//| trip a double exactly, which is what turns the comparison from   |
//| "agrees to six places" into a real equality test.                |
//+------------------------------------------------------------------+
bool DumpMatrix(string fname,const double &m[],int rows,int cols)
  {
   int h=FileOpen(fname,FILE_WRITE|FILE_TXT|FILE_ANSI);
   if(h==INVALID_HANDLE)
     {
      PrintFormat("Could not write %s (err %d)",fname,GetLastError());
      return false;
     }

   string nl=CharToString(13)+CharToString(10);
   for(int r=0;r<rows;r++)
     {
      for(int c=0;c<cols;c++)
        {
         if(c>0)
            FileWriteString(h,",");
         FileWriteString(h,StringFormat("%.17g",m[r*cols+c]));
        }
      FileWriteString(h,nl);
     }
   FileClose(h);
   PrintFormat("Wrote %s  (%d x %d)",fname,rows,cols);
   return true;
  }

Running it on a 128-bar window with 10,000 features requested gives the schedule and the cost:

window=128  requested=10000  realised=9996  dilations=15
dilation/features-per-kernel: 1/30 2/19 3/12 4/12 5/8 6/4 7/8 8/4 9/4 10/3 11/3 12/3 13/3 14/3 15/3
Fit  32 windows : 33.1 ms
Xform 8 windows: 18.3 ms  (2.292 ms/window)

The per-kernel counts sum to exactly 119, which is the budget, and 84 * 119 = 9,996. Transforming a window costs 2.3 ms, timed with GetMicrosecondCount rather than GetTickCount, whose roughly 16 ms resolution is coarser than several transforms put together.

Against an independent float64 reimplementation written from the algorithm rather than translated from the port, the two agree perfectly:

max abs diff  : 0.000e+00
mean abs diff : 0.000e+00
exact matches : 79968 / 79968

That is 8 windows times 9,996 features, bit-identical in double precision. A clean-room reference is good evidence, but the same person wrote both, so the second check goes against sktime, the established Python library whose implementation is the de facto standard.

One obstacle first: the installed sktime would not import, because its numba dependency pins NumPy to 2.2 or below and the environment had 2.4. Rather than rebuild the environment, the module is executed from its own source with the JIT decorator replaced by a no-op. That stays fair, because njit is a compilation directive, not a semantic one: the arithmetic under test is still sktime's, line for line.

def load_sktime():
    src = open(SKPATH, encoding="utf-8").read()
    src = src.replace("from sktime.utils.numba.njit import njit", "pass")
    src = src.replace(
        "from skbase.utils.dependencies import _check_soft_dependencies", "pass")
    ns = {
        "np": np,
        "njit": lambda *a, **k: (lambda f: f),
        "prange": range,
        "_check_soft_dependencies": lambda *a, **k: False,
        "_PPV": lambda a, b: (a > b).astype(np.float32),
    }
    exec(compile(src, SKPATH, "exec"), ns)
    return ns["_fit"], ns["_transform"]

One further wrinkle: sktime picks which training window each threshold is drawn from using NumPy's Mersenne Twister, which no other implementation can reproduce. Fitting on a single training window removes that choice entirely, since a random index into a set of one is always zero, while leaving the dilation schedule, the quantile sequence, the convolution decomposition, the padding rule and PPV all under test:

exact matches    : 49529 / 79968   (61.94%)
max abs diff     : 2.781550e-08
largest as count : 0.0000 samples out of 128

--- at the reference's own float32 output precision ---
exact matches    : 79968 / 79968
max abs diff     : 0.000000e+00

The top block looks like a partial failure. It is not, and the third line says why. PPV is a count divided by a segment length, so a genuine disagreement can only move a feature by a whole multiple of 1/length, and the largest difference here is 0.0000 samples out of 128: every PPV count agrees exactly. What differs is the stored ratio, because sktime returns float32 and segments scored without padding have a length that is not a power of two, so count/length is inexact there. Cast our doubles to sktime's own output precision and all 79,968 features match bit for bit.

Validation script output and the reference comparison

Fig. 3. The validation run and both reference comparisons


What the Kernels Cannot See

Back to the zero-sum property, because it constrains the whole experiment. A full nine-tap convolution whose weights sum to zero cannot respond to a constant added to its input. Add 0.37 to every value in a window and every such convolution output is unchanged, so every PPV built from it is unchanged too. The kernels are blind to the level of whatever series you feed them.

That is the theory, and the padded features complicate it enough to be worth measuring. Take a window, add a constant, re-transform, and count how many features moved:

feature group                     n  differing     max diff
padded (edges included)        4998       2799    1.641e-01
centre only                    4998          0    0.000e+00

Half the feature set is exactly invariant, bit for bit. The other half is not, and the reason is the padding: near the window edges only part of the kernel overlaps the data, and a partial kernel no longer sums to zero. A level shift applied to the whole window therefore survives the transform, but only through those edges.

Level invariance: centre features frozen, padded features responding at the edges

Fig. 4. Shifting a window vertically leaves the centre-scored features untouched and moves only the padded ones

That qualifier decides something that would otherwise look like a preprocessing detail: what do we feed the transform? Log returns are the reflexive choice in finance, but the level of a return series is the window's net drift, so the worry is that feeding returns throws away whether a setup is firing with the trend or against it.

The honest way to settle that is to plant a label whose answer is known and see whether it can be recovered. Recovery is measured by AUC, the area under the ROC curve: the probability that a randomly drawn positive is ranked above a randomly drawn negative, where 0.500 is chance and 1.000 is perfect. Two labels were planted, one living in the level of the return series (the sign of the sum of the last eight returns) and one a pure contrast (the last four moves against the four before them), each tried against both window contents:

window content   planted label          AUC
log price        8-bar drift          0.861
log price        4v4 contrast         0.790
log returns      8-bar drift          0.936
log returns      4v4 contrast         0.715

The drift label is recovered more easily from returns than from prices, so the worry is misplaced. The tempting explanation is the edge behaviour above: the label lives at the recent end of the window, exactly where the padded features respond to level. That is testable, and it is wrong. Splitting the feature set as before and refitting on each half alone gives:

feature group                 nfeat     AUC
all features                   9996   0.936
padded (edges included)        4998   0.916
centre only (invariant)        4998   0.953

The centre-only features, the ones provably blind to level, recover the drift label better than the padded ones, so the edges are not the route. The blindness is simply narrower than it sounds: a zero-sum kernel ignores a constant added to the whole window, but the last eight returns sitting higher than the hundred and twenty before them is not a constant, it is a step part-way through the window. That is a contrast, and contrasts are exactly what these kernels compute.

Worth carrying away: "the kernels cannot see level" holds only for a level shared by the entire window. Any local change in level is shape, and shape is what the transform is made of. Two plausible readings of the invariance result pointed the wrong way here, and only refitting on each half settled it.

Neither window content dominates: returns recover the drift label better, prices the contrast. So window content is an input rather than a hard-coded assumption. The audit below uses log prices, the stronger of the two for contrast-shaped labels, and the planted control is itself a contrast:

//+------------------------------------------------------------------+
//| The window of context ending at bar i, in whichever form the     |
//| experiment asked for. See ENUM_LAB_INPUT for why this matters.   |
//+------------------------------------------------------------------+
void LabFillWindow(int i,double &w[])
  {
   int n=g_cfg.window;
   ArrayResize(w,n);
   int start=i-n+1;
   for(int k=0;k<n;k++)
     {
      int b=start+k;
      double c=g_close[b];
      if(g_cfg.input_kind==LAB_LOGPRICE)
        {
         w[k]=(c>0.0)?MathLog(c):0.0;
         continue;
        }
      double a=g_close[b-1];
      w[k]=(a>0.0 && c>0.0)?MathLog(c/a):0.0;
     }
  }


A Ridge Classifier in the Dual

The transform hands over 9,996 features, and a setup might fire a few hundred to a couple of thousand times in six years of hourly bars. Fitting a linear model with far more features than rows is workable, provided it is set up correctly.

The obvious route, the normal equations, needs a 9,996 by 9,996 matrix: 800 MB, and singular besides, since a matrix built from 1,200 rows cannot have rank above 1,200. The dual form works with the n by n Gram matrix instead:

a = inverse(G + alpha*I) * y        w = transpose(X) * a

where G = X transpose(X). Both routes give the same weights; only one fits in memory. At 1,200 training rows the Gram matrix is about 11 MB.

The second idea makes the penalty free to tune. Eigendecompose the Gram matrix once, as G = V L transpose(V). Then for any alpha the fitted values are

yhat = V diag(L/(L+alpha)) transpose(V) y

so sweeping alpha costs one matrix-vector product each, not a fresh solve. Better still, ridge regression has a closed-form leave-one-out residual, (y_i - yhat_i)/(1 - H_ii), where H_ii is the leverage of row i. Every alpha can therefore be scored by true leave-one-out without refitting and without spending a validation split, which matters when a setup supplies only a few hundred signals.

MQL5's native matrix type carries the linear algebra, so this is short:

//--- the Gram matrix is symmetric positive semi-definite, so its
//--- eigenvalues are real and its eigenvectors orthonormal.
   matrix G=Xc.MatMul(Xc.Transpose());
   matrix V;
   vector lam;
   if(!G.Eig(V,lam))
      return false;
   for(int k=0;k<m_n;k++)
     {
      if(lam[k]<0.0)
         lam[k]=0.0;
     }

The eigenvalue clamp is not cosmetic: a Gram matrix is positive semi-definite in exact arithmetic, but the smallest eigenvalues come back as tiny negatives at floating-point precision, and a negative one would produce a nonsensical shrinkage factor.

The sweep is then a few lines per candidate:

   for(int t=0;t<nalpha;t++)
     {
      double al=alphas[t];
      if(al<=0.0)
         continue;
      for(int k=0;k<m_n;k++)
         d[k]=lam[k]/(lam[k]+al);
      vector yhat=V.MatMul(d*z);
      vector hii=V2.MatMul(d);
      double sse=0.0;
      bool ok=true;
      for(int i=0;i<m_n;i++)
        {
         double den=1.0-hii[i];
         if(MathAbs(den)<1.0e-10)
           {
            ok=false;
            break;
           }
         double r=(yc[i]-yhat[i])/den;
         sse+=r*r;
        }
      if(!ok)
         continue;
      double loo=sse/(double)m_n;
      if(best<0 || loo<bestloo)
        {
         best=t;
         bestloo=loo;
        }
     }

One reporting problem remains. When a feature set carries no signal, the leave-one-out error falls monotonically as the penalty rises, heading towards the model with no features at all, so its minimum sits at infinity and whatever grid you supply reports its own top end as the answer. The grid used throughout is nine points from 1 to 1e8, and a selected alpha of 1e8 tells you something is wrong.

The fix is to measure the fitted model against that same no-features baseline with the identical formula. For a model with only an intercept, every leverage is 1/n and every fitted value is the mean:

   double sy=0.0;
   for(int i=0;i<m_n;i++)
      sy+=yc[i]*yc[i];
   double shrink=1.0-1.0/(double)m_n;
   m_loonull=(sy/(double)m_n)/(shrink*shrink);

One minus the ratio of the two is a leave-one-out R-squared that reads directly: near zero means the 9,996 features added nothing over predicting the mean.


The Testbed and Its Controls

With a verified transform and a classifier, we can ask the question the article exists for: do the bars before a familiar setup say anything about whether that instance will work?

Seven setups go on trial, each a rule the forums already believe in: engulfing, pin bar, inside-bar break, a 20/50 EMA cross, RSI crossing 30 or 70, a Bollinger band touch, and a 20-bar Donchian break. Each fires a direction at a bar, reading that bar and earlier only.

Turning a trigger into a label uses the triple-barrier method: symmetric barriers at 1.5 ATR and a vertical barrier 24 bars out. Two cases are deliberately dropped rather than labelled:

//+------------------------------------------------------------------+
//| Resolve a trigger with the triple-barrier method: symmetric      |
//| barriers at barrier_k ATRs and a vertical barrier horizon bars   |
//| out. Returns +1 if the setup was right, -1 if wrong, 0 to drop.  |
//|                                                                  |
//|  Two cases are deliberately dropped rather than labelled. If     |
//|  neither barrier is touched the move had no conviction either    |
//|  way, and forcing it into a class teaches the model to call drift|
//|  a win. If both are touched on the same bar the intrabar path    |
//|  decides the answer and OHLC does not record it, so the only     |
//|  honest label is none.                                           |
//+------------------------------------------------------------------+
int LabLabel(int bar,int dir)
  {
   double atr=g_atr[bar];
   if(atr<=0.0)
      return 0;
   double entry=g_close[bar];
   double up=entry+g_cfg.barrier_k*atr;
   double dn=entry-g_cfg.barrier_k*atr;

   int last=bar+g_cfg.horizon;
   if(last>=g_bars)
      return 0;
   for(int j=bar+1;j<=last;j++)
     {
      bool hu=(g_high[j]>=up);
      bool hd=(g_low[j]<=dn);
      if(hu && hd)
         return 0;
      if(hu)
         return (dir>0)?1:-1;
      if(hd)
         return (dir>0)?-1:1;
     }
   return 0;
  }

If neither barrier is touched, the move had no conviction either way, and forcing it into a class would teach the model to call drift a win. If both are touched on the same bar, the intraday path decides the answer and OHLC does not record it.

The split is chronological and purged. The first 70% of a setup's triggers are training candidates, but a training trigger whose barrier window reaches into the test period had its label written by bars the test set is meant to be judging, so it is dropped outright, along with a further 12-bar embargo:

//+------------------------------------------------------------------+
//| Chronological split with purging. Returns the index of the first |
//| test signal, and sets trainEnd to the last usable training row.  |
//|                                                                  |
//|  A training trigger whose barrier window reaches into the test   |
//|  period is dropped outright: its label was written by bars the   |
//|  test set is supposed to be judging, so keeping it would let the |
//|  answer leak backwards across the split.                         |
//+------------------------------------------------------------------+
int LabSplit(const SSignal &sig[],int n,double train_frac,int &trainEnd)
  {
   int split=(int)((double)n*train_frac);
   if(split<1)
      split=1;
   if(split>=n)
      split=n-1;
   int splitbar=sig[split].bar;
   trainEnd=0;
   while(trainEnd<split &&
         sig[trainEnd].bar+g_cfg.horizon+g_cfg.embargo<=splitbar)
      trainEnd++;
   return split;
  }

Triple barrier labelling and the purged chronological split

Fig. 5. The triple barrier on a price path, and the purge and embargo gap at the split

Training rows are then capped at the most recent 1,200, the repeated figure in the results table below: both the Gram matrix and the design matrix scale with it, so it is a memory ceiling rather than a modelling choice. Only after the split is MiniRocket fitted, so the thresholds behind all 9,996 features see training bars alone. The acceptance threshold behind the precision figures is likewise a quantile of the training decision values, set to accept the top 30%, because choosing where to cut is one of the easiest places for a selection rule to leak.

The part that makes the answer mean something

Suppose all seven setups come back at AUC 0.50. Is that a fact about the setups, or a bug somewhere in nine hundred lines of new code? Nothing in the table can tell you. So controls run through the identical pipeline and bracket every real result.

The controls do not wait for a pattern to occur; they fire on every eighth bar, so their sample size is set by the experiment rather than by how often a shape appears. One plants a label the window provably contains, one assigns a coin flip that depends on nothing, and the third takes the planted label and flips a quarter of the answers, capping how well it can possibly be recovered:

//+------------------------------------------------------------------+
//| Labels for the two controls, which bracket every real result.    |
//|                                                                  |
//|  Seven setups all landing at AUC 0.50 is only evidence about the |
//|  setups if the pipeline can be shown to detect anything at all.  |
//|  So one control plants a label the window provably contains and  |
//|  the other assigns a coin flip that depends on nothing. A working|
//|  harness must score high on the first and near 0.5 on the second.|
//|  Any other pair means the measurement is broken and the real rows|
//|  say nothing.                                                    |
//|                                                                  |
//|  The planted label is deliberately a CONTRAST - the last four    |
//|  moves against the four before them - and not a sum or a mean.   |
//|  A contrast is exactly the kind of quantity these kernels        |
//|  compute, so a failure here is a real failure.                   |
//|                                                                  |
//|  A third control takes that same label and flips a quarter of    |
//|  the answers, which caps the recoverable AUC well below the      |
//|  clean one. Two controls only show that a STRONG signal is       |
//|  found and pure noise is not; this one puts a number on the      |
//|  weakest edge the harness can still resolve, which is what a     |
//|  null result has to be read against.                             |
//+------------------------------------------------------------------+
int LabControlLabel(ENUM_SETUP s,int i)
  {
   if(s==SETUP_CTRL_SIGNAL || s==SETUP_CTRL_WEAK)
     {
      double recent=0.0,prior=0.0;
      for(int k=0;k<4;k++)
        {
         double a=g_close[i-k-1],c=g_close[i-k];
         if(a>0.0 && c>0.0)
            recent+=MathLog(c/a);
         double a2=g_close[i-k-5],c2=g_close[i-k-4];
         if(a2>0.0 && c2>0.0)
            prior+=MathLog(c2/a2);
        }
      int lab=(recent>prior)?1:-1;
      if(s==SETUP_CTRL_SIGNAL)
         return lab;

      //--- flip a quarter of the answers, keyed off the bar index so the
      //--- corruption is reproducible and independent of the window.
      uint fh=(uint)(i+7919)*2654435761;
      fh^=(fh>>15);
      return ((fh%100)<25)?-lab:lab;
     }

//--- a hash of the bar index: reproducible, and by construction
//--- independent of every bar the window contains.
   uint h=(uint)i*2654435761;
   h^=(h>>16);
   h*=2246822519;
   h^=(h>>13);
   return ((h&1)==0)?1:-1;
  }

Two controls establish that the pipeline finds a strong signal and rejects pure noise. That is necessary but not sufficient, because a null result is a claim about weak edges too, and a harness that only ever sees obvious ones will report a null for everything subtler. The third control is what puts a number on the weakest edge this one can still resolve, and as the next section shows, that number turned out less comfortable than expected.

The planted label is deliberately a contrast, the last four moves against the four before them, and not a sum or a mean, because a contrast is exactly the kind of quantity these kernels compute, which makes a failure there a real failure.


What the Audit Found

Six years of EURUSD H1, 40,000 bars, 128-bar log-price windows, everything else as above. base is the fraction of a setup's test triggers that reached the profitable barrier first, which is what the model has to beat. lift is precision above that base rate on the accepted top 30%. Read the last three rows first.

setup
n
train
test
base
AUC
95% CI
lift
LOO R2
alpha
engulfing
6594
1200
1979
0.484
0.508
±0.025
+0.010
+0.0017
1e+08
pin bar
6372
1200
1912
0.499
0.495
±0.026
-0.030
+0.0017
1e+08
inside-bar break
2979
1200
894
0.437
0.510
±0.038
-0.006
+0.0025
1e+05
MA cross 20/50
736
515
221
0.471
0.449
±0.076
-0.039
+0.0055
1e+04
RSI 30/70
1155
806
347
0.510
0.508
±0.061
+0.004
+0.0025
1e+06
Bollinger touch
2534
1200
761
0.528
0.483
±0.041
-0.020
+0.0032
1e+05
Donchian 20 break
4225
1200
1268
0.494
0.513
±0.032
-0.000
+0.1033
1e+01
[ctrl] planted
4980
1200
1494
0.485
0.803
±0.022
+0.334
+0.3419
1
[ctrl] 25% flipped
4980
1200
1494
0.488
0.546
±0.029
+0.034
+0.0118
1e+03
[ctrl] coin flip
4980
1200
1494
0.484
0.499
±0.029
+0.012
+0.0018
1e+04

The two outer controls do their job. The planted label reaches AUC 0.803 with a 33 point precision lift, at the smallest penalty on the grid, meaning leave-one-out actively wants those features. The coin flip sits at 0.499, its interval straddles 0.500, and its leave-one-out R-squared is 0.0018. The pipeline detects what is there, and nothing when there is nothing.

The middle control changes how the rest of the table should be read. Flipping a quarter of the planted answers does not gently lower the score, it very nearly erases it: AUC falls from 0.803 to 0.546. The pipeline does still find it, with an interior penalty of 1e3 rather than one pinned to the top of the grid, a leave-one-out R-squared more than six times the coin flip's, and a confidence interval of [0.517, 0.575] that excludes 0.500. But it clears chance by barely more than one interval width, which puts the resolution of this harness, at a few thousand triggers over six years of H1 bars, somewhere around AUC 0.55.

Against that floor, the seven rows are evidence about the setups rather than about the code. Every one lands between AUC 0.449 and 0.513, and every one has a confidence interval straddling 0.500. How strong a claim that supports depends on the row. For engulfing, pin bar, Donchian, inside-bar and Bollinger, the test sets run from 761 to 1,979 triggers at intervals of ±0.025 to ±0.041, so an edge the size of the middle control's would have been visible. For those five, the null is real: there is no pre-trigger context here that this pipeline can turn into an edge, at this barrier width and horizon on this symbol. The MA cross and RSI rows are weaker, because 221 and 347 test triggers give intervals of ±0.076 and ±0.061, wide enough to hide an edge around 0.55. Those two read as "not enough signals to say", not "nothing there".

That distinction is exactly what the third control buys: with only a strong control and a noise control, all seven rows would have looked like equally solid nulls, and two of them are not. Null results are worth publishing, and this one says the information a hundred forum threads assume is in the bars before an engulfing candle is, on this evidence, not there.

A second, quieter finding sits in the base column. Three of the seven setups resolve below 0.500 before any model is involved, the inside-bar break at 0.437: under symmetric barriers at 1.5 ATR over 24 bars, those triggers reach the wrong barrier first more often than the right one. The direction rule itself is the problem there, not the absence of a filter on top of it.

The row that needs explaining

Donchian is the anomaly. Its leave-one-out R-squared is +0.1033 at a penalty of 10, real in-sample structure and a model that wants its features, and yet its test AUC is 0.513. Every other setup sits at or below 0.0055.

The explanation is label overlap. Donchian breakouts cluster, so a single breakout period fires many triggers inside the 24-bar horizon and their triple-barrier labels are written by overlapping sets of bars. Leave-one-out drops one row at a time and treats the rest as independent, which they are not, so information leaks between neighbours and it reports structure that does not survive to a genuinely later period.

Worth carrying away: leave-one-out is not a safe model-selection criterion when labels overlap in time. It is nearly free here and honest about the coin flip, but on clustered triggers it will flatter a model that has learned nothing durable. Keep a genuinely out-of-sample number beside it.


Reading a Model Across Time Scales

Ten thousand features are useless unless they can be turned back into a statement about the market. Every feature maps to a known kernel shape at a known dilation, so the machinery exists:

//+------------------------------------------------------------------+
//| Trace a feature index back to the kernel shape, dilation and tap |
//| positions that produced it, so a ridge weight can be read as a   |
//| statement about a specific shape at a specific scale.            |
//+------------------------------------------------------------------+
bool CMiniRocket::FeatureMap(int fi,int &kernel,int &dilation,int &tap0,
                             int &tap1,int &tap2) const
  {
   if(!m_ready || fi<0 || fi>=m_nfeat)
      return false;

   int start=0;
   for(int di=0;di<m_ndil;di++)
     {
      int block=m_nfpd[di]*MR_NUM_KERNELS;
      if(fi<start+block)
        {
         kernel=(fi-start)/m_nfpd[di];
         dilation=m_dil[di];
         tap0=m_idx[kernel*3+0];
         tap1=m_idx[kernel*3+1];
         tap2=m_idx[kernel*3+2];
         return true;
        }
      start+=block;
     }
   return false;
  }

The seven setups have no signal to locate, so the question has to be asked of the planted control, whose label lives eight bars deep. That makes this a test of the measure rather than of the market.

The obvious move is to rank dilations by the total absolute ridge weight sitting on them. Against the planted control, dilation 1 held 25.0% of the total weight, and it also owns 25.2% of the feature budget, because short dilations are handed more features than long ones. Every dilation came out within 0.85 to 1.15 of exactly proportional: the report was restating the schedule back at us, and it looked precisely like a finding.

Correcting for that, and scaling each weight by its column's standard deviation since a large weight on a feature that barely moves contributes nothing, produced a second answer: the longest dilations at 1.4 to 1.8 times their budget and dilation 1 marked down to 0.61, the opposite of where the signal was planted. The third approach asks the question directly: refit on one band of dilations at a time, and read the held-out AUC.

//+------------------------------------------------------------------+
//| Which time scales actually carry the signal, measured by         |
//| refitting on one band of dilations at a time.                    |
//|                                                                  |
//|  Weight-based importance was tried first and had to be thrown    |
//|  away. Ranking dilations by raw absolute weight just reports the |
//|  feature budget back - dilation 1 owns 25% of the features and   |
//|  duly received 25% of the weight. Scaling weights by column      |
//|  spread fixed that and then pointed the OTHER way, crediting the |
//|  longest dilations. Both were checked against a control whose    |
//|  answer was known - a label planted eight bars deep - and neither|
//|  recovered it.                                                   |
//|                                                                  |
//|  Ablation does. Refit on one band alone and read the held-out    |
//|  AUC: a band that cannot reproduce the score does not carry the  |
//|  signal, whatever its weights look like. It costs one extra fit  |
//|  per band and it is the only reading here that survived being    |
//|  tested against a known answer.                                  |
//+------------------------------------------------------------------+
int BandOf(int dilation)
  {
   int span=8*dilation+1;
   if(span<=25)
      return 0;
   if(span<=64)
      return 1;
   return 2;
  }

On the planted control that answers immediately:

--- scale ablation (all 9996 features together: AUC 0.803) ---
  band                   nfeat  AUC alone
  short  (<=25 bars)      5124      0.869
  medium (26-64 bars)     2688      0.621
  long   (>64 bars)       2184      0.573

The short band alone scores 0.869, better than all 9,996 features together, and the long band is barely above chance. For a label planted eight bars deep that is exactly right, and it carries a second lesson: including the scales that hold no signal actively hurts, since 0.869 falls to 0.803 once they are added back.

Worth carrying away: with ten thousand heavily correlated features, a coefficient is not an importance. Both weight-based rankings here were plausible, easy to compute, and wrong. If you build an importance measure, validate it against a signal you planted yourself before you believe a word it says.


Scoring Triggers on a Live Chart

A fitted pipeline is small: the dilation schedule, 9,996 thresholds, 9,996 weights and an operating threshold, about 170 KB. No training data travels with it, so a chart runs the transform without ever seeing what it was fitted on. The indicator loads that file and checks the symbol and timeframe in its header, because thresholds fitted to one market mean nothing on another and nothing about the output would look wrong if you mixed them.

Building it surfaced a platform trap worth writing down. The setups that read moving averages, RSI or Bollinger bands need those buffers, and indicator buffers fill asynchronously. The script path waits for them in a loop with Sleep(); reusing that loop inside a custom indicator produced an indicator that plotted nothing at all, with no error printed anywhere. Custom indicators run on the terminal's interface thread, where Sleep() is not allowed. The wait loop therefore spun without ever yielding, CopyBuffer returned -1, OnCalculate returned zero, and the plot stayed empty. A probe reported calc=0 copied=-1 while the identical include worked perfectly in a script.

The supported pattern is to create the handles once, then ask rather than wait, returning zero so the terminal calls you again on the next tick:

//--- the MA, RSI and Bollinger buffers are filled asynchronously and
//--- an indicator cannot wait for them: returning 0 lets the next tick
//--- call us again. See LabIndicatorsReady() for why waiting fails.
   if(!LabIndicatorsReady(rates_total))
      return 0;
   if(!LabCopyIndicators(rates_total,0))
      return 0;
   g_bars=rates_total;

with the readiness test being:

//+------------------------------------------------------------------+
//| Have the handles finished calculating at least want bars?        |
//|                                                                  |
//|  An indicator must ASK this rather than wait for it. Sleep() is  |
//|  refused inside a custom indicator - it runs on the interface    |
//|  thread - so a wait loop there spins without ever yielding, the  |
//|  CopyBuffer that follows comes up short, and the whole indicator |
//|  silently produces nothing. Returning 0 from OnCalculate and     |
//|  being called again on the next tick is the supported way to     |
//|  wait.                                                           |
//+------------------------------------------------------------------+
bool LabIndicatorsReady(int want)
  {
   return (BarsCalculated(g_hmaf)>=want && BarsCalculated(g_hmas)>=want &&
           BarsCalculated(g_hrsi)>=want && BarsCalculated(g_hbb)>=want &&
           BarsCalculated(g_hatr)>=want);
  }

With that in place the indicator scores every trigger in the visible range and leaves every other bar empty, because a score means "this trigger resembles the ones that worked" and says nothing between triggers. Reading the buffers back confirmed 500 scored bars out of 4,000, one per eight bars as the control fires, spanning the full [0,1] range.

MiniRocketProb scoring triggers in a EURUSD H1 subwindow

Fig. 6. The indicator scoring each trigger against the model, with the acceptance level drawn in

Note: a blank indicator looks identical to a working one that found nothing. Keep every sleeping loop on the script side of a shared include, and test the indicator by driving it from a throwaway script that counts the non-empty buffer values.


Conclusion

We ported MiniRocket to native MQL5, proved the port exact, and used it to audit seven setups this community trades every day, with no training loop, no ONNX and no Python at runtime.

  • The port is exact, and that is checkable. 79,968 of 79,968 features bit-identical against an independent float64 reimplementation, and the same count against sktime's own source at sktime's output precision. Determinism makes correctness an equality test rather than an opinion.
  • Seven setups returned nothing. Every AUC between 0.449 and 0.513, every confidence interval straddling 0.500, and precision lifts within noise of zero.
  • The controls are what make that statement worth anything. A planted label scores 0.803 and a coin flip 0.499, so the measurement works. The third control, the same planted label with a quarter of its answers flipped, falls to 0.546, putting this harness's resolution near AUC 0.55. Five of the seven setups have test sets tight enough for that to be a real null; the MA cross and RSI rows, at 221 and 347 triggers, are only "not enough signals to say".
  • Level blindness is narrower than it sounds. A zero-sum kernel ignores a constant added to the whole window, but a level change part-way through it is a contrast, and contrasts are what these kernels compute.
  • Leave-one-out flatters clustered triggers, and a coefficient is not an importance. Donchian's leave-one-out R-squared of 0.103 did not survive to a test AUC above 0.513, and two reasonable weight-based rankings both missed a signal planted eight bars deep that ablation found at once.

The scope is one symbol and one timeframe, EURUSD H1, at one barrier width and horizon, with a single chronological split. A null on a single market is not a universal law, and the honest reading is that these setups showed nothing here. Change the symbol, the barrier, or the horizon and re-run: the controls will tell you whether to believe the answer.

If you take one habit from this article, take the controls. They cost three extra rows in a table and they are the difference between a result and a guess.

References

  1. Dempster, A., Schmidt, D. F., Webb, G. I. (2021). MiniRocket: A Very Fast (Almost) Deterministic Transform for Time Series Classification. KDD 2021. arXiv:2012.08791
  2. Dempster, A., Petitjean, F., Webb, G. I. (2020). ROCKET: Exceptionally fast and accurate time series classification using random convolutional kernels. Data Mining and Knowledge Discovery 34. arXiv:1910.13051
  3. The sktime developers. sktime: a unified interface for machine learning with time series. sktime.net
  4. Lopez de Prado, M. (2018). Advances in Financial Machine Learning. Wiley. The source of the triple-barrier labelling and of purging and embargoing across a split.
The programs presented in this article are intended for educational purposes only. Nothing here is investment advice, and past behaviour of any statistical relationship is not a guarantee of future results. Test any code thoroughly on a demo account before considering live use.


Getting the Source Code via MQL5 Algo Forge

All source files are attached to this article below, but the full repository is also available on MQL5 Algo Forge, the community's Git-based platform for sharing and collaborating on trading projects.

File name
Description
MQL5\Include\MiniRocket\MiniRocket.mqh
The MiniRocket transform: 84 kernels, dilation schedule, quantile thresholds, PPV pooling, feature-to-kernel mapping and model persistence
MQL5\Include\MiniRocket\RidgeClassifier.mqh
Ridge classifier solved in the dual, with one eigendecomposition serving the whole penalty grid and exact closed-form leave-one-out
MQL5\Include\MiniRocket\SetupLab.mqh
The testbed: the seven setup rules, the three controls, triple-barrier labelling, purged chronological split and rank-based AUC
MQL5\Scripts\MiniRocket\MiniRocketVerify.mq5
Validation script: builds a reproducible fixture, reports the schedule and timings, and dumps input and features for external comparison
MQL5\Scripts\MiniRocket\SetupAudit.mq5
Runs every setup and all three controls through the identical pipeline and prints the results table
MQL5\Scripts\MiniRocket\MiniRocketFit.mq5
Fits one setup, runs the scale ablation, and writes the model file the indicator loads
MQL5\Indicators\MiniRocket\MiniRocketProb.mq5
Loads a fitted model and scores each trigger on the chart against the training distribution
MQL5\Files\MiniRocket\minirocket_reference.py
Independent float64 reimplementation used for the bit-exact comparison
MQL5\Files\MiniRocket\compare_sktime.py
Runs sktime's own MiniRocket source and diffs it against the MQL5 output
MQL5\Files\MiniRocket\level_invariance.py
Measures which features are exactly level-invariant, which window content recovers a planted label, and which half of the feature set carries it
Attached files |
MQL5.zip (36.77 KB)
Neural Networks in Trading: From Transformers to Spiking Neurons (Conclusion) Neural Networks in Trading: From Transformers to Spiking Neurons (Conclusion)
Neural networks are already changing the way we analyze markets, and new architectures are opening up even more possibilities. In this article, we wrap up our work with the SpikingBrain framework, which opens up new possibilities for us.
The Maximal Information Coefficient: Detecting Any Relationship, and the Null That Decides Whether It Is Real The Maximal Information Coefficient: Detecting Any Relationship, and the Null That Decides Whether It Is Real
This article implements the Maximal Information Coefficient (MINE) for MQL5, including the grid search with dynamic programming and the four MINE statistics. It explains why raw MIC has a nonzero noise floor and builds a permutation null to judge significance. The result is a verified library with a dependence scanner and a chart indicator, allowing you to test features and interpret scores consistently across relationship shapes.
Certified Robustness Radius: Knowing How Much Noise Your ONNX Trading Model Can Survive Certified Robustness Radius: Knowing How Much Noise Your ONNX Trading Model Can Survive
We introduce a certified-radius gate for ONNX signals implemented natively in MQL5. The system estimates per-prediction robustness via randomized smoothing and a one-sided Clopper–Pearson bound, then applies the radius to trade admission, lot scaling, and monitoring. This provides an actionable confidence margin that reflects input noise tolerance rather than softmax magnitude.
Symbol Correlation Monitor with Live Heatmap in MQL5 Symbol Correlation Monitor with Live Heatmap in MQL5
This work delivers an MQL5 Expert Advisor that reads open-position symbols, builds return series, and computes a rolling Pearson correlation matrix, displayed as a CCanvas heatmap. Off-diagonal pairs that meet a warning threshold are bordered for quick scanning. The code details return processing, correlation arithmetic, and matrix indexing, with a verification script, helping you track shifting co-movements across your active book.