Specifiche
Objective
Build a standalone dashboard module (preferably an EA, can also be an indicator) for XAUUSD that evaluates dump (sharp drop) risk and displays the result directly on the chart (on-screen display).
✅ The module must not open trades.
✅ The module only calculates and displays:
-
DumpRisk % (0–100)
-
Mode: NORMAL / SAFE / NO_TRADE
-
Top reasons (2–3) why the risk is high
-
Lock (if a hard trigger forces NO_TRADE for a period of time)
Quality Requirements (Critical)
-
100% compatible with MT5 / MQL5
-
0 errors, 0 warnings in MetaEditor
-
Robust CopyRates() / CopyBuffer() usage: always check return values
-
CPU optimization
-
Perform calculations only on a new M5 bar when ComputeOnlyOnNewM5Bar = true
-
Recalculate FVG (H1/H4) only when needed (ideally on a new H1/H4 bar + caching)
-
No unnecessary work in OnTick()
-
-
Code must be clean and clearly commented (functions, logic, score mapping)
-
All thresholds, weights, values, and settings must be input parameters (tunable directly in MT5, not only in code)
1) INPUTS (Everything Adjustable in MT5)
1.1 Global Thresholds and Modes
-
int DropPoints = 30;
-
int HorizonMinutes = 60; (buffer)
-
int ScoreSafe = 35;
-
int ScoreNoTrade = 60;
-
int NoTradeLockMinutes = 60;
-
bool ComputeOnlyOnNewM5Bar = true;
-
bool ShowDashboard = true;
1.2 Category Weights (Contributions to 0–100)
All must be input so they can be tuned:
-
int W_Volatility = 25;
-
int W_Micro = 25;
-
int W_Divergence = 20;
-
int W_Spread = 15;
-
int W_Session = 10;
-
int W_Structure = 10;
-
int W_FVG_ContribMax = 20; (maximum FVG contribution to the final score)
Note: The developer must ensure clamping/normalization so the system works correctly even if the weights are changed.
2) Modules (Architecture)
A) DataCache
-
Safe CopyRates() for: M1, M5, H1, H4
-
Maintain lastBarTime for M5/H1/H4
-
If ComputeOnlyOnNewM5Bar = true , compute only on a new M5 bar
B) FeatureEngine
Compute category sub-scores:
-
Volatility (0.. W_Volatility )
-
Microstructure (0.. W_Micro )
-
Divergences / exhaustion (0.. W_Divergence )
-
Spread proxy (0.. W_Spread )
-
Session (0.. W_Session )
-
Structure (0.. W_Structure )
C) FVGEngine (H1 + H4)
-
Detect bearish FVG zones (3-candle model)
-
Fill status: when filled >= FVG_FillPct → zone becomes inactive
-
Find nearest bearish FVG below + stack count
-
Compute FVG_RiskScore (0..25), then
FVG_Contrib = min(W_FVG_ContribMax, FVG_RiskScore)
D) DumpRiskEngine
-
Compute final DumpRiskScore (0..100) as the sum of category contributions (normalized to weights)
-
Determine mode: NORMAL / SAFE / NO_TRADE
-
Apply hard triggers + lock
E) Dashboard (Display)
-
Use OBJ_LABEL (preferred), top-left corner
-
Show DumpRisk %, Mode, lock (if active), and top reasons
3) Exact Calculations + Score Mapping (v1)
IMPORTANT: All thresholds and boundaries below must be input parameters (tunable in MT5).
3.1 Volatility (0..W_Volatility)
Inputs
-
int ATR_Period = 14;
-
double Vol_Ratio_L1 = 0.90;
-
double Vol_Ratio_L2 = 1.20;
-
double Vol_Ratio_L3 = 1.50;
-
double Vol_Ratio_L4 = 1.90;
-
int Vol_Score1 = 5;
-
int Vol_Score2 = 8;
-
int Vol_Score3 = 12;
-
int Vol_Score4 = 17;
-
int Vol_Score5 = 22;
TR spikes (bonus)
-
int TRSpikes_Lookback = 24;
-
double TRSpikes_Factor = 1.8;
-
int TRSpikes_B1 = 1;
-
int TRSpikes_B2 = 2;
-
int TRSpikes_B3 = 3;
-
int TRSpikes_Th1 = 2;
-
int TRSpikes_Th2 = 4;
-
int TRSpikes_Th3 = 6;
Logic
-
Compute ATR_M5 , ATR_H1
-
baseline = ATR_H1 / 12
-
ratio = ATR_M5 / baseline
-
Map ratio to base score ( Vol_Score1..Vol_Score5 )
-
Add bonus based on spike count (0.. TRSpikes_B3 )
-
Clamp result to 0..W_Volatility (scale if required)
3.2 Microstructure (0..W_Micro)
Micro = Wicks + FailedBO + BearImpulse
Each component has its own maximum points (all adjustable).
Inputs
-
int WickBars = 12;
-
int Wick_Max = 12;
-
int FailedBO_Lookback = 20;
-
int FailedBO_Max = 6;
-
int BearImpulse_LookbackM1 = 6;
-
double BearImpulse_ATRMult = 1.2;
-
int BearImpulse_Max = 7;
3.2.1 WickScore (0..Wick_Max)
Threshold inputs
-
double Wick_AvgUpper_T1 = 0.22;
-
double Wick_AvgUpper_T2 = 0.30;
-
double Wick_AvgUpper_T3 = 0.38;
-
int Wick_AvgScore1 = 1;
-
int Wick_AvgScore2 = 3;
-
int Wick_AvgScore3 = 6;
-
int Wick_AvgScore4 = 8;
-
double Wick_BadFrac_T1 = 0.10;
-
double Wick_BadFrac_T2 = 0.25;
-
double Wick_BadFrac_T3 = 0.40;
-
int Wick_BadScore1 = 0;
-
int Wick_BadScore2 = 2;
-
int Wick_BadScore3 = 3;
-
int Wick_BadScore4 = 4;
-
double Wick_BodyRatioBad = 0.25;
-
double Wick_UpperRatioBad = 0.40;
Logic
-
avgUpperScore + badFracScore , clamp to 0..Wick_Max
3.2.2 FailedBreakoutScore (0..FailedBO_Max)
Inputs
-
int FBO_Th1 = 1;
-
int FBO_Th2 = 3;
-
int FBO_Th3 = 5;
-
int FBO_Score0 = 0;
-
int FBO_Score1 = 1;
-
int FBO_Score2 = 3;
-
int FBO_Score3 = 5;
-
int FBO_Score4 = 6;
-
int FBO_LocalWindow = 5; (comparison window for local high)
3.2.3 BearImpulseScore (0..BearImpulse_Max)
Inputs
-
double Impulse_ClosePosMax = 0.25;
-
double Impulse_BodyFactor = 0.60;
(open-close must exceed Impulse_BodyFactor * ATR_M1 * BearImpulse_ATRMult) -
double Impulse_Str1 = 1.2;
-
double Impulse_Str2 = 1.8;
-
int Impulse_Score1 = 4;
-
int Impulse_Score2 = 6;
-
int Impulse_Score3 = 7;
3.3 Divergences / Exhaustion (0..W_Divergence)
Div = RSI state + RSI divergence + EMA slope
Inputs
-
int RSI_Period = 14;
-
int EMA_SlopeBars = 10;
-
int Div_RSI_Max = 6;
-
int Div_RSIdiv_Max = 8;
-
int Div_EMAslope_Max = 6;
RSI state inputs
-
double RSI_T1 = 55;
-
double RSI_T2 = 60;
-
double RSI_T3 = 65;
-
int RSI_S1 = 1;
-
int RSI_S2 = 3;
-
int RSI_S3 = 4;
-
int RSI_S4 = 6;
RSI divergence inputs
-
int Div_SwingLookback = 60;
-
int Div_Score = 8;
EMA slope inputs (points)
-
double EMA_Slope_PosHi = 15;
-
double EMA_Slope_PosLo = 5;
-
double EMA_Slope_Neg = -5;
-
int EMA_Slope_S0 = 0;
-
int EMA_Slope_S1 = 2;
-
int EMA_Slope_S2 = 4;
-
int EMA_Slope_S3 = 6;
3.4 Spread Proxy (0..W_Spread)
Inputs
-
int Spread_BufferM1 = 50;
-
double SpreadZ_T1 = 0.5;
-
double SpreadZ_T2 = 1.0;
-
double SpreadZ_T3 = 1.5;
-
double SpreadZ_T4 = 2.0;
-
int Spread_S1 = 2;
-
int Spread_S2 = 5;
-
int Spread_S3 = 9;
-
int Spread_S4 = 12;
-
int Spread_S5 = 15;
Implementation
-
Use a circular buffer of spread values, update on a new M1 bar
-
z = (SpreadNow - mean) / std
-
Map to points, clamp to 0..W_Spread
3.5 Session Risk (0..W_Session)
Inputs
-
int Session_London_Start = 8;
-
int Session_London_End = 10;
-
int Session_NY_Start = 14;
-
int Session_NY_End = 16;
-
int Session_Rollover_Start = 23;
-
int Session_Rollover_End = 1; (handle midnight crossover 23–01)
-
int Session_Add = 4;
Clamp result to 0..W_Session
3.6 Structure (0..W_Structure)
Inputs
-
int BOS_Lookback = 20;
-
double BOS_BufferPoints = 2;
-
int Struct_ScoreNoBOS = 2;
-
int Struct_ScoreBOS = 10;
Logic
-
structureLow from bars 2..(lookback+1)
-
If close(shift=1) < structureLow - BOS_BufferPoints*_Point → BOS = true
4) FVG ENGINE (H1 + H4) – Exact and Adjustable
Inputs
-
bool UseFVG = true;
-
ENUM_TIMEFRAMES FVG_TF1 = PERIOD_H1;
-
ENUM_TIMEFRAMES FVG_TF2 = PERIOD_H4;
-
int FVG_LookbackH1 = 400;
-
int FVG_LookbackH4 = 250;
-
double FVG_FillPct = 80.0;
-
double FVG_StackATRWindow = 1.5;
-
double FVG_DistATR_T1 = 0.75;
-
double FVG_DistATR_T2 = 1.50;
-
double FVG_DistATR_T3 = 2.50;
-
double FVG_SizeATR_T1 = 0.40;
-
double FVG_SizeATR_T2 = 0.80;
Scoring inputs
-
int FVG_S_Dist1 = 12;
-
int FVG_S_Dist2 = 7;
-
int FVG_S_Dist3 = 3;
-
int FVG_S_Size1 = 1;
-
int FVG_S_Size2 = 3;
-
int FVG_S_Size3 = 5;
-
int FVG_S_Stack0 = 0;
-
int FVG_S_Stack1 = 1;
-
int FVG_S_Stack2 = 3;
-
int FVG_S_Stack3 = 4;
-
int FVG_S_InsideZone = 4;
Combining
-
double FVG_CombineH1Weight = 0.65;
-
double FVG_CombineH4Weight = 0.35;
Output
-
FVG_RiskScore in range 0..25
-
FVG_Contrib = min(W_FVG_ContribMax, FVG_RiskScore)
5) Hard Triggers + NO_TRADE Lock (Adjustable)
Inputs
-
int HardA_FVG_Min = 12;
-
bool HardA_RequireBOS = true;
-
int HardA_LockMinutes = 60;
-
int HardB_FVG_Min = 10;
-
bool HardB_RequireBearImpulse = true;
-
double HardB_LockFactor = 0.75;
Logic
-
If lock is active → always NO_TRADE
-
Trigger A: FVG >= HardA_FVG_Min AND BOS == true
→ NO_TRADE + lock HardA_LockMinutes -
Trigger B: FVG >= HardB_FVG_Min AND BearImpulse == true
→ NO_TRADE + lock round(NoTradeLockMinutes * HardB_LockFactor)
6) Dashboard Output (Display) + Reasons
Display using OBJ_LABEL .
Required lines
-
DumpRisk: XX% | Mode: NORMAL/SAFE/NO_TRADE
-
Drop: 30pts | Safe:35 | NoTrade:60
-
Vol: x Micro: x Div: x Spr: x Sess: x Str: x FVG: x
-
Reasons: ... (top 2–3 texts)
-
Lock: XX min (only if active)
Top reasons must be selected from the highest contributing categories.
Examples
-
FVG(H4): bearish below
-
BOS(M5): true
-
BearImpulse(M1): true
-
SpreadZ: 2.1
-
Wicks: high distribution
7) Performance Rules (Must Be Followed)
OnTick
-
If ComputeOnlyOnNewM5Bar = true → only check for a new bar; compute only then
CopyRates
-
M5: only required windows (e.g., ~80 bars for divergence)
-
M1: only for impulse + spread-buffer update on a new M1 bar
FVG
-
H1/H4 scan only when needed + caching
(do not scan 400/250 bars on every tick)
Delivery
-
.mq5 file (EA or indicator)
-
Compiles with 0 warnings / 0 errors
-
Short usage notes:
-
how to attach it to XAUUSD M5
-
what Mode means
-