SniperGold_ML/MQL5/Indicators/AlgoForge/AF_Engine3_Display.mq5

199 lines
9.2 KiB
MQL5
Raw Permalink Normal View History

//+------------------------------------------------------------------+
//| AF_Engine3_Display.mq5 |
//| Project : Algo Forge (refactor total) |
//+------------------------------------------------------------------+
//| ATRIBUSI SUMBER (WAJIB - jangan dihapus): |
//| |
//| Proyek ini adalah REFAKTOR TOTAL dengan arsitektur baru |
//| (3 engine + ML hibrida), terinspirasi dari indikator: |
//| |
//| SniperGold SMC Pro+ |
//| https://www.mql5.com/en/code/75466 |
//| Copyright (c) Waseem Shahrukh |
//| |
//| Bukan salinan langsung; seluruh implementasi ditulis ulang |
//| dengan arsitektur 3-engine. Atribusi sumber WAJIB dicantumkan |
//| di header setiap file, README, dan publikasi "Algo Forge". |
//| |
//| ENGINE 3 (display) - HANYA membaca output Engine 1 & 2: |
//| * Engine 1 (AFEngine1MTF): bar MTF tertutup (closed-bar lock). |
//| * Engine 2 (AFEngine2Signals/AFAggOut/AFDisplayData): struktur,|
//| zona, sinyal, bias - TIDAK ada perhitungan analisis di sini. |
//| Semua komputasi display dilakukan AF_BuildDisplayData (layer |
//| Engine 2, AF_Engine2_Display.mqh). |
//+------------------------------------------------------------------+
#property copyright "Algo Forge - refactor SniperGold SMC Pro+ (Waseem Shahrukh, https://www.mql5.com/en/code/75466)"
#property version "1.00"
#property strict
#property description "Algo Forge Engine 3 (Display): struktur, zona (OB/FVG), sinyal & dashboard - hanya membaca output Engine 1 & 2. Sumber inspirasi: SniperGold SMC Pro+ (c) Waseem Shahrukh."
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots 0
#include <AlgoForge\AF_Engine3_Render.mqh>
//------------------------------------------------------------------
// INPUTS
//------------------------------------------------------------------
input group "===== GENERAL ====="
input int InpMaxBars = 600; // Kapasitas cache per slot
input ENUM_TIMEFRAMES InpDispTF = PERIOD_CURRENT; // TF display struktur/zona (CURRENT = chart)
// TF agen (Engine 2) HARDCODED - lihat AF_E2_TF_S1..S4 di AF_Defines.mqh:
// S1=Narrative(H4) S2=Context(M30) S3=Entry(M15) S4=PriceAction(M3)
// (tidak ada input manual lagi)
input group "===== DISPLAY ====="
input bool InpShowStructure = true; // Tampilkan struktur (BOS/CHoCH)
input bool InpShowSwingPoints = true; // Tampilkan HH/HL/LH/LL
input bool InpShowOB = true; // Tampilkan Order Block
input int InpOBCount = 5; // Jumlah OB
input bool InpShowFVG = true; // Tampilkan FVG
input int InpFVGCount = 6; // Jumlah FVG
input bool InpShowPD = true; // Tampilkan Premium/Discount
input bool InpShowLevels = true; // Tampilkan PDH/PDL/PWH/PWL
input bool InpShowSignals = true; // Tampilkan sinyal + Entry/SL/TP
input bool InpShowDashboard = true; // Tampilkan dashboard
input group "===== VISUAL ====="
input int InpFontSize = 9; // Font size
input string InpFontName = "Segoe UI"; // Font
input bool InpPanelTransparent= true; // Panel transparan
input group "===== COLORS ====="
input color InpBull = C'8,153,129';
input color InpBear = C'242,54,69';
input color InpIntBullOBLine = C'91,156,246';
input color InpIntBearOBLine = C'247,124,128';
input color InpFillIntBullOB = C'9,15,28';
input color InpFillIntBearOB = C'28,13,15';
input color InpBullFVGLine = C'0,255,104';
input color InpBearFVGLine = C'255,0,8';
input color InpFillBullFVG = C'7,26,16';
input color InpFillBearFVG = C'27,8,10';
input color InpMTFCol = C'33,87,243';
input color InpPremiumLine = C'242,54,69';
input color InpEquilLine = C'178,181,190';
input color InpDiscountLine = C'8,153,129';
input color InpFillPremium = C'27,10,12';
input color InpFillEquil = C'20,21,24';
input color InpFillDiscount = C'7,24,16';
input color InpPanelBG = C'12,16,22';
input color InpPanelBorder = C'40,50,62';
input color InpTextCol = clrGainsboro;
input color InpAccent = C'33,87,243';
//------------------------------------------------------------------
// STATE
//------------------------------------------------------------------
AFEngine1MTF g_e1;
AFEngine2Signals g_eng2;
AFDisplayData g_dd;
AFSignalOut g_n, g_c, g_e, g_p;
AFAggOut g_agg;
AFRenderCfg g_cfg;
int g_sN, g_sC, g_sE, g_sP, g_sDisp, g_sD1, g_sW1;
datetime g_lastDispBar;
//+------------------------------------------------------------------+
int OnInit()
{
string nm=AF_PROJECT_NAME+" Engine3";
IndicatorSetString(INDICATOR_SHORTNAME,nm);
IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
// konfigurasi render dari input
AFR_DefaultCfg(g_cfg);
g_cfg.showStructure = InpShowStructure;
g_cfg.showSwingPoints = InpShowSwingPoints;
g_cfg.showOB = InpShowOB;
g_cfg.obCount = MathMax(1,InpOBCount);
g_cfg.showFVG = InpShowFVG;
g_cfg.fvgCount = MathMax(1,InpFVGCount);
g_cfg.showPD = InpShowPD;
g_cfg.showLevels = InpShowLevels;
g_cfg.showSignals = InpShowSignals;
g_cfg.showDashboard = InpShowDashboard;
g_cfg.fontSize = InpFontSize;
g_cfg.fontName = InpFontName;
g_cfg.panelTransparent= InpPanelTransparent;
g_cfg.bull=InpBull; g_cfg.bear=InpBear;
g_cfg.obLineBull=InpIntBullOBLine; g_cfg.obLineBear=InpIntBearOBLine;
g_cfg.obFillBull=InpFillIntBullOB; g_cfg.obFillBear=InpFillIntBearOB;
g_cfg.fvgLineBull=InpBullFVGLine; g_cfg.fvgLineBear=InpBearFVGLine;
g_cfg.fvgFillBull=InpFillBullFVG; g_cfg.fvgFillBear=InpFillBearFVG;
g_cfg.mtfLevel=InpMTFCol;
g_cfg.premiumLine=InpPremiumLine; g_cfg.premiumFill=InpFillPremium;
g_cfg.equilLine=InpEquilLine; g_cfg.equilFill=InpFillEquil;
g_cfg.discountLine=InpDiscountLine; g_cfg.discountFill=InpFillDiscount;
g_cfg.panelBG=InpPanelBG; g_cfg.panelBorder=InpPanelBorder;
g_cfg.textCol=InpTextCol; g_cfg.accent=InpAccent;
// Engine 1: slot agen + display + D1/W1 (level MTF)
// TF agen hardcoded (AF_E2_TF_S1..S4 = H4/M30/M15/M3)
g_sN = g_e1.Register(AF_E2_TF_S1,InpMaxBars);
g_sC = g_e1.Register(AF_E2_TF_S2,InpMaxBars);
g_sE = g_e1.Register(AF_E2_TF_S3,InpMaxBars);
g_sP = g_e1.Register(AF_E2_TF_S4,InpMaxBars);
ENUM_TIMEFRAMES dispTf=(InpDispTF==PERIOD_CURRENT)? (ENUM_TIMEFRAMES)_Period : InpDispTF;
g_sDisp= g_e1.Register(dispTf,InpMaxBars);
g_sD1 = g_e1.Register(PERIOD_D1,AF_E3_LEVELS_D1_BARS);
g_sW1 = g_e1.Register(PERIOD_W1,AF_E3_LEVELS_W1_BARS);
if(g_sN<0 || g_sC<0 || g_sE<0 || g_sP<0 || g_sDisp<0)
{
PrintFormat("%s OnInit: registrasi slot gagal (N=%d C=%d E=%d P=%d D=%d)",
AF_E3_PFX,g_sN,g_sC,g_sE,g_sP,g_sDisp);
return INIT_FAILED;
}
AFR_Clear(g_cfg);
g_lastDispBar=0;
return INIT_SUCCEEDED;
}
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
AFR_Clear(g_cfg);
ChartRedraw();
}
//+------------------------------------------------------------------+
//| Engine 3: hanya menggambar saat bar tertutup baru pada TF display|
//| (non-repaint). Semua data dari Engine 1 & 2. |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,const int prev_calculated,
const datetime &time[],const double &open[],const double &high[],
const double &low[],const double &close[],const long &tick_volume[],
const long &volume[],const int &spread[])
{
g_e1.Refresh();
// butuh slot display siap (bar tertutup terbaru)
if(!g_e1.IsReady(g_sDisp)) return rates_total;
datetime tDisp=g_e1.Time(g_sDisp,0);
if(tDisp==g_lastDispBar) return rates_total; // bar sama -> tidak redraw
g_lastDispBar=tDisp;
// semua slot agen harus siap
if(!g_e1.IsReady(g_sN) || !g_e1.IsReady(g_sC) ||
!g_e1.IsReady(g_sE) || !g_e1.IsReady(g_sP))
return rates_total;
// Engine 2: 4 agen + agregator
g_eng2.Compute(g_e1,g_sN,g_sC,g_sE,g_sP,g_n,g_c,g_e,g_p,g_agg);
// Engine 2: bangun data display (komputasi display ada di Engine 2)
AF_BuildDisplayData(g_e1,g_sN,g_sC,g_sE,g_sP,g_sDisp,g_sD1,g_sW1,
g_cfg.obCount,g_cfg.fvgCount,
g_n,g_c,g_e,g_p,g_dd);
// Engine 3: gambar ulang (render murni)
AFR_Clear(g_cfg);
AFR_DrawAll(g_cfg,g_e1,g_sDisp,g_dd,g_n,g_c,g_e,g_p,g_agg);
ChartRedraw();
return rates_total;
}
//+------------------------------------------------------------------+