//+------------------------------------------------------------------+ //| Liquidity.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" //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int8_t idx_controler_d1 = INVALID_INDEX; int8_t idx_controler_curr = INVALID_INDEX; CSwingBar* swing; CLiquidity liquidez; #define LIQ_TIPO_SWING 0 //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- g_new_bar_manager.GetPosExecute(PERIOD_D1, idx_controler_d1); g_new_bar_manager.GetPosExecute(_Period, idx_controler_curr); //--- MqlParam params[]; ZZToParams(5, 400, false, params); // Obtenemos las configuraciones del swing swing = new CSwingBarZigZag(); // Creamos el swing como tipo CSwingBarZigZag, el swing sera del tipo zigzag swing.Create(_Symbol, _Period, 0, 0, false, params); // Segundo, crear el swing swing.SetProperties(clrBlue, clrRed, "H", "L", "Arial", 8, 10); // Establecemos propiedades //--- liquidez.Initilize(_Period, _Symbol, 0, 0, false, 20); liquidez.CreateLiquidityLevel("Swings", clrRed, 1, STYLE_DASHDOTDOT); //Retorna 0 //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- delete swing; 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) && CNewBarManager_IsNewBar(g_new_bar_manager, idx_controler_curr)) { const bool new_day = CNewBarManager_IsNewBar(g_new_bar_manager, idx_controler_d1); ICTGen_FuncionOnBarM1(new_day, curr_time); //--- swing.OnNewBar(); //--- liquidez.OnNewBarInit(curr_time); Liq_AddSwings(); liquidez.OnNewBarEnd(); } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void Liq_AddSwings() { const int idx_a = swing.HayUnNuevoSwing(SWING_ALCISTA); const int idx_b = swing.HayUnNuevoSwing(SWING_BAJISTA); //--- if(idx_a >= 0) { liquidez.AddLiquidityLevel(swing.GetSwingsAlcistas(idx_a), LIQ_TIPO_SWING, LIQUIDITY_BULL); } else if(idx_b >= 0) { liquidez.AddLiquidityLevel(swing.GetSwingsBasjitas(idx_b), LIQ_TIPO_SWING, LIQUIDITY_BEAR); } } //+------------------------------------------------------------------+