Hi guys/&gals,
Having a massive problem with my EA, instead of just opening 2 trades with the same magic number and then closing those ones at a set profit target my EA goes nuts and just continually opens the same trade over and over again until I turn off auto trading, I have tried everything and it just wont stop, HELLLP,
Im pretty sure this is the part of code that is doing the damage
lol, please tell me this is a <deleted>-post
Hi guys/&gals,
Having a massive problem with my EA, instead of just opening 2 trades with the same magic number and then closing those ones at a set profit target my EA goes nuts and just continually opens the same trade over and over again until I turn off auto trading, I have tried everything and it just wont stop, HELLLP,
Im pretty sure this is the part of code that is doing the damage
I solved a problem like this before , check my solution
if(//Buy Conditions){ if(totalSells(mNum)>0){//Close Sell CloseSell(mNum); } if(totalBuys(mNum)==0){ Buy(lots,mNum); } } if(// Sell Conditions){ if(totalBuys(mNum)>0){//Close Buy CloseBuy(mNum); } if(totalSells(mNum)==0){ Sell(lots,mNum); } }
and this is the functions
//+------------------------------------------------------------------+ void Buy(double lot, int magic){ if(OrderSend(Symbol(),OP_BUY,lot,Ask,3,0,0,magic,magic,0,clrNONE)){ Print(Symbol()+" Buy @ "+Ask); }else{Print("Buy Open ERROR"); } } //+------------------------------------------------------------------+ void Sell(double lot, int magic){ if(OrderSend(Symbol(),OP_SELL,lot,Bid,3,0,0,magic,magic,0,clrNONE)){ Print(Symbol()+" Sell @ "+Bid); }else{Print("Sell Open ERROR"); } } //+------------------------------------------------------------------+ void CloseBuy(int magic){ for (int h = OrdersTotal()-1; h>=0; h--){ if(OrderSelect(h, SELECT_BY_POS,MODE_TRADES)) if(OrderMagicNumber()==magic) if(OrderSymbol()==Symbol()) if(OrderType()==OP_BUY) if(OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,clrNONE)){ Print(OrderTicket()+" "+Symbol()+" Buy Closed @ "+OrderClosePrice()); }else{ Print("Buy Close Error"); } }} //+------------------------------------------------------------------+ void CloseSell(int magic){ for (int h = OrdersTotal()-1; h>=0; h--){ if(OrderSelect(h, SELECT_BY_POS,MODE_TRADES)) if(OrderMagicNumber()==magic) if(OrderSymbol()==Symbol()) if(OrderType()==OP_SELL) if(OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,clrNONE)){ Print(OrderTicket()+" "+Symbol()+" Sell Closed @ "+OrderClosePrice()); }else{ Print("Sell Close Error"); } }} //+------------------------------------------------------------------+

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys/&gals,
Having a massive problem with my EA, instead of just opening 2 trades with the same magic number and then closing those ones at a set profit target my EA goes nuts and just continually opens the same trade over and over again until I turn off auto trading, I have tried everything and it just wont stop, HELLLP,
Im pretty sure this is the part of code that is doing the damage