//+------------------------------------------------------------------+ //| OrderBlock.mq5 | //| Copyright 2025, Leo. | //| https://www.mql5.com/es/users/nique_372/news | //+------------------------------------------------------------------+ #property copyright "Copyright 2025, Leo." #property link "https://www.mql5.com/es/users/nique_372/news" #property version "1.00" #property strict #define DEFGLOBAL_SIMPLE #include "..\\..\\..\\DefGlobal.mqh" //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ sinput group "------| Order Blocks |------" input int minutos_despues_mitigacion_eliminar_ob = 10; //minutes to delete the order block after being invalidated input bool mostar_la_mitad_ob = true; //show the middle line of an order block? input ENUM_ORDERBLOCKS_OBTENCIUON_TYPE mod_obtencion_obs = ORDER_BLOCKS_ALL; //Order blocks Obtaining mode sinput group "--| General properties of the order block rectangle" input bool fill_order_blocks = true; //Fill Order Blocks? sinput group "--| Bullish order block" input color Color_OrderBlock_Alcista = C'45,154,29'; // Choose the Bullish Order Block Color input color line_mitad_color_oba = clrDarkGreen; //color of the middle line of the bullish order blocks input ENUM_OB_STYLE price_1_oba = low; // choose price1 bullish order block input ENUM_OB_STYLE price_2_oba = high; // choose price2 bullish order block sinput group "--| Bearish order block" input color Color_OrderBlock_Bajista = C'249,95,57'; // Choose the Bearish Order Block Color input color line_mitad_color_obb = clrTomato; //color of the middle line of the bearish order blocks input ENUM_OB_STYLE price_1_obb = high; // choose price1 bearish order block input ENUM_OB_STYLE price_2_obb = low; // choose price2 bearish order block sinput group "--| Settings order block by sweeps" input int16_t lenth_order_block = 4; //Num bar of swings to identify swing points input ENUM_TYPE_ROPTRUA_CONFIRMAR_OB breakout_type_ob = BREAKUP_VELA_ROPTURA_SWING;// break type for order block by sweep input int max_espera_roptura_ob_sweep = 20; //maximum wait in bars to break a swing or open of a candle sinput group "--| Alerts" input bool enable_alert_ob = false; //Activate alerts when an order block is touched? input string type_alerts_ob = "Alert|Notification"; //Types of alerts when an order block is touched //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int8_t idx_controler_d1 = INVALID_INDEX; COrderBlockBar order_block; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- g_new_bar_manager.GetPosExecute(PERIOD_D1, idx_controler_d1); //--- order_block.Create(_Symbol, _Period, 0, 0); order_block.SetGrapich(Color_OrderBlock_Alcista, Color_OrderBlock_Bajista, line_mitad_color_oba, line_mitad_color_obb, STYLE_SOLID, fill_order_blocks, 1, mostar_la_mitad_ob, minutos_despues_mitigacion_eliminar_ob, 1, STYLE_DOT); order_block.SetTypeBusqueda(mod_obtencion_obs); order_block.SetStylesPrices(price_1_oba, price_1_obb, price_2_oba, price_2_obb); order_block.SetOrderBlockSweep(lenth_order_block, max_espera_roptura_ob_sweep, breakout_type_ob); order_block.Set(500); order_block.SetAlertas(enable_alert_ob, type_alerts_ob); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- ICTGen_OnDeinitEvent(reason); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- const datetime curr_time = TimeCurrent(); g_new_bar_manager.Execute(curr_time); //--- if(CNewBarManager_IsNewBarM1(g_new_bar_manager)) { const bool new_day = CNewBarManager_IsNewBar(g_new_bar_manager, idx_controler_d1); ICTGen_FuncionOnBarM1(new_day, curr_time); order_block.OnNewBar(); //Ejecutamos OnNewBar } } //+------------------------------------------------------------------+