How to remove extra arrows in an indicator?

 

Hi everyone,

I wrote an indicator to display arrows & alert me whenever the closed candlestick is above 50, 100 and 150 EMA lines.

That worked and I'm happy with the code. But there's an issue occurred:

https://i.ibb.co/5YfBRw8/090.jpg


When I run the indicator, it draw many extra arrows as soon as the conditions are met. So, how may I disable creating more arrows when the first one is draw?

 
torabian:

So, how may I disable creating more arrows when the first one is draw?

remember (static) the first arrow direction, until new arrow != new direction.

 
torabian:

Hi everyone,

I wrote an indicator to display arrows & alert me whenever the closed candlestick is above 50, 100 and 150 EMA lines.

That worked and I'm happy with the code. But there's an issue occurred:

https://i.ibb.co/5YfBRw8/090.jpg


When I run the indicator, it draw many extra arrows as soon as the conditions are met. So, how may I disable creating more arrows when the first one is draw?

Most likely there is an error in your code, resulting in multiple arrows instead of only one.
 
Comments that do not relate to this topic, have been moved to "Off Topic Posts".
 
Mohamad Zulhairi Baba:

remember (static) the first arrow direction, until new arrow != new direction.

Thanks Mohammad, but can't understand what you mean

 
WindmillMQL:
Most likely there is an error in your code, resulting in multiple arrows instead of only one.
Actually no, the code doesn't generate any error. I can't understand how should I modify it
 
torabian: alert me whenever the closed candlestick is above 50, 100 and 150 EMA lines.

Don't Alert on a signal. Act on a change of signal.
          MQL4 (in Strategy Tester) - double testing of entry conditions - MQL5 programming forum #1 2017.12.12

 

What I do in mine is create a variable" int lastWas=5;  "  Then I check to make sure "lastWas" is not equal to 1 for up arrow or 2 for down arrow. So something like  ...  

 if

( iClose(NULL,0,1)>iMA( bla bla bla)

&& iClose(NULL,0,2)< iMA( yadda , yadda, yadda) 

&& lastWas!=1 //1 is up, 2 is down

)

{

Buffer1[1]=iLow(NULL,0,1);

lastWas=1;

}

As long as lastWas is not equal to 1 , it will paint, else..nothing but clean chart :)