| //+------------------------------------------------------------------+
|
| //| Sessions2.mq5 |
|
| //| Copyright 2025, Niquel Mendoza. |
|
| //| https://www.mql5.com/es/users/nique_372/news |
|
| //+------------------------------------------------------------------+
|
| #property copyright "Copyright 2025, Niquel Mendoza."
|
| #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;
|
| CSessionManagerMit sesiones_manager;
|
|
|
| //+------------------------------------------------------------------+
|
| //| Expert initialization function |
|
| //+------------------------------------------------------------------+
|
| int OnInit()
|
| {
|
| //---
|
| g_new_bar_manager.GetPosExecute(PERIOD_D1, idx_controler_d1);
|
| g_new_bar_manager.GetPosExecute(_Period, idx_controler_curr);
|
|
|
|
|
| //--- Configuramos la session 1
|
| CRangeSession* sesion_1 = new CRangeSession();
|
| sesion_1.Create(_Symbol, _Period, 0, 0, true, true, 5, 0, 10, 15, "Sesion 1");
|
| sesion_1.SetGrapichStyles(STYLE_SOLID, clrAliceBlue, 1, true);
|
| sesion_1.Set(1, STYLE_SOLID, clrBlue, clrBlueViolet, clrAliceBlue, draw_session_text_abajo, draw_session_range_only_rect);
|
|
|
| sesiones_manager.AddItemFast(sesion_1); //añadimos la sesion 1 al manager
|
|
|
| //--- Configuramos la sesion 2
|
| CRangeSession* sesion_2 = new CRangeSession();
|
| sesion_2.Create(_Symbol, _Period, 0, 0, true, true, 11, 0, 20, 15, "Sesion 2");
|
| sesion_2.SetGrapichStyles(STYLE_SOLID, clrAliceBlue, 1, true);
|
| sesion_2.Set(1, STYLE_SOLID, clrBlue, clrBlueViolet, clrAliceBlue, draw_session_text_abajo, draw_session_range_only_rect);
|
|
|
| sesiones_manager.AddItemFast(sesion_2); //añadimos la sesion 2 al manager
|
|
|
| //---
|
| // sesiones_manager.Init(_Period,_Symbol); ya se infilzia con valores por defecto
|
|
|
| //---
|
| 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);
|
| sesiones_manager.OnNewBarM1();
|
|
|
| if(CNewBarManager_IsNewBar(g_new_bar_manager, idx_controler_curr))
|
| {
|
| sesiones_manager.OnNewBar();
|
| if(sesiones_manager.MaxSessionIsMitigated())
|
| {
|
| PrintFormat("Maximo de la sesion %s ha sido mitigado", sesiones_manager.GetSessionNameMaxMitigated());
|
| }
|
| if(sesiones_manager.MinSessionIsMitigated())
|
| {
|
| PrintFormat("Minimo de la sesion %s ha sido mitigado", sesiones_manager.GetSessionNameMinMitigated());
|
| }
|
| }
|
| }
|
| }
|
| //+------------------------------------------------------------------+
|