- Period is in minutes (only on MT4). OpenTime is in seconds. Use PeriodSeconds().
- If you fix № 1, you will be trying to open an order per tick.
-
Be careful with NULL.
- On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not, OrderSend does not.
- Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
- Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
- MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
- Cloud Protector Bug? - MQL4 programming forum 2020.07.25
- Period is in minutes (only on MT4). OpenTime is in seconds. Use PeriodSeconds().
- If you fix № 1, you will be trying to open an order per tick.
-
Be careful with NULL.
- On MT4, you can use NULL in place of _Symbol only in those calls that the documentation specially says you can. iHigh does, iCustom does, MarketInfo does not, OrderSend does not.
- Don't use NULL (except for pointers where you explicitly check for it.) Use _Symbol and _Period, that is minimalist as possible and more efficient.
- Zero is the same as PERIOD_CURRENT which means _Period. Don't hard code numbers.
- MT4: No need for a function call with iHigh(NULL,0,s) just use the predefined arrays, i.e. High[].
- Cloud Protector Bug? - MQL4 programming forum 2020.07.25
I tested it but it doesn't work .
the EA doesn't open at time .
TimeCurrent()>=StrToTime(OpenTime)&&TimeCurrent()<StrToTime(OpenTime)+PeriodSeconds()
extern string OpenTime="01:00";//Time to place trades (HH:MM) datetime time = StrToTime(OpenTime); datetime current = TimeCurrent(); datetime next = time + PeriodSeconds(); if(TimeHour(current)>=TimeHour(time) && TimeMinute(current)>=TimeMinute(time) && TimeHour(current)<TimeHour(next) && TimeMinute(current)<TimeMinute(next)){ if(n_open_sells<=0) double sell= OrderSend(NULL,OP_SELL,LotSize,Bid,50,SL,TP,NULL,MagicNumber,0,clrRed); }
if(TimeHour(current)>=TimeHour(time) && TimeMinute(current)>=TimeMinute(time)
Bogus. For example. If time is 1:15 then the compare is true for [1:15 to 2:00) and [2:15 to 3:00) etc. it fails from [2:00 to 2:15)
I tested it but it doesn't work .
the EA doesn't open at time .
TimeCurrent()>=StrToTime(OpenTime)&&TimeCurrent()<StrToTime(OpenTime)+PeriodSeconds()
Never use StrToTime() or StringToTime() unless the string also includes the date.
If there is no actual date in the string, the date will be taken from the computer's local time, not platform time.
So if the string is "01:00" and the platform date is 7th January, you will expect the time returned to be 1:00 on the 7th January.
However, if your computer local time is behind the platform time, eg 23:00 on 6th January, the time returned will be 1:00 on the 6th January.
This will obviously affect your calculations.
Never use StrToTime() or StringToTime() unless the string also includes the date.
If there is no actual date in the string, the date will be taken from the computer's local time, not platform time.
So if the string is "01:00" and the platform date is 7th January, you will expect the time returned to be 1:00 on the 7th January.
However, if your computer local time is behind the platform time, eg 23:00 on 6th January, the time returned will be 1:00 on the 6th January.
This will obviously affect your calculations.
I have already used PeriodSecond() but without any result .
so if the time of computer is totally different of broker time , what is the best solution ?
Never use StrToTime() or StringToTime() unless the string also includes the date.
If there is no actual date in the string, the date will be taken from the computer's local time, not platform time.
So if the string is "01:00" and the platform date is 7th January, you will expect the time returned to be 1:00 on the 7th January.
However, if your computer local time is behind the platform time, eg 23:00 on 6th January, the time returned will be 1:00 on the 6th January.
This will obviously affect your calculations.
Never use StrToTime() or StringToTime() unless the string also includes the date.
What does that have to do with my post?
so if the time of computer is totally different of broker time , what is the best solution ?
Don't use StringToTime().
can I change my computer time to broker time ? it will work in this wat ?
That would be a rather silly way to make it work.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello
I coded my EA to open orders at time , the issue is the EA doesn't open trades if i leave the EA to work for next days even if i use VPS .