2026-03-11 01:01:25 +07:00
|
|
|
|
//+------------------------------------------------------------------+
|
2026-03-11 16:06:24 +07:00
|
|
|
|
//| SimpleFVG.mq5 – Fair Value Gap Visual Strategy (Test mode) |
|
|
|
|
|
|
//| |
|
|
|
|
|
|
//| Modules: |
|
|
|
|
|
|
//| Config.mqh → Step 0: Inputs, enums, constants |
|
|
|
|
|
|
//| Trend.mqh → Step 1: EMA34/EMA89 trend detection |
|
|
|
|
|
|
//| FVG.mqh → Step 2: FVG scanning & management |
|
|
|
|
|
|
//| Drawing.mqh → Step 4: Chart visualization |
|
2026-03-11 01:01:25 +07:00
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
|
#property copyright "SimpleFVG"
|
2026-03-11 16:06:24 +07:00
|
|
|
|
#property version "2.00"
|
|
|
|
|
|
#property description "FVG strategy visualizer – EMA trend + FVG zones on chart"
|
2026-03-11 01:01:25 +07:00
|
|
|
|
|
2026-03-11 16:06:24 +07:00
|
|
|
|
#include "SimpleFVG/Config.mqh"
|
|
|
|
|
|
#include "SimpleFVG/Trend.mqh"
|
|
|
|
|
|
#include "SimpleFVG/FVG.mqh"
|
2026-03-11 18:13:27 +07:00
|
|
|
|
#include "SimpleFVG/Trade.mqh"
|
2026-03-11 16:06:24 +07:00
|
|
|
|
#include "SimpleFVG/Drawing.mqh"
|
2026-03-11 01:01:25 +07:00
|
|
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
2026-03-11 16:06:24 +07:00
|
|
|
|
//| OnInit |
|
2026-03-11 01:01:25 +07:00
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
|
int OnInit()
|
|
|
|
|
|
{
|
2026-03-11 16:06:24 +07:00
|
|
|
|
//--- Step 1: Initialize trend (EMA handles + chart indicators) ---
|
|
|
|
|
|
if(!TrendInit())
|
|
|
|
|
|
return INIT_FAILED;
|
2026-03-11 01:01:25 +07:00
|
|
|
|
|
2026-03-11 16:06:24 +07:00
|
|
|
|
//--- Step 2: Initialize FVG array ---
|
|
|
|
|
|
FVGInit();
|
2026-03-11 01:01:25 +07:00
|
|
|
|
|
2026-03-11 16:06:24 +07:00
|
|
|
|
//--- Initial scan on existing bars ---
|
|
|
|
|
|
TrendUpdate();
|
|
|
|
|
|
FVGUpdate();
|
2026-03-11 01:01:25 +07:00
|
|
|
|
|
2026-03-11 16:06:24 +07:00
|
|
|
|
//--- Step 4: Draw everything ---
|
|
|
|
|
|
DrawAll();
|
2026-03-11 01:01:25 +07:00
|
|
|
|
|
2026-03-11 16:06:24 +07:00
|
|
|
|
if(InpDebugLog)
|
|
|
|
|
|
PrintFormat("[INIT] SimpleFVG v2.0 | %s %s | EMA%d/%d | FVG lookback=%d maxAge=%d",
|
|
|
|
|
|
GetTradeSymbol(), EnumToString(InpTimeframe),
|
|
|
|
|
|
InpEMAFastPeriod, InpEMASlowPeriod,
|
|
|
|
|
|
InpFVGLookbackBars, InpFVGMaxAgeBars);
|
|
|
|
|
|
|
|
|
|
|
|
return INIT_SUCCEEDED;
|
2026-03-11 01:01:25 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-11 16:06:24 +07:00
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
|
//| OnDeinit |
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
2026-03-11 01:01:25 +07:00
|
|
|
|
void OnDeinit(const int reason)
|
|
|
|
|
|
{
|
2026-03-11 16:06:24 +07:00
|
|
|
|
TrendDeinit();
|
|
|
|
|
|
DrawCleanup();
|
2026-03-11 01:01:25 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-11 16:06:24 +07:00
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
|
//| OnTick |
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
2026-03-11 01:01:25 +07:00
|
|
|
|
void OnTick()
|
|
|
|
|
|
{
|
2026-03-11 16:06:24 +07:00
|
|
|
|
if(!IsNewBar())
|
|
|
|
|
|
return;
|
2026-03-11 01:01:25 +07:00
|
|
|
|
|
2026-03-11 16:06:24 +07:00
|
|
|
|
TrendUpdate();
|
|
|
|
|
|
FVGUpdate();
|
2026-03-11 18:13:27 +07:00
|
|
|
|
ManageFVGTrades();
|
2026-03-11 16:06:24 +07:00
|
|
|
|
DrawAll();
|
2026-03-11 01:01:25 +07:00
|
|
|
|
}
|