ajude-me com o código - página 3

 
mohsin360:

e, por favor, corrija seus erros ou me dê algumas dicas


"mohsin360", o compilador está lhe dizendo o que está errado. Por que você não lê o relatório de erro e o acompanhamento.

Se disser, que você tem uma variável que não foi definida, então defina a variável para que ela não cause o erro.

Se ela disser que você tem um parêntese de desequilíbrio ")" isso significa que você tem que verificar se você coloca o número correto de parênteses esquerdo e direito e que provavelmente falta um ou mais.

Estes são erros simples para alguém que já sabe como codificar um pouco.

Se você não sabe nada sobre programação, então talvez devesse dedicar algum tempo para primeiro aprender o básico da programação e usar um compilador e corrigir os erros de sintaxe no código em geral, antes de tentar escrever um EA ou Indicador.

Um bom lugar para começar é o "MQL4 Book", aqui mesmo neste site!

Alternativamente, talvez um livro para iniciantes em "Programação C" ou talvez alguns tutoriais on-line em "C" para iniciantes. Isso começará para você entender o básico e então você poderá prosseguir com a MQL4.

 

sim li o relatório de erro e ele contém o primeiro e o segundo erros oito em números b coz do meu código de início de rastreamento e cheguei a saber que alpari ou mt4 não permite um rastreamento mínimo de 30 pips então decidi mudar um pouco o código e usar código de modificação de ordem direta em vez de código de início de rastreamento. obrigado a todos por cooperarem tanto comigo. não fique tão relaxado pergunte novamente se preciso de ajuda depois de fazer e compilar as novas mudanças

Cumprimentos

Mohsin.meo

 
Mais uma vez obrigado WHRoeder
 

meu meta editor mostra alguns erros primeiro é (145,51) quando eu procuro na lista de erros eu multo no 145 dizendo que :[Modificação negada porque ordem muito próxima do mercado.O que é verdade é que, naquela linha, eu digito código para modificar a ordem em mais 5 pips, mas quando procuro outros erros como (153,62), (158,8), (164,8), (170,55), (180,60) e (185,8), não posso multar qualquer erro que não esteja listado na lista aqui é a lista onde eu multo os que significam e não encontrei outros.por favor, qualquer um pode me dizer qual é o significado dos erros e onde posso encontrar significados b porque procurei "ficha inesperada" e descobri que eu só venho quando há algum problema com a sintaxe do código, mas como você pode ver eu tenho dois erros no topo dizem que os parâmetros errados contam @(145,51) e (153,62) e apenas 145 listados no índice, mas 153,62 não é 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);
  }
aqui está o código
 
mohsin360:

meu meta editor mostra alguns erros primeiro é (145,51) quando eu procuro na lista de erros eu multo no 145 dizendo que :[Modificação negada porque ordem muito próxima do mercado.O que é verdade é que, naquela linha, eu digito código para modificar a ordem em mais 5 pips, mas quando procuro outros erros como (153,62), (158,8), (164,8), (170,55), (180,60) e (185,8), não posso multar qualquer erro que não esteja listado na lista aqui é a lista onde eu multo os que significam e não encontrei outros.por favor, qualquer um pode me dizer qual é o significado dos erros e onde posso encontrar significados b porque procurei "ficha inesperada" e descobri que eu só venho quando há algum problema com a sintaxe do código, mas como você pode ver eu tenho dois erros no topo dizem que os parâmetros errados contam @(145,51) e (153,62) e apenas 145 listados no índice, mas 153,62 não é Y

145 é o número da linha e não o número do erro . . 51 é o número da coluna de caracteres. Estes são erros de codificação e não erros de execução . . . corrija seus aparelhos.

Isto está errado . .

buy_selection = OrderSelect(  "Buy_ticket",   SELECT_BY_TICKET);

OrderSelect() o primeiro parâmetro deve ser uma int e não uma string, leia a documentação.

O mesmo aqui . . .

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


Estas são cordas e não funcionarão . .

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

o mesmo aqui . . .

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

já declarei Buy_ticket como intiger contendo o valor do ticket recebido do servidor @ orderend Buy e o mesmo para venda.

se você diz que o primeiro parâmetro de seleção de pedidos deve ser em números, então como eu consegui o "não" obviamente eu o armazenei primeiro em um intiger e depois chamei esse intiger e o que estou fazendo.

?

 
mohsin360:

já declarei Buy_ticket como intiger contendo o valor do ticket recebido do servidor @ orderend Buy e o mesmo para venda.

se você diz que o primeiro parâmetro de seleção de pedidos deve ser em números, então como eu consegui o "não" obviamente eu o armazenei primeiro em um intiger e depois chamei esse intiger e o que estou fazendo.

?

Este é um número inteiro . .

int Buy_ticket;

Buy_ticket = 10;

isto é uma seqüência

"Buy_ticket"
 

se você estiver com dúvidas "" ?

eu as removi e o metaeditor perguntou a uma variável de erro pré-definida que mostrava uma variável de erro não definida

buy_ticket

sell_ticket

agora eu conserto estas vírgulas duplas e tendo apenas dois erros

aqui está o 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:

se você estiver com dúvidas "" ?

eu as removi e o metaeditor perguntou a uma variável de erro pré-definida que mostrava uma variável de erro não definida

buy_ticket

sell_ticket

agora eu conserto estas vírgulas duplas e tendo apenas dois erros

aqui está o código


buy_ticket não é o mesmo que Buy_ticket

Você ainda tem muitos outros erros . . .

OrderModify() (favor ler a documentação) leva pelo menos 5 parâmetros . .

OrderModify(buy_ticket, buy_open_price, slbuy);

. não três. a cor é opcional . .

mais o que ?

       else{
     
       }