EA opening system
Depends on what you want exactly. In general your EA has to keep track what kind
of a trade last time it opened.
int lastTrade = -1; ... // signal decides it is to BUY, then: if( lastTrade != OP_BUY ) { // do send the buy order lastTrade = OP_BUY; } ... // signal decides it is to SELL, then: if( lastTrade != OP_SELL ) { // do send the sell order lastTrade = OP_SELL; }
To clarify the case, I am talking about ASCTrend EA with the following script for
buy and sell:
if (!ExistPositions()){//2 if (PS){//3 OpenSell(); return(0); }//3 if (PB){//3 OpenBuy(); return(0); }//3 }//2 if (ExistPositions()){//2 if(OrderType()==OP_BUY){//3 if(EnableCloseByASCTrend){//4 if (PS){//5 CloseBuy(); return(0); }//5 }//4 }//3 if(OrderType()==OP_SELL){//3 if(EnableCloseByASCTrend){//4 if (PB){//5 CloseSell(); return(0); }//5 }//4 }//3
When I manually close a trade opened by EA, EA will open another trade since the signal is still in the same direction.
How can I lead EA to open only one trade after each signal change ?