Why does it recalculate or repaint ?

To add comments, please log in or register
MadaForex
121
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.

Mladen Rakic
159819
Mladen Rakic  
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

MadaForex
121
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 ?

Mladen Rakic
159819
Mladen Rakic  
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)

MadaForex
121
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 ?

Files:
capture_2.png 17 kb
MadaForex
121
MadaForex  

forgot to post my code sorry :

attached

MadaForex
121
MadaForex  

here it is.

Mladen Rakic
159819
Mladen Rakic  
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 ?

MadaForex
121
MadaForex  

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.

To add comments, please log in or register