Rectangle from Sunday to Monday is drawn already on Friday

 

Hi,

if I draw a rectangle from Sunday (e.g. 09th March) to Monday, the rectangle is drawn already on Fridays last bar.

Its a bug?



Maybe its a problem with no quotes on Sunday with some demo-accounts?


Regards

Burkhard

 
I think that you will find that as there is no bar with that time, it will use the latest bar before that time.
 
I've already thought of this, but this is not a good solution. When I want to show a session (with rectangle) and MetaTrader colored me the previous bar (not in my favorite session), that's not so good.
 
BurkhardWille:
I've already thought of this, but this is not a good solution. When I want to show a session (with rectangle) and MetaTrader colored me the previous bar (not in my favorite session), that's not so good.
Use the time of your chart. There is no Monday 9 on your chart.
 
BurkhardWille:
I've already thought of this, but this is not a good solution. When I want to show a session (with rectangle) and MetaTrader colored me the previous bar (not in my favorite session), that's not so good.

Is this rectangle placed on the chart by you or by code?
 
GumRai:

Is this rectangle placed on the chart by you or by code?

The problem is with both methods!


angevoyageur:
Use the time of your chart. There is no Monday 9 on your chart.

Thats correct, some brokers have Sundays bars, some not. However, the rectangle should not start on Friday.
 
GumRai:

Is this rectangle placed on the chart by you or by code?

BurkhardWille:

The problem is with both methods!


If you are placing the object on the chart yourself, why are you trying to place it with the time co-ordinate of a bar that you know will not exist?

There is no 22:00 on a Sunday with your broker.

If it is being placed by code, then modify the code so that this doesn't happen.

 
GumRai:

There is no 22:00 on a Sunday with your broker.

If it is being placed by code, then modify the code so that this doesn't happen.


How can I use the next bar? I try to check the bar Sunday 22:00, but if the bar doesn't exist, then use the next bar right side (22:15), but what if, when the next bar also not exist?
 
BurkhardWille:

How can I use the next bar? I try to check the bar Sunday 22:00, but if the bar doesn't exist, then use the next bar right side (22:15), but what if, when the next bar also not exist?
There is no Sunday bar on your chart, so what are you trying to achieve ? You can always check that a bar exists before using it.
 
BurkhardWille:

How can I use the next bar? I try to check the bar Sunday 22:00, but if the bar doesn't exist, then use the next bar right side (22:15), but what if, when the next bar also not exist?


You use iBarShift with exact =true to try to find the 22:00 candle

If the candle doen't exist, then iBarShift exact will return -1

If that is the case use iBarShift again without the exact setting and it will return the shift of the candle prior to 22:00

This shift, minus 1 will give you the shift of the first candle after 22:00

Reason: