EA work base on time event

 
Hi there,

I need your help please I need to force EA work base on time event not on tick event 

how can I do that ??

for ex I want EA to open pending order at specific time ex: when server time = 14 hour and Minute = 15 and seconds = 40 the EA will open pending order 
I need just the code
anyone can help please 
thanks in advance

 
mpowerjo:
hi there,

i need your help please i need to force ea work base on time event not on tick event 

how can i do that ??

for ex i want ea to open pending order at specific time ex: when server time = 14 hour and minute = 15 and seconds = 40 the ea will open pending order 
i need just the code
anyone can help please 
thanks in advance

hello mpowerjo,

please take a look at the event handling functions, specifically the ontimer event handler.

you can also do that using the ontick event handler, through the usage of the mqldatetime struct. 

 
MpowerJo:
Hi there,

I need your help please I need to force EA work base on time event not on tick event 

how can I do that ??

for ex I want EA to open pending order at specific time ex: when server time = 14 hour and Minute = 15 and seconds = 40 the EA will open pending order 
I need just the code
anyone can help please 
thanks in advance

use  while(IsStopped()==false){  }
 
tuoitrecuoi:
use  while(IsStopped()==false){  }
This is a very very discouraging advice. Malacarne's answer is much better.
 
Malacarne:

hello mpowerjo,

please take a look at the event handling functions, specifically the ontimer event handler.

you can also do that using the ontick event handler, through the usage of the mqldatetime struct. 

Thank you Maclaren

The problem is I'm beginner in programming and I know the solution is the ontimer function but I don't Find useful tutorial that can help to understand this function

so if you can help to find tutorial or example to use this function I will be thankful for you

I writ my EA before and I use it for trading now my problem is I need to open my pending orders in small period of time about 2 seconds when I use ontick event handler the EA will wait the new tick from the market

if the price did not make the tick in me 2 seconds period the EA will not open the pending orders

I think the picture is clear now for what I want exactly

I will be thankful if you help me 

 
tuoitrecuoi:
use  while(IsStopped()==false){  }

I use this method before and didn't be useful for me 

thank very much sir 

 
marketeer:
This is a very very discouraging advice. Malacarne's answer is much better.
thanks ^^
 
MpowerJo:

Thank you Maclaren

The problem is I'm beginner in programming and I know the solution is the ontimer function but I don't Find useful tutorial that can help to understand this function

so if you can help to find tutorial or example to use this function I will be thankful for you

I writ my EA before and I use it for trading now my problem is I need to open my pending orders in small period of time about 2 seconds when I use ontick event handler the EA will wait the new tick from the market

if the price did not make the tick in me 2 seconds period the EA will not open the pending orders

I think the picture is clear now for what I want exactly

I will be thankful if you help me 

You may look at this example - https://www.mql5.com/ru/forum/16196#comment_740586.
Вопрос по OnTimer и возможным альтернативам
Вопрос по OnTimer и возможным альтернативам
  • www.mql5.com
Есть ли варианты помимо просто записи времени в глобальную переменную? - - Категория: эксперты форекс, торговые роботы и советники
 

Use this code.

#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
#property strict

int OnInit()
  {
//--- create timer
   EventSetTimer(1);
   OnTimer();
//---
   return(INIT_SUCCEEDED);
  }
void OnTimer()
  {
//---
   Print("hello !") ;
  }
//+------------------------------------------------------------------+



MpowerJo:

I use this method before and didn't be useful for me 

thank very much sir 

Automated Trading and Strategy Testing
Automated Trading and Strategy Testing
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
Reason: