void OnStart() { MqlDateTime curDate; TimeCurrent(curDate); if(curDate.hour==9) { Print("Do somethig"); } else { Print("It is not 9 O'Clock yet"); } } //+------------------------------------------------------------------+
Thanks. But this must be done into OnCalculate, because I am doing a chart indicator.
MqlDateTime curDate; datetime dt=iTime(NULL,0,0); TimeToStruct(dt,curDate);This should work in OnCalculate (untested.)
int hora_inicio_trading=9; hora_actual_local=TimeHour(TimeLocal()); if(hora_actual_local==hora_inicio_trading && TimeMinute(TimeLocal())==0) { }
This is what I use. Although the code is for a robot you would easily modify it for use in an indicator.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I am doing an indicator for stock market that starts at 9 AM. So I want get the first price of day and start or restart the calculation at 9 AM.
I have tried this into OnCalculate, but it is not working
I appreciate any help.