- Please use the "</>" icon (Alt-S) to add code to your post. Don't just paste code as plain text.
- Don't access time-series data from the OnInit() even handler. The chart data may not be ready yet. Do in it in the OnTick() event handler.
- The iTime() function returns a datatime data-type and not an int. So declare the receiving variable as a datatime.
- Don't set the event timer on every tick. Set once only or when its duration needs to change.
- Set the event time based on a time duration and not a set datetime as you are doing.

Documentation on MQL5: Timeseries and Indicators Access / iTime
- www.mql5.com
iTime - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

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
Hello everyone,
I would appreciate your help since I am not so familiar with mql4.
My goal:
When the code starts EventSetTimer should be 0 as well as the variable x to get the close of bar 0 and bar 1 as "sell"/"buy" comment.
After that the EventSetTimer should work only 5 seconds after the candle of the 1h time frame has closed, giving me the close of bar 1 and bar 2 as "sell"/"buy" comment.
The code you can find below. The code did not show any errors but the following warning at "int OnInit()" for t2 --> «possible loss of data due to type conversion»
Thank you in advance.
___________________________________________
#property strict
// inputs