Strange drawing problem, the arrow is misplaced by 2 bar ???

 

Hi all

I am trying to draw out the crossing of this indicator, using both green and red arrow, the red arrows seem to be correctly placed, however the green arrows are always misplaced by 2 bars, e.g it is placed on bar 34 when it is supposed to be bar 36.

I have attached a print screen to show the debugging info. For example, Cross down draws a red arrow at bar number, which is correct, and before that, cross up supposes to draw a green bar at bar 36, but in fact it is placed on bar 34, and going back in time again, cross down draws a red arrow at bar 36, which is correct again, and a cross up should draw a bar at bar 65 but it draws at buy 63.

In summary, the green arrow always draws at bar number - 2.

The code is attached. 

wrong arrow placement

Many thanks for viewing this post and your help

 
Use the debugger or print out your variables, including _LastError and find out why.
 
whroeder1:
Use the debugger or print out your variables, including _LastError and find out why.

There is no Error, hence I output the the shift number using Alert, and for people to understand my problem, I did a screen shot.

As you can it, it actually draws, but just not at the right bar, an offset of 2. 

I have extracted what I believed is the relevant code below, the full script is attached. 

I have done my best to find out why and I just can not get to anywhere further hence I am asking on this forum.

#property indicator_color4    DarkGreen
#property indicator_width4    3
#property indicator_color5    Red
#property indicator_width5    3

   SetIndexStyle(3,DRAW_ARROW);
   SetIndexArrow(3, 221);
   SetIndexStyle(4,DRAW_ARROW);
   SetIndexArrow(4, 222);
   SetIndexBuffer(3, CrossUp);
   SetIndexBuffer(4, CrossDown);

CrossUp[shift] = Low[shift] - 5;

Alert("Cross Up, bar number ", shift);
 

Does anyone have any idea please?

 
luckyvictor: There is no Error, As you can it, it actually draws, but just not at the right bar, an offset of 2.
If it doesn't do what you want, that is the error. Use the debugger or print out your variables, and find out why. We're not going to debug your 200+ lines of code.
Reason: