Download MetaTrader 5
To add comments, please log in or register
MQL5 Cloud Network speeds up calculations. Try it!
Fa Cao
1143
Fa Cao 2013.11.28 03:41 

The codes are as below:

I just want to send an order to buy and then set a proper stopline for this order; but I find when this EA is executed, the stopline is up and down continually, so which bug cause this?

int counted=0;

int Move_Stop_Small=30,Move_Stop_Big=100;
double Get_High,Get_Low;
bool Stop_Big=false;

int start()
  {
  if(counted<1)  { counted++;OrderSend(Symbol(),OP_BUY,1,Ask,3,0,0,0,0,0,0);   }
  Move_Stop_Loss();
  return(0);
  }
  
 void Move_Stop_Loss()
{
  int i=OrdersTotal();
  if(i==0) {Stop_Big=false; return(0);}
  else
  while(i>=0)
  {
   if(OrderSelect(i-1,SELECT_BY_POS,MODE_TRADES))
   if(OrderType()==OP_BUY&&Close[0]-OrderStopLoss()>(Move_Stop_Small+5)*Point) 
   {
     if(OrderProfit()<=200*Point&&Stop_Big==false)OrderModify(OrderTicket(),OrderOpenPrice(),Close[0]-Move_Stop_Small*Point,0,0,0);
     else if(OrderModify(OrderTicket(),OrderOpenPrice(),Close[0]-Move_Stop_Big*Point,0,0,0)) Stop_Big=True;    
   } 
   i--;
  }
  return(0);
}
Fa Cao
1143
Fa Cao 2013.11.28 03:54  

Ok

I know I have get this bug.

Ian Flanagan
549
Ian Flanagan 2013.11.28 05:05  
You need to check your code and search google before posting. These days you start so many threads that you didn't need to.
Fa Cao
1143
Fa Cao 2013.11.28 05:22  
alladir:
You need to check your code and search google before posting. These days you start so many threads that you didn't need to.


Sorry if give you any trouble and thanks for your suggestion.

I post any thread just because I can't resolve it by other method.

whroeder1
13610
whroeder1 2013.11.28 13:21  
vx0532: but I find when this EA is executed, the stopline is up and down continually, so which bug cause this?
rderModify(OrderTicket(),OrderOpenPrice(),Close[0]-Move_Stop_Big*Point,0,0,0)

Which is exactly what you programmed. Close[0] moves up and down continually so so does your stop.
/
To add comments, please log in or register