помогите мне с кодом - страница 3

 
mohsin360:

и, пожалуйста, исправьте его ошибки или дайте мне несколько подсказок.


"mohsin360", компилятор говорит вам, что не так. Почему бы вам не прочитать отчет об ошибке и не проследить за ним.

Если написано, что у вас есть переменная, которая не определена, то определите переменную так, чтобы она не вызывала ошибку.

Если написано, что у вас несбалансированная скобка ")", это означает, что вам нужно проверить, что вы разместили правильное количество левых и правых скобок, и что одна или несколько, возможно, пропущены.

Это простые ошибки для тех, кто уже немного умеет кодировать.

Если вы ничего не знаете о программировании, то, возможно, вам стоит посвятить некоторое время изучению основ программирования, использованию компилятора и исправлению синтаксических ошибок в коде в целом, прежде чем пытаться написать советника или индикатор.

Хорошее место для начала - это "Книга MQL4", прямо здесь, на этом сайте!

В качестве альтернативы можно взять книгу по программированию на C или несколько онлайн-учебников по C для начинающих. Это поможет вам понять основы, а затем вы сможете приступить к работе с MQL4.

 

Да, я прочитал отчет об ошибках, и он содержит первую и вторую ошибки восемь в цифрах b из-за моего кода начала трейлинга, и я узнал, что альпари или мт4 не позволяет минимальный трейлинг в 30 пунктов, поэтому я решил немного изменить код и использовать прямой код модификации ордера вместо кода начала трейлинга. спасибо всем за сотрудничество со мной. не расслабляйтесь, я спрошу снова, если мне понадобится помощь после внесения и компиляции новых изменений.

С уважением,

Mohsin.meo

 
Еще раз спасибо .
 

мой мета редактор показывает несколько ошибок первая из них (145,51) когда я ищу в списке ошибок я нахожу ошибку 145, говорящую что :[Модификация отклонена потому что ордер слишком близок к рынку.] и это правда, потому что в этой строке я ввел код для модификации ордера в плюс всего на 5 пунктов, но когда я ищу другие ошибки, такие как (153,62),(158,8),(164,8),(170,55),(180,60) и (185,8), я не могу найти ни одной ошибки из списка, вот список, где я нашел значение одних и не смог найти другие.Пожалуйста, кто-нибудь может сказать мне, что означают эти ошибки и где я могу найти их значение, потому что я искал "неожиданный токен" и обнаружил, что он появляется только тогда, когда есть какая-то проблема с синтаксисом кода, но как вы можете видеть, у меня есть две ошибки в верхней части, скажем, неправильное количество параметров @(145,51) и (153,62), и только 145 перечислены в индексе, но 153,62 не 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);
  }
вот код
 
mohsin360:

мой мета редактор показывает несколько ошибок первая из них (145,51) когда я ищу в списке ошибок я нахожу ошибку 145, говорящую что :[Модификация отклонена потому что ордер слишком близок к рынку.] и это правда, потому что в этой строке я ввел код для модификации ордера в плюс всего на 5 пунктов, но когда я ищу другие ошибки, такие как (153,62),(158,8),(164,8),(170,55),(180,60) и (185,8), я не могу найти ни одной ошибки из списка, вот список, где я нашел значение одних и не смог найти другие.Пожалуйста, кто-нибудь может сказать мне, что означают эти ошибки и где я могу найти их значение, потому что я искал "unexpected token" и обнаружил, что он появляется только тогда, когда есть какая-то проблема с синтаксисом кода, но, как вы можете видеть, у меня есть две ошибки сверху, скажем, неправильное количество параметров @(145,51) и (153,62), и только 145 перечислены в индексе, но 153,62 не Y.

145 - это номер строки, а не номер ошибки... 51 - это номер символьного столбца. Это ошибки кодирования, а не выполнения... исправьте скобки.

Это неправильно...

buy_selection = OrderSelect(  "Buy_ticket",   SELECT_BY_TICKET);

OrderSelect() первый параметр должен быть int, а не строкой, читайте документацию.

То же самое . . .

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


Они струнные и не будут работать. ...

 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
 

Я уже объявил Buy_ticket как intiger, содержащий значение билета, полученного с сервера @ ordersend Buy и то же самое для sell.

Если вы говорите, что первый параметр orderelect должен быть в числах, то как я получил no, очевидно, что я сначала сохранил его в intiger, а затем вызвал этот intiger и вот что я делаю.

?

 
mohsin360:

Я уже объявил Buy_ticket как intiger, содержащий значение билета, полученного с сервера @ ordersend Buy и то же самое для sell.

Если вы говорите, что первый параметр orderelect должен быть в числах, то как я получил no, очевидно, что я сначала сохранил его в intiger, а затем вызвал этот intiger и вот что я делаю.

?

Это целое число...

int Buy_ticket;

Buy_ticket = 10;

это строка

"Buy_ticket"
 

если вы говорите о ""?

Я удалил их и метаэдитор спрашивает о предопределенных переменных, показывая ошибку переменная не определена

купить_билет

продать_билет

Теперь я исправил эти двойные запятые и имею только две ошибки

вот код

//+------------------------------------------------------------------+
//|                                                 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:

если вы говорите о ""?

Я удалил их и метаэдитор спрашивает о предопределенных переменных, показывая ошибку переменная не определена

купить_билет

продать_билет

Теперь я исправил эти двойные запятые и имею только две ошибки

вот код


buy_ticket не то же самое, что Buy_ticket

У вас еще много других ошибок ...

OrderModify() (пожалуйста, прочитайте документацию) принимает как минимум 5 параметров. ...

OrderModify(buy_ticket, buy_open_price, slbuy);

... не три. цвет необязателен ...

что еще?

       else{
     
       }
       
Причина обращения: