Questions from Beginners MQL5 MT5 MetaTrader 5 - page 509

 
Aleksey Stukalov:
What's wrong with a trailing stop? It's already built into the terminal.
Try it and you will understand
 

Kind people help with compiling EA very please, I'm not good at programming.

This is the error I get when compiling 'delete' - name expected

The error in the code is highlighted in red

void delete(int type){

if(OrdersTotal()>0){

for(i=OrdersTotal()-1;i>=0;i--){

OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

if(type!=6 && type!=7 && type!=8)if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==type)OrderDelete(OrderTicket();

if(type==6)if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP || OrderType()==OP_BUYLIMIT || OrderType()==OP_SELLLIMIT)OrderDelete(OrderTicket());

if(type==7)if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_BUYSTOP || OrderType()==OP_BUYLIMIT)OrderDelete(OrderTicket());

if(type==8)if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_SELLSTOP || OrderType()==OP_SELLLIMIT)OrderDelete(OrderTicket());

}

}

}


Here's another error '(' - object pointer expected

if(oppositedelete){delete(OP_SELLSTOP);delete(OP_SELLLIMIT);}

And here '}' - not all control paths return a value

int countglobal(){

int cnt=0;

if(OrdersTotal()>0){

for(i=OrdersTotal()-1;i>=0;i--){

OrderSelect(i,SELECT_BY_POS,MODE_TRADES);

cnt++;

}

return(cnt);

}

}

 
Anton Razmyslov:

Kind people help with compiling EA very please, I'm not good at programming.

This is the error I get when compiling 'delete' - name expected

The error in the code is highlighted in red

void delete(int type){.

..............

It says it cannot be called that way. You should call the function by some other name.

and this "not all control paths return a value" about the function having no return path and returning no value, write return(0); before the last "}" of the function

 
Спасибо большое!
 
Tema97:
Good afternoon to all) Share the code for a mobile stop loss - to drive the price )))) Thanks in advance
//---------------------------------
void Trailing3(int Mag,string Symb,int Dist,int Shag,bool Isp_shag,bool Isp_bezubitok)
  {
   double dist=0,shag;
   if(Digits==3 || Digits==5)
      dist=Dist*10*Point; shag=Shag*10*Point;
   if(Digits==2 || Digits==4)
      dist=Dist*Point; shag=Shag*Point;

   for(int pos=OrdersTotal()-1; pos>=0; pos--)
     {
      int res=OrderSelect(pos,SELECT_BY_POS,MODE_TRADES);
      if(OrderMagicNumber()==Mag && OrderSymbol()==Symb)
        {
         if(OrderType()==OP_BUY)
           {
            if(!Isp_shag && !Isp_bezubitok && NormalizeDouble(Bid-OrderStopLoss(),Digits)>NormalizeDouble(dist,Digits))
               OrderModifyX3(OrderTicket(),0,Bid-dist,OrderTakeProfit(),0,clrTeal);
            if(Isp_shag && !Isp_bezubitok && NormalizeDouble(Bid-OrderOpenPrice(),Digits)>=NormalizeDouble(shag,Digits) && 
               NormalizeDouble(Bid-OrderStopLoss(),Digits)>NormalizeDouble(dist,Digits))
               OrderModifyX3(OrderTicket(),0,Bid-dist,OrderTakeProfit(),0,clrTeal);
            if(!Isp_shag && Isp_bezubitok && NormalizeDouble(OrderStopLoss(),Digits)<NormalizeDouble(OrderOpenPrice(),Digits) && 
               NormalizeDouble(Bid-OrderStopLoss(),Digits)>NormalizeDouble(dist,Digits))
               OrderModifyX3(OrderTicket(),0,Bid-dist,OrderTakeProfit(),0,clrTeal);
            if(Isp_shag && Isp_bezubitok && NormalizeDouble(Bid-OrderOpenPrice(),Digits)>=NormalizeDouble(shag,Digits) && 
               NormalizeDouble(OrderStopLoss(),Digits)<NormalizeDouble(OrderOpenPrice(),Digits) && NormalizeDouble(Bid-OrderStopLoss(),Digits)>NormalizeDouble(dist,Digits))
               OrderModifyX3(OrderTicket(),0,Bid-dist,OrderTakeProfit(),0,clrTeal);
           }
         else  if(OrderType()==OP_SELL)
           {
            if(!Isp_shag && !Isp_bezubitok && NormalizeDouble(OrderStopLoss()-Ask,Digits)>NormalizeDouble(dist,Digits))
               OrderModifyX3(OrderTicket(),0,Ask+dist,OrderTakeProfit(),0,clrCrimson);
            if(Isp_shag && !Isp_bezubitok && NormalizeDouble(OrderOpenPrice()-Ask,Digits)>=NormalizeDouble(shag,Digits) && 
               NormalizeDouble(OrderStopLoss()-Ask,Digits)>NormalizeDouble(dist,Digits))
               OrderModifyX3(OrderTicket(),0,Ask+dist,OrderTakeProfit(),0,clrCrimson);
            if(!Isp_shag && Isp_bezubitok && NormalizeDouble(OrderStopLoss(),Digits)>NormalizeDouble(OrderOpenPrice(),Digits) && 
               NormalizeDouble(OrderStopLoss()-Ask,Digits)>NormalizeDouble(dist,Digits))
               OrderModifyX3(OrderTicket(),0,Ask+dist,OrderTakeProfit(),0,clrCrimson);
            if(Isp_shag && Isp_bezubitok && NormalizeDouble(OrderOpenPrice()-Ask,Digits)>=NormalizeDouble(shag,Digits) && 
               NormalizeDouble(OrderStopLoss(),Digits)>NormalizeDouble(OrderOpenPrice(),Digits) && NormalizeDouble(OrderStopLoss()-Ask,Digits)>NormalizeDouble(dist,Digits))
               OrderModifyX3(OrderTicket(),0,Ask+dist,OrderTakeProfit(),0,clrCrimson);
           }
        }
     }

  }
//-----------------------------------------------
 
Hi all! Downloaded MT4, strategy tester has only been working since December 2015, who knows how to pimp the terminal?
 
olleg.1:
Hi all! Downloaded MT4, strategy tester has only been working since December 2015, who knows how to patch the terminal?
Download quotes for the required instrument. Service - Quote Archive.
 
Thank you!
 

Hello, everyone!

Could you please tell me how to implement in EA the possibility to check if input variable is in range or not. For example:

a) More than 10, but less than 20

b) More than 20 or less than 10

c) etc.

ZS: so far we have 3 values to check each variable: case for switch (greater than/less than/more than, but less than/less than or greater than) and 2 values. I guess you could loop this construction and go through all the variables... Is this the right direction?

 
Антон:

Hello, everyone!

Could you please tell me how to implement in EA the possibility to check if input variable is in range or not, in a simpler and more correct way. For example:

a) More than 10, but less than 20

b) More than 20 or less than 10

c) etc.

ZS: so far we have 3 values to check each variable: case for switch (greater than/less than/more than, but less than/less than or greater than) and 2 values. I guess you could loop this construction and go through all the variables... Is this the right direction?

Which variables to loop? Give me the code or write it more clearly