ICTLibraryExamples/Base/Consolidation/Rango.mq5
81 lines
3 KiB
MQL5
Nique_372
2025-12-09 13:28:37 -05:00
//+------------------------------------------------------------------+
//| Rango.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
Nique_372
2026-02-01 13:11:51 -05:00
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#define DEFGLOBAL_SIMPLE
Nique_372
2026-01-06 06:46:34 -05:00
#include "..\\..\\DefGlobal.mqh"
Nique_372
2026-02-01 13:11:51 -05:00
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
Nique_372
2026-01-06 06:46:34 -05:00
int8_t idx_controler_d1 = INVALID_INDEX;
int8_t idx_curr = INVALID_INDEX;
Nique_372
2025-12-09 13:28:37 -05:00
CRango rango_consolidacion;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
Nique_372
2026-01-06 06:46:34 -05:00
//--- Registramos timeframe D1
g_new_bar_manager.GetPosExecute(PERIOD_D1, idx_controler_d1);
g_new_bar_manager.GetPosExecute(_Period, idx_curr);
Nique_372
2025-12-09 13:28:37 -05:00
//---
int handle_pos_atr = ICTAtr_Create(_Period, _Symbol, 14, false);
Nique_372
2026-10-23 21:51:38 -05:00
TSN::CAtr* atr_ptr = ICTAtr_GetAtrPointer(handle_pos_atr);
Nique_372
2025-12-09 13:28:37 -05:00
Nique_372
2026-01-06 06:46:34 -05:00
//---
Nique_372
2025-12-09 13:28:37 -05:00
rango_consolidacion.Create(_Symbol, _Period);
Nique_372
2026-10-23 21:51:38 -05:00
rango_consolidacion.Set(true, clrOldLace, 1, STYLE_SOLID, PURE_SWINGS, 5, 250, TSN::CreateDiffptr(TSN::MODE_DIFF_BY_ATR, _Symbol, atr_ptr, 1, 2.0));
Nique_372
2025-12-09 13:28:37 -05:00
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
Nique_372
2026-02-01 13:11:51 -05:00
ICTGen_OnDeinitEvent(reason);
Nique_372
2025-12-09 13:28:37 -05:00
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
const datetime curr_time = TimeCurrent();
Nique_372
2026-01-06 06:46:34 -05:00
g_new_bar_manager.Execute(curr_time);
Nique_372
2025-12-09 13:28:37 -05:00
//---
Nique_372
2026-01-06 06:46:34 -05:00
if(CNewBarManager_IsNewBarM1(g_new_bar_manager) && CNewBarManager_IsNewBar(g_new_bar_manager, idx_curr))
Nique_372
2025-12-09 13:28:37 -05:00
{
Nique_372
2026-01-06 06:46:34 -05:00
const bool new_day = CNewBarManager_IsNewBar(g_new_bar_manager, idx_controler_d1);
ICTGen_FuncionOnBarM1(new_day, curr_time);
Nique_372
2025-12-09 13:28:37 -05:00
Nique_372
2026-01-06 06:46:34 -05:00
rango_consolidacion.OnNewBar();
Nique_372
2025-12-09 13:28:37 -05:00
if(rango_consolidacion.GetTypeRoptura() == ROPTURA_HACIA_ABAJO)
{
Print("Venta");
}
else
if(rango_consolidacion.GetTypeRoptura() == ROPTURA_HACIA_ARRIBA)
{
Print("compra");
}
}
}
//+------------------------------------------------------------------+