ForexBoat Trading Academy

Coding Time Of Day Controls – MQL4 for Complete Beginners Tutorial Part 25

The preparation stage is complete and today we will finally start programming our FOREX Robot in MQL4. We will start by completing the blue section of the trading strategy design template, which is responsible for time of day controls. If you recall we want our expert advisor to send buy and sell orders only once at a certain hour of every day. That is exactly what we will implement today.

Enrol in the full course here: https://www.forexboat.com/learn-mql4


//+------------------------------------------------------------------+
//| SimpleSystem.mq4 |
//| Copyright 2014, ForexBoat |
//| http://www.forexboat.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, ForexBoat"
#property link "http://www.forexboat.com"
#property version "1.00"
#property strict

extern int StartHour = 9;

void OnTick()
{
static bool IsFirstTick = true;

if(Hour() == StartHour)
{
if(IsFirstTick == true)
{
IsFirstTick = false;

//CORE OF THE ALGORITHMIC TRADING SYSTEM

Alert("First tick of hour");
}

}
else
{
IsFirstTick = true;
}

}