//+------------------------------------------------------------------+ //| Ob.mq5 | //| Copyright 2026, Niquel Mendoza. | //| https://www.mql5.com/es/users/nique_372 | //+------------------------------------------------------------------+ #property copyright "Copyright 2026, Niquel Mendoza." #property link "https://www.mql5.com/es/users/nique_372" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| Include | //+------------------------------------------------------------------+ #include "..\\Src\\Defines.mqh" //+------------------------------------------------------------------+ //| Global variables | //+------------------------------------------------------------------+ //--- Order Block buffers double g_bullish_ob_buffer[]; double g_bearish_ob_buffer[]; //--- Indicator handle int g_handle = INVALID_HANDLE; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- Load ICT SMC indicator ResetLastError(); g_handle = iCustom(_Symbol, _Period, ICTSMCIND_NAME_RES); if(g_handle == INVALID_HANDLE) { PrintFormat("Failed to load TheSmcIctIndicator, last error = %d", GetLastError()); return INIT_FAILED; } else { Print("Successful loading TheSmcIctIndicator"); } //--- Set buffers as series (index 0 = most recent bar) ArraySetAsSeries(g_bullish_ob_buffer, true); ArraySetAsSeries(g_bearish_ob_buffer, true); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- Release handle to free resources if(g_handle != INVALID_HANDLE) IndicatorRelease(g_handle); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- Only process on new bar open static datetime last_time = 0; const datetime new_time = iTime(_Symbol, _Period, 0); if(last_time == new_time) return; //--- Copy 2 candle data (candle 1 and 2) ResetLastError(); if(CopyBuffer(g_handle, ICTSMCIND_BUFFER_BULLISH_OB, 1, 2, g_bullish_ob_buffer) != 2 || CopyBuffer(g_handle, ICTSMCIND_BUFFER_BEARISH_OB, 1, 2, g_bearish_ob_buffer) != 2) { Print("Error copying indicator data, last error = ", GetLastError()); return; } //--- if(g_bullish_ob_buffer[0] < g_bullish_ob_buffer[1] && g_bullish_ob_buffer[1] > ICTSMCIND_VOID_BUFFER_VALUE) { Print("Bullish order block mitigation now"); } if(g_bearish_ob_buffer[0] > g_bearish_ob_buffer[1] && g_bearish_ob_buffer[1] < ICTSMCIND_BLOCK_GEN_BEARISH_EMPTY_VALUE) { Print("Bearish order block mitigation now"); } //--- Update timestamp last_time = new_time; } //+------------------------------------------------------------------+