how to open multiple trades.
Search in the codebase for some MT4 Stochastic EA and study it. Your EA needs at least a Magic number (unique identifier) to count the number of open orders correctly.
If you want to limit the number of open trades, test against a maximum value like MaxBuys or so:
input int InpMaxBuys=1; // max open buy orders
and
if(k0 > d0 && k1 < d1 && MyOpenBuys<InpMaxBuys)
If you want to have a difference of X pips between the orders you need to find the open order which is nearest to the Ask.
You can combine it with the loop that counts your open orders.
int MyOpenBuys(double &nearest) { int count=0; nearest=999999; for(int i=OrdersTotal()-1; i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS) && OrderSymbol()==_Symbol && OrderMagicNumber()==MagicID) { if(OrderType()==OP_BUY) { count++; if(MathAbs(OrderOpenPrice()-Ask)<MathAbs(nearest-Ask)) nearest=OrderOpenPrice(); } } } return count; }
and
double nearestBuy; if(k0 > d0 && k1 < d1 && MyOpenBuys(nearestBuy)<InpMaxBuys && Ask-nearestBuy>=distance*RealPipPoint(_Symbol))
That's Work Thankx Mate
Appreciated
Appreciated
hello there i am facing some problem
my expert adviser are opening infinite trade till the margin become zero .
i used OrderTotal== 0 but i want to open multiple trades with the difference of 100 pip
example :
if my condition become true EA should open buy trade
but if condition become true again EA should open 2 buy trade .
what should i do ??