How to remove extra arrows in an indicator?

To add comments, please log in or register
torabian
17
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?

Mohamad Zulhairi Baba
21011
Mohamad Zulhairi Baba  
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.

WindmillMQL
232
WindmillMQL  
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.
Keith Watford
Moderator
24134
Keith Watford  
Comments that do not relate to this topic, have been moved to "Off Topic Posts".
torabian
17
torabian  
Mohamad Zulhairi Baba:

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

Thanks Mohammad, but can't understand what you mean

torabian
17
torabian  
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
William Roeder
22310
William Roeder  
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

Djinn Trader
14
Djinn Trader  

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 :)

To add comments, please log in or register