ayúdame con el código - página 3

 
mohsin360:

y por favor arregle sus errores o déme algunas pistas


"mohsin360", el compilador le está diciendo lo que está mal. ¿Por qué no leer el informe de error y el seguimiento.

Si dice que tienes una variable que no ha sido definida, entonces define la variable para que no cause el error.

Si dice que tienes un paréntesis desequilibrado ")" significa que tienes que comprobar que colocas el número correcto de paréntesis a la izquierda y a la derecha y que probablemente falte uno o más.

Estos son errores simples para alguien que ya sabe codificar un poco.

Si no sabes nada de programación, entonces tal vez deberías dedicar algo de tiempo a aprender primero los fundamentos de la programación y a usar un compilador y corregir los errores de sintaxis del código en general, antes de intentar escribir un EA o un Indicador.

¡Un buen lugar para empezar es el "Libro MQL4", aquí mismo en este sitio!

Alternativamente, tal vez un libro para principiantes en "Programación C" o tal vez algunos tutoriales en línea en "C" para los principiantes. Eso le hará empezar a entender los fundamentos y luego puede proceder con MQL4.

 

Sí, leí el informe de error y contiene el primer y segundo errores ocho en números b coz de mi código de inicio de arrastre y llego a saber que alpari o mt4 no permite un mínimo de arrastre de 30 pips por lo que decidí cambiar el código un poco y el uso de orden recta modificar el código en lugar de código de inicio de arrastre . gracias a todos por co operar conmigo tanto . no seas tan relajado voy a pedir de nuevo si necesito ayuda después de hacer y compilar los nuevos cambios

Saludos

Mohsin.meo

 
Gracias de nuevo WHRoeder
 

mi meta editor muestra algunos errores primero es (145,51) cuando busco en la lista de errores me multa no 145 diciendo que :[Modificación denegada porque orden demasiado cerca del mercado.Y esto es cierto porque en esa línea introduje el código para modificar la orden en más de sólo 5 pips, pero cuando busco otros errores como (153,62), (158,8), (164,8), (170,55), (180,60) y (185,8).Por favor, ¿alguien puede decirme cuál es el significado de los errores y dónde puedo encontrar los significados b coz busqué "token inesperado" y encontrar que sólo viene cuando hay algún problema con la sintaxis del código, pero como u puede ver tengo dos errores en la parte superior dicen parámetros equivocados cuentan @(145,51) y (153,62) y sólo 145 aparece en el índice, pero 153,62 no es Y

 
//+------------------------------------------------------------------+
//|                                                 every tick20.mq4 |
//|                                                    mohsin mewati |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "mohsin mewati"
#property link      ""

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
 
int init()
  {
//----
   int order_open_time_buy =0;//intiger to save buy open Time
   int order_open_time_sell =0;//intiger to save sell open Time
   bool err_close_all_orders =0;//bolean to save get last error for close all opened orders code
   
   bool err_sell=0;
   bool err_buy=0;
   bool err_selection_buy=0;
   bool err_selection_sell=0;
   bool buy_modified=0;
   bool sell_modified=0;
   double mf_buy=0;
   double mf_sell=0;
   int buy_trail=0;
 
   int err_trail_buy=0;
   int err_modify_sell=0;
   int buy_selection=0;
   bool buy_open_price=0;
   int sell_selection=0;
//----
   return(0);
  }

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+

//----
 
  int start()
  {
  
   bool err_buy;
   int buy_ticket;
   bool err_sell;
   int sell_ticket;
   bool err_selection_buy;
   int buy_selection;
   double buy_open_price;
   bool err_selection_sell;
   int sell_selection;
   bool err_mf_buy;
   bool srr_mf_sell;
   bool err_mf_sell;
   bool err_trail_buy;
   bool err_modify_sell;
   bool buy_modified;
   bool err_trail_sell;
   bool err_modify_buy;
   int buy_trail=0;
   int sell_trail=0;
   string buy="open";
   string sell="open";
   int bp=20;
   int sp=20;
   double buy_ans;
   double sell_ans;
   double slbuy;
   double slsell;
   double tp_sell;
   double tp_buy;
   
 
  //coding starts
  
  
  while(err_buy==0){//for loop started to execute a buy Order
  
   buy_ticket=OrderSend("GBPUSD",OP_BUY,1,Ask,3,Ask+20*Point,0,Green); //code to execute a buy (buy order placed without SL but with a TP of 20 pips
  err_buy=GetLastError();//code to check either buy is executed or not?
  
 }//for loop end
  while(err_sell==0){//for loop to place a sell order
    sell_ticket = OrderSend("GBPUSD",OP_SELL,1,Ask,3,Ask-20*Point,0,Red);//code to place a sell ,order placed without SL but with a TP of 20 pips
   err_sell=GetLastError();//code to check either sell is placed or not?
   }//for loop ends
   Alert("buy/sell executed");
   
   //__________________________________________________________________________________________________________________________________
   
   while(err_selection_buy==0){// for loop start to selection of first executed order for further procedure
   buy_selection=OrderSelect("Buy_ticket",SELECT_BY_TICKET);//order select and stored in intiger
   err_selection_buy=GetLastError();//code to check eithet order is selected or not
   }//for loop ends
   
   
   
  buy_open_price=OrderOpenPrice();//taking open price for the first selected order
  buy_ans=buy_open_price;
   
   
   
    while(err_selection_sell==0){// for loop start to selection of second executed order for further procedure
   sell_selection=OrderSelect("Sell_ticket",SELECT_BY_TICKET);//order select and stored in intiger
   err_selection_sell=GetLastError();//code to check eithet order is selected or not
   }//for loop ends
   
   
   
double sell_open_price=OrderOpenPrice();//taking open price for the second selected order
   
 sell_ans=sell_open_price;
   
   
   
   while("buy_trail==0" && "Sell_trail==0"){// while loop started to check if thow of them or one is true
      
      while ("err_mf_buy==0" &&  "err_mf_sell==0"){//while loop start to take price quote every time for buy and sell
        double mf_buy=MarketInfo("GBPUSD",MODE_POINT);//code to store markeet info in integer mf_buy
        err_mf_buy=GetLastError();//code to confirm the previous line of code executed? 
       double mf_sell=MarketInfo("GBPUSD",MODE_POINT);//code to store markeet info in integer mf_sell
        err_mf_sell=GetLastError();//code to confirm the previous line of code executed? 
       }
       
       if (mf_buy==slbuy){
        buy="closed";}
       
       else{
       if( mf_sell==slsell){
     
       sell="closed";}
       else{}
       }
       
       
       if("mf_buy-bp == buy_ans" && "Buy==open"){//if condition to compare if current markeet quote which stored in mf_buy is 20 times greater than the open price of buy Order?
       
       
       while(err_trail_buy==0){//if above condition true for loop started to start trailing on buy order.
       OrderModify(buy_ticket,buy_open_price,slbuy);
             bp="(bp+5)";
        err_trail_buy=GetLastError();//code to confirm the previous line of code executed? 
        }
        
        if(bp>=30){
        tp_sell=0.00005;
        while(err_modify_sell==0){//if buy is in profit for 20 pips and trailing stop started on it i want my sell to modify for take profit for just 5 pips.
       OrderModify(sell_ticket,sell_open_price,slsell,tp_sell);
       err_modify_sell=GetLastError();//code to confirm the previous line of code executed? 
       buy_trail=1;//intiger use to remember that the buy was in profit and all the cooding associated with it was executed there is no need to check .
       }
       }
       else{
     
       }
       
       
       
       else if ("mf_sell+sp"<="Sell_ans" && "Sell"=="open"){//another logical test to check if buy was not in 20 pips if our sell is in 20 pips profit if so then in the next for loop statrted
       
       
       
       
       while(err_trail_sell==0){//for loop start to modify sell for trail
        OrderModify(sell_ticket,sell_open_price,slsell);
       sp="(sp+5)";
       
        err_trail_sell=GetLastError();//code to confirm the previous line of code executed? 
        }
        
        if(sp>=30){
        tp_buy=0.00005;
        
       while(err_modify_buy==0){//if our sell is in 20 pips profit and trailing executed on it while loop start to modify buy for tp for just 5 pips 
         OrderModify(buy_ticket,buy_open_price,slbuy,tp_buy);
          err_modify_buy=GetLastError();//code to confirm the previous line of code executed? 
         sell_trail=1;//intiger use to remember that the sell was in profit and all the cooding associated with it was executed there is no need to check .
         }
       }
       else{
       }
       
       }
       
       
   }

 
   
   
  }
  double ab=AccountBalance();
  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
aquí está el código
 
mohsin360:

mi meta editor muestra algunos errores primero es (145,51) cuando busco en la lista de errores me multa no 145 diciendo que :[Modificación denegada porque orden demasiado cerca del mercado.Y esto es cierto porque en esa línea introduje el código para modificar la orden en más de sólo 5 pips, pero cuando busco otros errores como (153,62), (158,8), (164,8), (170,55), (180,60) y (185,8).Por favor, ¿puede alguien decirme cuál es el significado de los errores y dónde puedo encontrar los significados? porque he buscado "token inesperado" y he encontrado que sólo aparece cuando hay algún problema con la sintaxis del código, pero como puede ver, tengo dos errores en la parte superior que dicen que los parámetros son incorrectos @(145,51) y (153,62) y sólo 145 aparece en el índice, pero 153,62 no es Y

145 es el número de línea no el número de error... 51 es el número de columna de caracteres. Estos son errores de codificación, no de ejecución. . . arregla tus llaves.

Esto es incorrecto . . .

buy_selection = OrderSelect(  "Buy_ticket",   SELECT_BY_TICKET);

OrderSelect() el primer parámetro debe ser un int no una cadena, lea la documentación.

Lo mismo aquí . . .

sell_selection = OrderSelect(   "Sell_ticket",  SELECT_BY_TICKET);//order select and stored in intiger


Estos son de cuerda y no funcionarán. . .

 while "buy_trail==0"   && "Sell_trail==0"    ){// while loop started to check if thow of them or one is true

lo mismo aquí . . .

 while  "err_mf_buy==0" &&  "err_mf_sell==0"   ){//while loop start to take price quote every time for buy and sell
 

Ya he declarado Buy_ticket como un intiger que contiene el valor del ticket recibido del servidor @ ordersend Buy y lo mismo para sell.

si dices que el primer parámetro de orderelect debe estar en números entonces como obtuve el no obviamente primero lo almacené en un intiger y luego llame a ese intiger y eso es lo que estoy haciendo.

?

 
mohsin360:

Ya he declarado Buy_ticket como un intiger que contiene el valor del ticket recibido del servidor @ ordersend Buy y lo mismo para sell.

si dices que el primer parámetro de orderelect debe estar en números entonces como obtuve el no obviamente primero lo almacené en un intiger y luego llame a ese intiger y eso es lo que estoy haciendo.

?

Esto es un entero...

int Buy_ticket;

Buy_ticket = 10;

esto es una cadena

"Buy_ticket"
 

Si lo que dices es ""?

he eliminado estos y el metaeditor pregunta por las variables predefinidas mostrando el error de variable no definida

comprar_boleto

vender_boleto

ahora he arreglado estas comas dobles y solo tengo dos errores

aquí está el código

//+------------------------------------------------------------------+
//|                                                 every tick20.mq4 |
//|                                                    mohsin mewati |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "mohsin mewati"
#property link      ""

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
 
int init()
  {
//----
   int order_open_time_buy =0;//intiger to save buy open Time
   int order_open_time_sell =0;//intiger to save sell open Time
   bool err_close_all_orders =0;//bolean to save get last error for close all opened orders code
   
   bool err_sell=0;
   bool err_buy=0;
   bool err_selection_buy=0;
   bool err_selection_sell=0;
   bool buy_modified=0;
   bool sell_modified=0;
   double mf_buy=0;
   double mf_sell=0;
   int buy_trail=0;
 
   int err_trail_buy=0;
   int err_modify_sell=0;
   int buy_selection=0;
   bool buy_open_price=0;
   int sell_selection=0;
//----
   return(0);
  }

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+

//----
 
  int start()
  {
  
   bool err_buy;
   int buy_ticket;
   bool err_sell;
   int sell_ticket;
   bool err_selection_buy;
   int buy_selection;
   double buy_open_price;
   bool err_selection_sell;
   int sell_selection;
   bool err_mf_buy;
   bool srr_mf_sell;
   bool err_mf_sell;
   bool err_trail_buy;
   bool err_modify_sell;
   bool buy_modified;
   bool err_trail_sell;
   bool err_modify_buy;
   int buy_trail=0;
   int sell_trail=0;
   string buy;
   string sell;
   int bp=20;
   int sp=20;
   double buy_ans;
   double sell_ans;
   double slbuy;
   double slsell;
   double tp_sell;
   double tp_buy;
   
 
  //coding starts
  
  
  while(err_buy==0){//for loop started to execute a buy Order
  
   buy_ticket=OrderSend("GBPUSD",OP_BUY,1,Ask,3,Ask+20*Point,0,Green); //code to execute a buy (buy order placed without SL but with a TP of 20 pips
  err_buy=GetLastError();//code to check either buy is executed or not?
  
 }//for loop end
  while(err_sell==0){//for loop to place a sell order
    sell_ticket = OrderSend("GBPUSD",OP_SELL,1,Ask,3,Ask-20*Point,0,Red);//code to place a sell ,order placed without SL but with a TP of 20 pips
   err_sell=GetLastError();//code to check either sell is placed or not?
   }//for loop ends
   Alert("buy/sell executed");
   
   //__________________________________________________________________________________________________________________________________
   
   while(err_selection_buy==0){// for loop start to selection of first executed order for further procedure
   buy_selection=OrderSelect(Buy_ticket,SELECT_BY_TICKET);//order select and stored in intiger
   err_selection_buy=GetLastError();//code to check eithet order is selected or not
   }//for loop ends
   
   
   
  buy_open_price=OrderOpenPrice();//taking open price for the first selected order
  buy_ans=buy_open_price;
   
   
   
    while(err_selection_sell==0){// for loop start to selection of second executed order for further procedure
   sell_selection=OrderSelect(Sell_ticket,SELECT_BY_TICKET);//order select and stored in intiger
   err_selection_sell=GetLastError();//code to check eithet order is selected or not
   }//for loop ends
   
   
   
double sell_open_price=OrderOpenPrice();//taking open price for the second selected order
   
 sell_ans=sell_open_price;
   
   
   
   while("buy_trail"==0 &&  "Sell_trail"==0){// while loop started to check if thow of them or one is true
      
      while (err_mf_buy==0 &&  err_mf_sell==0){//while loop start to take price quote every time for buy and sell
        double mf_buy=MarketInfo("GBPUSD",MODE_POINT);//code to store markeet info in integer mf_buy
        err_mf_buy=GetLastError();//code to confirm the previous line of code executed? 
       double mf_sell=MarketInfo("GBPUSD",MODE_POINT);//code to store markeet info in integer mf_sell
        err_mf_sell=GetLastError();//code to confirm the previous line of code executed? 
       }
       
       if (mf_buy==slbuy){
        buy="closed";}
       
       else{
       if( mf_sell==slsell){
     
       sell="closed";}
       else{}
       }
       
       
       if(mf_buy-bp == buy_ans && "Buy"=="open"){//if condition to compare if current markeet quote which stored in mf_buy is 20 times greater than the open price of buy Order?
       
       
       while(err_trail_buy==0){//if above condition true for loop started to start trailing on buy order.
       OrderModify(buy_ticket,buy_open_price,slbuy);
             bp="(bp+5)";
        err_trail_buy=GetLastError();//code to confirm the previous line of code executed? 
        }
        
        if(bp>=30){
        tp_sell=0.00005;
        while(err_modify_sell==0){//if buy is in profit for 20 pips and trailing stop started on it i want my sell to modify for take profit for just 5 pips.
       OrderModify(sell_ticket,sell_open_price,slsell,tp_sell);
       err_modify_sell=GetLastError();//code to confirm the previous line of code executed? 
       buy_trail=1;//intiger use to remember that the buy was in profit and all the cooding associated with it was executed there is no need to check .
       }
       }
       else{
     
       }
       
       
       
       else if ("mf_sell"+"sp"<="Sell_ans" && "Sell"=="open"){//another logical test to check if buy was not in 20 pips if our sell is in 20 pips profit if so then in the next for loop statrted
       
       
       
       
       while(err_trail_sell==0){//for loop start to modify sell for trail
        OrderModify(sell_ticket,sell_open_price,slsell);
       sp="(sp+5)";
       
        err_trail_sell=GetLastError();//code to confirm the previous line of code executed? 
        }
        
        if(sp>=30){
        tp_buy=0.00005;
        
       while(err_modify_buy==0){//if our sell is in 20 pips profit and trailing executed on it while loop start to modify buy for tp for just 5 pips 
         OrderModify(buy_ticket,buy_open_price,slbuy,tp_buy);
          err_modify_buy=GetLastError();//code to confirm the previous line of code executed? 
         sell_trail=1;//intiger use to remember that the sell was in profit and all the cooding associated with it was executed there is no need to check .
         }
       }
       else{
       }
       
       }
       
       
   }

 
   
   
  }
  double ab=AccountBalance();
  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
 
mohsin360:

Si lo que dices es ""?

he eliminado estos y el metaeditor pregunta por las variables predefinidas mostrando el error de variable no definida

comprar_boleto

vender_boleto

ahora he arreglado estas comas dobles y solo tengo dos errores

aquí está el código


buy_ticket no es lo mismo que Buy_ticket

Todavía tiene muchos otros errores. . .

OrderModify() (por favor, lea la documentación) toma al menos 5 parámetros .

OrderModify(buy_ticket, buy_open_price, slbuy);

. . . no tres. el color es opcional . . .

¿si no qué?

       else{
     
       }
       
Razón de la queja: