코드를 도와주세요 - 페이지 4

 
mohsin360 :
         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 .

귀하의 책은 한 열이지만 너비는 2피트입니까? 읽을 수 없기 때문입니다. 그것들은 6인치이고 때로는 2열이므로 쉽게 읽을 수 있습니다. 귀하의 코드도 마찬가지여야 합니다. 나는 그것을 읽으려고 앞뒤로 스크롤하지 않을 것입니다. 형식이 지정된 코드 로 게시물을 수정하면 추가 도움을 받을 수 있습니다.
 

오 죄송합니다만 설명을 추가 하여 설명을 제거합니다.

 

여기 코드가 있습니다

 //+------------------------------------------------------------------+
//|                                                 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;
   int i= 1 ;
 double tpbuy;
 double tpsell;
 
   //coding starts
  
  
   while (err_buy== 0 ){
  
   buy_ticket= OrderSend ( "GBPUSD" , OP_BUY , 1 , Ask , 3 , Ask + 20 * Point , 0 ,Green);
  err_buy=GetLastError();  
 }
   while (err_sell== 0 ){
    sell_ticket = OrderSend ( "GBPUSD" , OP_SELL , 1 , Ask , 3 , Ask - 20 * Point , 0 ,Red);
   err_sell=GetLastError();
   }
   Alert ( "buy/sell executed" );
   
      
   while (err_selection_buy== 0 ){
   buy_selection= OrderSelect (buy_ticket, SELECT_BY_TICKET );
   err_selection_buy=GetLastError();
   }
   
   
   
  buy_open_price= OrderOpenPrice ();
  buy_ans=buy_open_price;
   tpbuy=buy_ans+ 0.00050 ;
   
   
     while (err_selection_sell== 0 ){
   sell_selection= OrderSelect (sell_ticket, SELECT_BY_TICKET );
   err_selection_sell=GetLastError();
   }
   
   
   
double sell_open_price= OrderOpenPrice ();
   
 sell_ans=sell_open_price;
   tpsell=sell_ans- 0.00050 ;
   
   
   while ( "buy_trail" == "0" &&   "Sell_trail" == "0" ){
      
       while (err_mf_buy== "0" &&  err_mf_sell== "0" ){
         double mf_buy= MarketInfo ( "GBPUSD" , MODE_POINT );
        err_mf_buy=GetLastError();
       double mf_sell= MarketInfo ( "GBPUSD" , MODE_POINT );
        err_mf_sell=GetLastError();
       }
       
       if (mf_buy==slbuy){
        buy= "closed" ;}
       
       else {
       if ( mf_sell==slsell){
     
       sell= "closed" ;}
       else {
       i++;
       }
       }
       
       
       if (mf_buy-bp == buy_ans && "Buy" == "open" ){
       
       
       while (err_trail_buy== 0 ){
       OrderModify (buy_ticket,buy_open_price,slbuy,tpbuy, 0 ,Blue);
             bp= "(bp+5)" ;
        err_trail_buy=GetLastError();
        }
        
         if (bp>= 30 ){
        tp_sell= 0.00005 ;
         while (err_modify_sell== 0 ){
       OrderModify (sell_ticket,sell_open_price,slsell,tpsell, 0 ,Red);
       err_modify_sell=GetLastError(); 
       buy_trail= 1 ;
       }
       }
       else {
     i++;
       }
       
       
       
         if ( "mf_sell" + "sp" <= "Sell_ans" && "Sell" == "open" ){
       
       
       
       
       while (err_trail_sell== 0 ){
         OrderModify (sell_ticket,sell_open_price,slsell,tpsell, 0 ,Red);
       sp= "(sp+5)" ;
       
        err_trail_sell=GetLastError(); 
        }
        
         if (sp>= 30 ){
        tp_buy= 0.00005 ;
        
       while (err_modify_buy== 0 ){ 
         OrderModify (buy_ticket,buy_open_price,slbuy,tpbuy, 0 ,Blue);
          err_modify_buy=GetLastError(); 
         sell_trail= 1 ;
         }
       }
       else {
       i++;
       }
       
       }
       
       
   }

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

그리고 나는 또한 약간의 수정을했고 '=='비교 @125,24에서 다른 유형의 오류가 하나만 발생했습니다.

 
mohsin360 :

여기 코드가 있습니다

그리고 나는 또한 약간의 수정을했고 '=='비교 @125,24에서 다른 유형의 오류가 하나만 발생했습니다.

문자열이 무엇인지 이해하지 못하는 것이 분명합니다. . . 읽고 배우십시오. 그렇지 않으면 시간을 낭비하고 있습니다.


이것이 어떻게 이해가 될까요?

 while (err_mf_buy== "0" &&  err_mf_sell== "0" ){

bool, err_mf_buy가 어떻게 문자열과 같을 수 있습니까?

이것이 어떻게 이해가 됩니까?

 if ( "mf_sell" + "sp" <= "Sell_ans" && "Sell" == "open" ){

문자열 mf_sellsp는 Sell_ans와 결코 같지 않을 것입니다. 어떻게 스팅이 다른 문자열보다 작습니까? 사과 <= 오렌지입니까?

 
""에 0을 덮는 의미가 없다고 말하면서 수정했지만 오류가 발생했습니다.
 //+------------------------------------------------------------------+
//|                                                 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;
   int i= 1 ;
 double tpbuy;
 double tpsell;
 
   //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;
   tpbuy=buy_ans+ 0.00050 ;
   
   
     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;
   tpsell=sell_ans- 0.00050 ;
   
   
   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 {
       i++;
       }
       }
       
       
       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,tpbuy, 0 ,Blue);
             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,tpsell, 0 ,Red);
       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 {
     i++;
       }
       
       
       
         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,tpsell, 0 ,Red);
       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,tpbuy, 0 ,Blue);
          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 {
       i++;
       }
       
       }
       
       
   }

 
   
   
  }
   double ab= AccountBalance ();
  
//----
   return ( 0 );
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return ( 0 );
  }
 
이제 메타 에디터가 사전 정의된 변수에 대해 묻습니다.
 
Yes zero errors 0 warnings.....
//+------------------------------------------------------------------+
//|                                                 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;
   int i=1;
 double tpbuy;
 double tpsell;
 
  //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;
   tpbuy=buy_ans+0.00050;
   
   
    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;
   tpsell=sell_ans-0.00050;
   
   
   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{
       i++;
       }
       }
       
       
       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,tpbuy,0,Blue);
             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,tpsell,0,Red);
       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{
     i++;
       }
       
       
       
        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,tpsell,0,Red);
       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,tpbuy,0,Blue);
          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{
       i++;
       }
       
       }
       
       
   }

 
   
   
  }
  double ab=AccountBalance();
  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
 
mohsin360 :
이제 메타 에디터가 사전 정의된 변수에 대해 묻습니다.

구매가 선언되었습니까?

 if (mf_buy-bp == buy_ans && Buy == "open" )

Sell_trail이 선언되었습니까?

 while (buy_trail== 0 &&  Sell_trail== 0 ){

Sell_ans가 선언되었습니까?

 if (mf_sell+sp<=Sell_ans && Sell== "open" ){

판매가 선언되었습니까?

sp 는 int 입니다. . 이게 어떻게 말이 되나요?

sp = "(sp+5)" ;
 
예, 저는 이러한 대소문자를 구분하여 수정했으며 현재 전략을 백테스트 하고 있습니다. 감사합니다.
 
mohsin360 :
예, 저는 이러한 대소문자를 구분하여 수정했으며 현재 전략을 백테스트하고 있습니다. 감사합니다.
시간을 낭비하지 마십시오. . . 이 모든 무작위 수정 후에 코드는 예상대로 작동하지 않을 것입니다.
사유: