Preventing indicator from sending multiple signals per bar

 

Hello,


I have found a custom indicator which I would like to use for Trading.


Now when I implement a function for alarming on signal, it generates a dozen of signals.

When using this indicator in an EA this matter ends up in generation of a dozen of buys or sells at each bar.


How can I prevent the indicator from doing this. For example in sending only one signal each bar.


Attached the indicator.


Thank You for Your help

Files:
 

use a static or global boolean


russell

 
eduardkiefel:

Hello,


I have found a custom indicator which I would like to use for Trading.


Now when I implement a function for alarming on signal, it generates a dozen of signals.

When using this indicator in an EA this matter ends up in generation of a dozen of buys or sells at each bar.


How can I prevent the indicator from doing this. For example in sending only one signal each bar.


Attached the indicator.


Thank You for Your help

When the current bar hasn't ened,  there is only one OPEN price, but there are many CLOSE price. For example, in the whole bar there are four ticks come: 1.4000, 1.4010, 1.4020 and 1.4030. Whenever a tick comes, it's price is considered as the CLOSE price. If the indicator's condition is satisfied there will be a signal. There will be 4 singals in this example. If you want only one signal at each bar, my idea is that don't use the indicator and open an order at the same bar. Instead, you can use the indicator at bar 1 and open an order at bar 0. Then there will be only one CLOSE price at each bar, so there will be only one buy or sell signals at each bar.

 

Or just let the signals be generated but filtered by the EA.


The EA, on receiving the first signal will open a position. Subsequently signals will not trigger anything because a position has already been opened for that same Time/bar.

 

Hi,


thank You for Your suggestions.


@ Russel:


How will a static or global Boolean affect the indicator.


@ valleyfir:


Is it possible to code this into the inidcator. I'll take a look int the forum in this matter.


@ blogzr3


Which EA do you mean. Is there a standard EA where I can implement this into. I do not have a lot of experience in EA Programming, but some things I can do.


Thanks again for the fast help.

 
eduardkiefel:

Hi,


thank You for Your suggestions.


@ Russel:


How will a static or global Boolean affect the indicator.


@ valleyfir:


Is it possible to code this into the inidcator. I'll take a look int the forum in this matter.


@ blogzr3


Which EA do you mean. Is there a standard EA where I can implement this into. I do not have a lot of experience in EA Programming, but some things I can do.


Thanks again for the fast help.



generally, i control the generation of signals upon the start of a new bar. It could be verified like this:



if(Time[0]==TimeCurrent()){

//a new bar started, check indicators.

}



Hope this helps.

 
dguilhon:

generally, i control the generation of signals upon the start of a new bar. It could be verified like this:



if(Time[0]==TimeCurrent()){

//a new bar started, check indicators.

}



Hope this helps.

I use Bars, something like



int CurrentBar = 0;



int start(){

int ThisBar = Bars();

if(ThisBar != CurrentBar)

{

CurrentBar = ThisBar;

RunMyIndicator();

}

}

Reason: