60 lines
4.9 KiB
MQL5
60 lines
4.9 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| Sessions.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
|
|
|
|
#include <ICTLibraryEasy\\Main.mqh>
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
CBarControler bar_controlerd1(PERIOD_D1, _Symbol);
|
|
CBarControler bar_controler_curr(_Period, _Symbol);
|
|
CTradingSession session;
|
|
//+------------------------------------------------------------------+
|
|
//| Expert initialization function |
|
|
//+------------------------------------------------------------------+
|
|
int OnInit()
|
|
{
|
|
//--- Configuramos la session 1
|
|
session.Create(_Symbol, _Period, 0, 0, true, true, 10, 0, 15, 0, "Trading session");
|
|
session.SetGrapichStyles(STYLE_SOLID, clrAntiqueWhite, 1, true);
|
|
session.SetExtra(clrAqua, clrAliceBlue, STYLE_SOLID, 2, draw_session_range_lines_and_rect);
|
|
|
|
//---
|
|
return(INIT_SUCCEEDED);
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Expert deinitialization function |
|
|
//+------------------------------------------------------------------+
|
|
void OnDeinit(const int reason)
|
|
{
|
|
//---
|
|
ICTGen_OnDeinitEvent();
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
//| Expert tick function |
|
|
//+------------------------------------------------------------------+
|
|
void OnTick()
|
|
{
|
|
//---
|
|
const datetime curr_time = TimeCurrent();
|
|
const bool new_day = bar_controlerd1.IsNewBar(curr_time);
|
|
|
|
//---
|
|
const bool new_bar = bar_controler_curr.IsNewBar(curr_time);
|
|
ICTGen_FuncionOnTick(new_day, curr_time); //Luego OnTick
|
|
if(new_bar)
|
|
ICTGen_FuncionOnBar(new_day, curr_time); //Primero siempre ejecutar FUncionOnBar
|
|
|
|
session.OnTickEvent();
|
|
|
|
if(new_bar)
|
|
ICTGen_FuncionOnEndBar(); //Finlizar con OnEndBar
|
|
}
|
|
//+------------------------------------------------------------------+
|