How to Stop Consecutive Loss Orders

 

Hi,

I created my own EA but I wanted to know if there was a way to code the EA, so it there are 2 losses in a row it will not trade to trade in the same direction again until an oppsite order is executed. For instance my EA gives a sell signal & it gets stopped out. The EA will Open the Sell signal again if all my conditions are met. So sometimes I'm getting 3 or 4 losses in a row. Is there a code that will let the EA know that once it has 2 losses in a row not to keep trading in that direction. So what i want it to do is say I have 2 sell orders and their both losses,don't take any sell orders until a buy order is received. Then sell orders can be taken agian.

Thanks

 

here's my 2 cents:



1. have a loss count for both trade directions:

#define LOSSCOUNTTHRESHOLD 2
uint losscountbuy = 0;
uint losscountsell = 0;

2. trade according to signal if respective loss count not exceeded threshold value:

if((losscountbuy < LOSSCOUNTTHRESHOLD) && buysignal) buy();
else if((losscountsell < LOSSCOUNTTHRESHOLD) && sellsignal) sell();

3. whenever a trade ends in a loss, increase loss count in the respective direction:

4. on every new trade set opposite loss count to zero (in the respective trade function):

// in buy() function
losscountsell = 0;

// in sell() function
losscountbuy = 0;
 
cpickens: Is there a code that ...
Not unless you create it. learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.