yesterday=DayOfWeek()-1; if (yesterday==0) yesterday=5;
Hi
Suppose that today is MONDAY and I want to number of yesterday. I know I can use DayOfWeek() but if it's MONDAY I cannot do this | DayOfWeek()-1 |, because it returns 0 but I meant 5. And also if yesterday the market was closed what then?! I want to have last working day number.
Could anyone help on this?
Try:
int previous_trading_day = TimeDayOfWeek(iTime(_Symbol, PERIOD_D1, 1));
Remember to trap and properly deal with a 4066 runtime error. The above works well with broker servers that don't have weekend bars.
Try:
Remember to trap and properly deal with a 4066 runtime error. The above works well with broker servers that don't have weekend bars.
So helping. Thank you very much.
Try:
Remember to trap and properly deal with a 4066 runtime error. The above works well with broker servers that don't have weekend bars.
I never found a way how to properly deal with the 4066 error. Whatever I did in the code, the error appeared once every time, and never twice, regardless if the history was still loading or the chart has already been up to date.
Could you show us how to properly deal with the 4066 error?
I never found a way how to properly deal with the 4066 error. Whatever I did in the code, the error appeared once every time, and never twice, regardless if the history was still loading or the chart has already been up to date.
Could you show us how to properly deal with the 4066 error?
It seems we should just wait for around 10seconds to send another request. No other solution found.
see also: https://www.mql5.com/en/forum/127460
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
Suppose that today is MONDAY and I want to number of yesterday. I know I can use DayOfWeek() but if it's MONDAY I cannot do this | DayOfWeek()-1 |, because it returns 0 but I meant 5. And also if yesterday the market was closed what then?! I want to have last working day number.
Could anyone help on this?