Download MetaTrader 5

Rectangle from Sunday to Monday is drawn already on Friday

To add comments, please log in or register
Find out the most discussed Forum topics. Have a look at the Wall section!
BurkhardWille
170
BurkhardWille 2014.03.16 11:14 

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

Keith Watford
Moderator
9619
Keith Watford 2014.03.16 11:20  
I think that you will find that as there is no bar with that time, it will use the latest bar before that time.
BurkhardWille
170
BurkhardWille 2014.03.16 19:36  
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.
Alain Verleyen
Moderator
30727
Alain Verleyen 2014.03.16 20:06  
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.
Keith Watford
Moderator
9619
Keith Watford 2014.03.16 20:28  
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?
BurkhardWille
170
BurkhardWille 2014.03.18 17:07  
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.
Keith Watford
Moderator
9619
Keith Watford 2014.03.18 22:35  
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.

BurkhardWille
170
BurkhardWille 2014.04.06 11:28  
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?
Alain Verleyen
Moderator
30727
Alain Verleyen 2014.04.06 12:11  
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.
Keith Watford
Moderator
9619
Keith Watford 2014.04.06 13:50  
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

To add comments, please log in or register