EA error that places multiple trades

 

Hi guys,


I have an annoying error that causes my EA to place multiple (sometimes as many as 100) trades and then close them straight away because the fast moving average that I use as a close signal has not yet caught up with the price and fallen below the buy signal. So essentially both conditions are true at the same time (enter buy / exit buy). This is what the chart looks like.

Its responding to an if statement that states if 5 bars close above the green line open a buy order and also another if statement that states if two bars close below the red line close the buy order. I'd like to avoid changing the positions of the MA lines, and also I'd like to avoid making the triggers any more or less sensitive. Can anybody suggest anything that I could do to prevent this?

 
DrBeardface:

Hi guys,


I have an annoying error that causes my EA to place multiple (sometimes as many as 100) trades and then close them straight away because the fast moving average that I use as a close signal has not yet caught up with the price and fallen below the buy signal. So essentially both conditions are true at the same time (enter buy / exit buy). This is what the chart looks like.

Its responding to an if statement that states if 5 bars close above the green line open a buy order and also another if statement that states if two bars close below the red line close the buy order. I'd like to avoid changing the positions of the MA lines, and also I'd like to avoid making the triggers any more or less sensitive. Can anybody suggest anything that I could do to prevent this?

That is not an issue of the average

That is an issue of the code managing orders

If you want to avoid the change of the current average value, the simplest is to :

  • use open price for average
  • use the average value on the first closed bar
 
So by changing the average or changing the sensitivity of the trigger? I actually fixed it by adding in a condition that the Exit signal must be below the Entry signal at the point of entry, which fingers crossed should stop the problem. I don't know why it didn't occur to me straight away. Only trouble is that it might skip a profitable trade entry. But I might just have to live with that.
Reason: