Checking bar existence for current date, MQL5

 

Dear Friends,

 Please, who can help me with my problem?

EURUSD Weekly

 

EURUSD Daily 

 Line is placed by script, so, I want to check date existence and place it exactly on week start. Or, I it will be nice to have any solution to achieve result. 

 

Regards, 

 

Hi,

If your line is placed by script, what's your problem exactly ? When you place a line it's up to you to choose where to place it.

Please show the relevant code.

 

The code is:

 

datetime dt_tm1 = 0, dt_buff[1] = {0};   

CopyTime( _Symbol, PERIOD_W1, 0, 1, dt_buff );

dt_tm1 = dt_buff[0];


Then I use dt_tm1 as time parameter to create line. 

 

Forum on trading, automated trading systems and testing trading strategies


Please use the SRC button when you post code. Thank you.


This time, I edited it for you.

I see now. The first day of a week is always Sunday, see documentation :

Thus, if the current day is Saturday, at the attempt to copy data on a week timeframe specifying start_time=Last_Tuesday and stop_time=Last_Friday the function will return 0, because the open time on a week timeframe is always Sunday, but one week bar does not fall into the specified interval.

 

angevoyageur,

Sorry, my mistake -- I will use SRC for code! :)

I understood and will check the documentation. Thank you for help!

Regards, 

Reason: