Why does it recalculate or repaint ?

 

Hello all,

I have done a simple indicator ; a kind of alligator cross arrow.

Same MA with , , and .

But i have tested it, and i saw that sometimes, an arrow disappear one or two candles after.

As i am not an experienced coder, i need help again to fix, and not recalculate or repaint when a an arrow is drawn on closed candle.

Thank you.

 
MadaForex:
Hello all,

I have done a simple indicator ; a kind of alligator cross arrow.

Same MA with , , and .

But i have tested it, and i saw that sometimes, an arrow disappear one or two candles after.

As i am not an experienced coder, i need help again to fix, and not recalculate or repaint when a an arrow is drawn on closed candle.

Thank you.

MadaForex

Index mean one bar into the future. That is the reason why it repaints as you described

 

I suppose it's because if this line

for(int i=limit; i>=0; i--)

"i" should be superior or equal to zero.

What should i write ?

 
MadaForex:
I suppose it's because if this line

for(int i=limit; i>=0; i--)

"i" should be superior or equal to zero.

What should i write ?

You should avoid indexes like i-1 (for example Close is the first future Close price relative to the currently calculated bar)

 

Ok, thought it was the past candle.

And please, how can draw the cross over of this :

2EMA (shift=0) > 2EMA (shift=+1)

&&

2EMA (shift=0) > 2EMA (shift=-1)

Like the attached image ?

Files:
capture_2.png  17 kb
 

forgot to post my code sorry :

attached

 

here it is.

Files:
 
MadaForex:
Ok, thought it was the past candle.

And please, how can draw the cross over of this :

2EMA (shift=0) > 2EMA (shift=+1)

&&

2EMA (shift=0) > 2EMA (shift=-1)

Like the attached image ?

I am afraid but I do not understand the idea

Do you mind explaining a bit more ?

 

Hello mladen,

hank you for your response.

In fact if you put the alligator with this setup, you will have 3 Moving averages. and i want to have arrows when the fist MA is above the others "&&" when the 2nd is above the 3rd.

And vice-versa.

Reason: