帮我写一下代码 - 页 3

 
mohsin360:

并请修复它的错误或给我一些提示


"mohsin360",编译器正在告诉你哪里出了问题。你为什么不阅读错误报告并跟进。

如果它说你有一个没有定义的变量,那么就定义这个变量,使它不会引起错误。

如果它说你有一个不平衡的小括号")",这意味着你必须检查你是否放置了正确数量的左右小括号,可能缺少一个或多个。

对于已经知道如何编码的人来说,这些是简单的错误。

如果你对编程一无所知,那么在尝试编写EA或指标之前,也许你应该拿出一些时间,首先学习编程的基础知识,使用编译器,纠正代码中的一般语法错误。

一个好的开始是"MQL4书",就在这个网站上。

另外,也可以选择一本关于 "C语言编程 "的初级书籍,或者为初学者提供一些关于 "C语言 "的在线教程。这将使您开始了解基础知识,然后您可以继续使用MQL4。

 

是的,我读了错误报告,它包含了第一个和第二个错误,数字为8,因为我的追踪启动代码,我知道阿尔帕里或MT4不允许最低追踪30点,所以我决定改变代码一点点,使用直接订单修改代码,而不是追踪启动代码.谢谢大家与我合作这么多。

尊敬的各位领导

莫辛.梅奥

 
再次感谢WHRoeder
 

我的元编辑器显示了一些错误,第一个是(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).我无法找到列表中的任何错误号码,这是列表中我找到的意思,未能找到其他。谁能告诉我这些错误的含义是什么,以及我在哪里可以找到含义,因为我搜索了 "意外标记",发现只有在代码语法有问题时才会出现,但正如你所看到的,我在顶部有两个错误,说错误的参数计数@(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也是如此。

如果你说orderselect的第一个参数 必须是数字,那么我是如何得到这个数字的,显然我首先把它存储在一个intiger中,然后调用这个intiger,这就是我所做的。

?

 
mohsin360:

我已经把Buy_ticket声明为intiger,其中包含了从服务器上收到的票据值,在ordersend Buy和sell也是如此。

如果你说orderselect的第一个参数必须是数字,那么我是如何得到这个数字的,显然我首先把它存储在一个intiger中,然后调用这个intiger,这就是我所做的。

?

这是一个整数......。

int Buy_ticket;

Buy_ticket = 10;

这是一个字符串

"Buy_ticket"
 

如果你说的是""?

删除了 这些,元编辑器询问预定义的变量,显示错误的变量未定义。

买票

sell_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:

如果你说的是""?

我删除了这些,元编辑器询问预定义的变量,显示错误的变量没有定义。

买票

sell_ticket

现在我修改了这些双逗号,只出现了两个错误。

以下是代码


buy_ticket Buy_ticket 不一样

你还有很多其他错误 . .

OrderModify()(请阅读文档)至少需要5个参数 ... .

OrderModify(buy_ticket, buy_open_price, slbuy);

...不是三个。颜色是可选的。

还有什么?

       else{
     
       }