NetworkMomentum/Include/NetworkMomentum/NM_Config.mqh
2026-07-30 03:34:33 +00:00

65 라인
3.3 KiB
MQL5

//+------------------------------------------------------------------+
//| NM_Config.mqh |
//| MMQ — Muhammad Minhas Qamar |
//| www.mql5.com/en/articles/23763 |
//+------------------------------------------------------------------+
#property copyright "MMQ — Muhammad Minhas Qamar"
#property link "https://www.mql5.com/en/articles/23763"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Numeric constants of the network-momentum pipeline. |
//| |
//| Every default here is taken straight from the paper's |
//| definitions so the maths matches the method it implements. They |
//| are gathered in one header because four separate modules read |
//| them and a value that drifted between two of them would corrupt |
//| the pipeline with no compile error to catch it. |
//| |
//| The tradeable-symbol and cross-asset lists deliberately live |
//| elsewhere: the maths operates on a raw price matrix and is |
//| symbol-agnostic, so only the EA needs broker names. Keeping |
//| them out keeps the library usable in isolation. |
//+------------------------------------------------------------------+
//--- volatility scaling (Definitions 4.1-4.3)
#define NM_VOL_WINDOW 22 // EWMA span for the return-vol estimate
//--- momentum oscillators (Definition 4.4)
#define NM_SPEED_COUNT 6 // K - number of oscillator speeds
#define NM_OSC_M 12 // slow/fast EMA-span ratio in Def 4.4
//--- graph learning (Definition 3.1)
#define NM_ALPHA 1.0 // weight on the log-degree barrier
#define NM_BETA 0.1 // weight on the Frobenius regulariser
//--- position response (Definition 5.1)
#define NM_LAMBDA 1.4142135623730951 // sqrt(2), the sigmoid width
//+------------------------------------------------------------------+
//| The K oscillator speeds, k = 1..NM_SPEED_COUNT (Definition 4.4). |
//| The speeds are the literal list [1,2,3,4,5,6]; a helper returns |
//| it so every module speaks of "speed index k" the same way |
//| rather than each re-deriving the sequence. |
//+------------------------------------------------------------------+
void NM_FillSpeeds(int &speeds[])
{
ArrayResize(speeds,NM_SPEED_COUNT);
for(int k=0;k<NM_SPEED_COUNT;k++)
speeds[k]=k+1;
}
//+------------------------------------------------------------------+
//| The ensemble lookback windows (Equation 7 ensemble). |
//| Multiples of the volatility window, [22,44,66,88,110,132]. The |
//| detector runs once per window and the adjacencies are averaged, |
//| which is Equation 7's ensemble over horizons. |
//+------------------------------------------------------------------+
void NM_FillEnsembleWindows(int &windows[])
{
ArrayResize(windows,NM_SPEED_COUNT);
for(int i=0;i<NM_SPEED_COUNT;i++)
windows[i]=NM_VOL_WINDOW*(i+1);
}
//+------------------------------------------------------------------+