4753 error. Can anyone help , I post my code here.

 

Hi I coded a simple EA for my first try, but it does not work when it was tested. I got the problem about "unsupported filling type" last time and I added some new code to solve this, but this time it still does not work by sending the error code: 4753. I am really confused becoz I dont know where is the problem from the buy/sell part of code.

I post my code here and hope anyone be kind to point out the problem and give me some suggestion.Thx!

The logic of EA is quiet simple:If fast moving average cross up slow moving average then buy or (close sell positon and buy)

                                                If fast moving average cross down slow moving average then sell or (close buy positon and sell)

//--- input parameters
input int      StopLoss=30;
input int      Ma1_Period=10;
input int      Ma2_Period=20;
input int      EA1_Magic=123456;
input int      EA2_Magic=1234567;
input double   Lot=0.1;
int Ma1Handle; 
int Ma2Handle;  
double Ma1Val[];
double Ma2Val[]; 
int STP; 
ENUM_ORDER_TYPE_FILLING GetFilling( const string Symb, const uint Type = ORDER_FILLING_FOK )
{
  const ENUM_SYMBOL_TRADE_EXECUTION ExeMode = (ENUM_SYMBOL_TRADE_EXECUTION)::SymbolInfoInteger(Symb, SYMBOL_TRADE_EXEMODE);
  const int FillingMode = (int)::SymbolInfoInteger(Symb, SYMBOL_FILLING_MODE);

  return((FillingMode == 0 || (Type >= ORDER_FILLING_RETURN) || ((FillingMode & (Type + 1)) != Type + 1)) ?
         (((ExeMode == SYMBOL_TRADE_EXECUTION_EXCHANGE) || (ExeMode == SYMBOL_TRADE_EXECUTION_INSTANT)) ?
           ORDER_FILLING_RETURN : ((FillingMode == SYMBOL_FILLING_IOC) ? ORDER_FILLING_IOC : ORDER_FILLING_FOK)) :
          (ENUM_ORDER_TYPE_FILLING)Type);
}

int OnInit()
  {

   Ma1Handle=iMA(_Symbol,_Period,Ma1_Period,0,MODE_EMA,PRICE_CLOSE);

   Ma2Handle=iMA(_Symbol,_Period,Ma2_Period,0,MODE_EMA,PRICE_CLOSE);

   if(Ma1Handle<0 || Ma2Handle<0)
     {
      Alert("波仔!创建指标出错: ",GetLastError(),"!!");
     }

   STP = StopLoss;
   if(_Digits==5 || _Digits==3)
     {
      STP = STP*10;
     }

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   IndicatorRelease(Ma1Handle);
   IndicatorRelease(Ma2Handle);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
      if(Bars(_Symbol,_Period)<200) 
     {
      Alert("波仔,历史数据不足,将要退出交易!");
      return;
     }

   static datetime Old_Time;
   datetime New_Time[1];
   bool IsNewBar=false;
   int copied=CopyTime(_Symbol,_Period,0,1,New_Time);
   if(copied>0) 
     {
      if(Old_Time!=New_Time[0])
        {
         IsNewBar=true;  
         if(MQL5InfoInteger(MQL5_DEBUGGING)) Print("我们有新时间 ",New_Time[0]," 旧的时间是 ",Old_Time);
         Old_Time=New_Time[0];           
        }
     }
   else
     {
      Alert("波仔,历史时间数据出错, 错误 =",GetLastError());
      ResetLastError();
      return;
     }

   if(IsNewBar==false)
     {
      return;
     }

   MqlTick latest_price;     
   MqlTradeRequest BoRequest;  
   MqlTradeResult BoResult;    
   MqlRates BoRate[];         
   ZeroMemory(BoRequest);  

   ArraySetAsSeries(BoRate,true);
   ArraySetAsSeries(Ma1Val,true);
   ArraySetAsSeries(Ma2Val,true);

   if(!SymbolInfoTick(_Symbol,latest_price))
     {
      Alert("波仔,无法获得最后价格:",GetLastError(),"!!");
      return;
     }

   int Ma1=CopyBuffer(Ma1Handle,0,0,3,Ma1Val);
   int Ma2=CopyBuffer(Ma2Handle,0,0,3,Ma2Val);

   if(Ma1<0||Ma2<0)
     {
      Alert("阿波,复制均线数据出错:",GetLastError());
      return;
     }

    bool Buy_opened=false;  
    bool Sell_opened=false; 
    
    if (PositionSelect(_Symbol) ==true)  
    {
         if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY)
         {
            Buy_opened = true; 
         }
         else if(PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL )
         {
            Sell_opened = true; 
         }
    }


   bool ComeOnBaby= (Ma1Val[1]>Ma2Val[1]) && (Ma2Val[2]>Ma1Val[2]); 
   
   if(ComeOnBaby) 
     {
       if (Buy_opened)return;
       
       else if(Sell_opened)
         {
         BoRequest.action = TRADE_ACTION_CLOSE_BY;                                
         BoRequest.price = NormalizeDouble(latest_price.ask,_Digits);          
         BoRequest.symbol = _Symbol;                                         
         BoRequest.volume = Lot;                                            
         BoRequest.magic = EA1_Magic;                                       
         BoRequest.type = ORDER_TYPE_BUY;                                    
         BoRequest.type_filling = GetFilling(BoRequest.symbol);                        
         BoRequest.deviation=20;                                                
         return;
          }

         //开始做嘢!
         BoRequest.action = TRADE_ACTION_DEAL;                                
         BoRequest.price = NormalizeDouble(latest_price.ask,_Digits);          
         BoRequest.sl = NormalizeDouble(latest_price.ask - STP*_Point,_Digits); 
         BoRequest.symbol = _Symbol;                                         
         BoRequest.volume = Lot;                                            
         BoRequest.magic = EA2_Magic;                                       
         BoRequest.type = ORDER_TYPE_BUY;                                    
         BoRequest.type_filling = GetFilling(BoRequest.symbol);                          
         BoRequest.deviation=20;   
         
         if(BoResult.retcode==10009 || BoResult.retcode==10008) //掂!
           {
            Alert("阿波,已经搞掂,订单#:",BoResult.order,"!!");
           }
         else
           {
            Alert("未搞掂:",GetLastError());
            ResetLastError();           
            return;
           }
        return;
        }

  bool BabyComeOn = (Ma2Val[1]>Ma1Val[1]) && (Ma1Val[2]>Ma2Val[2]); 
   
  if(BabyComeOn) 
     {
       if (Sell_opened) return;
       else if(Buy_opened)
         {
         BoRequest.action = TRADE_ACTION_CLOSE_BY;                                
         BoRequest.price = NormalizeDouble(latest_price.bid,_Digits);          
         BoRequest.symbol = _Symbol;                                         
         BoRequest.volume = Lot;                                            
         BoRequest.magic = EA1_Magic;                                       
         BoRequest.type = ORDER_TYPE_SELL;                                    
         BoRequest.type_filling = GetFilling(BoRequest.symbol);                         
         BoRequest.deviation=20;                                                     
         return;
          }

         
         BoRequest.action = TRADE_ACTION_DEAL;                                
         BoRequest.price = NormalizeDouble(latest_price.bid,_Digits);          
         BoRequest.sl = NormalizeDouble(latest_price.ask + STP*_Point,_Digits); 
         BoRequest.symbol = _Symbol;                                         
         BoRequest.volume = Lot;                                            
         BoRequest.magic = EA2_Magic;                                       
         BoRequest.type = ORDER_TYPE_SELL;                                    
         BoRequest.type_filling = GetFilling(BoRequest.symbol);                     
         BoRequest.deviation=20;   
            
         if(BoResult.retcode==10009 || BoResult.retcode==10008) //掂!
           {
            Alert("阿波,已经搞掂,订单#:",BoResult.order,"!!");
           }
         else
           {
            Alert("未搞掂:",GetLastError());
            ResetLastError();
            return;
           }
        return;
        }
  }
//+------------------------------------------------------------------+
 

What's that code ? There is not even an OrderSend() for you requests. Post real code if you need help.

 
Alain Verleyen:

What's that code ? There is not even an OrderSend() for you requests. Post real code if you need help.


Hi Alain

My EA is not working at all , the trading journal gave back none of errors and trade, no execution happened.

I just want a simple trading : if BuyCondition is ture, check the position, if buy opened ->return, if sell opened ->close position and buy, if no position then buy.

                                               if SellCondition is ture, check the position, if sell opened ->return, if buy opened ->close position and sell, if no position then sell.

But my code does not work:

if(BuyCondition) 
     {
       if (Buy_opened )return;
       else if (Sell_opened )
       {
         BoRequest.action = TRADE_ACTION_DEAL;
                                    
         BoRequest.price = SymbolInfoDouble(position_symbol,SYMBOL_ASK);           
         BoRequest.symbol = position_symbol;                                          
         BoRequest.volume = volume;                                           
         BoRequest.magic = EA_Magic;                                       
         BoRequest.type = ORDER_TYPE_BUY;                                    
         BoRequest.type_filling = GetFilling(BoRequest.symbol);                          
         BoRequest.deviation=20; 
         OrderSend(BoRequest,BoResult);
         Print(BoResult.retcode);
        
        }  
       else
       { 
         
         BoRequest.action = TRADE_ACTION_DEAL;                                
         BoRequest.price = NormalizeDouble(latest_price.ask,_Digits);          
         BoRequest.sl = NormalizeDouble(latest_price.ask - STP*_Point,_Digits); 
         BoRequest.symbol = _Symbol;                                         
         BoRequest.volume = Lot;                                            
         BoRequest.magic = EA_Magic;                                       
         BoRequest.type = ORDER_TYPE_BUY;                                    
         BoRequest.type_filling = GetFilling(BoRequest.symbol);                          
         BoRequest.deviation=20;   
         
         OrderSend(BoRequest,BoResult);
         Print(BoResult.retcode," ",BoResult.ask," ",SymbolInfoInteger(Symbol(),SYMBOL_DIGITS)," ",BoRequest.volume);
         if(BoResult.retcode==10009 || BoResult.retcode==10008) 
           {
            Alert("completed #:",BoResult.order,"!!");
           }
         else
           {
            Alert("not completed:",GetLastError());
            ResetLastError();           
            return;
           }
           return;
           }
       
        }

 
   
  if(SellCondition) 
     {
       if (Sell_opened) return;
       else if (Buy_opened)
       {
         BoRequest.action = TRADE_ACTION_DEAL;                                
         BoRequest.price = SymbolInfoDouble(position_symbol,SYMBOL_BID);           
         BoRequest.symbol = position_symbol;                                          
         BoRequest.volume = volume;                                           
         BoRequest.magic = EA_Magic;                                       
         BoRequest.type = ORDER_TYPE_SELL;                                    
         BoRequest.type_filling = GetFilling(BoRequest.symbol);                          
         BoRequest.deviation=20; 
         OrderSend(BoRequest,BoResult);
         Print(BoResult.retcode);
         
        }  
        else
        {
         
         BoRequest.action = TRADE_ACTION_DEAL;                                
         BoRequest.price = NormalizeDouble(latest_price.bid,_Digits);          
         BoRequest.sl = NormalizeDouble(latest_price.ask + STP*_Point,_Digits); 
         BoRequest.symbol = _Symbol;                                         
         BoRequest.volume = Lot;                                            
         BoRequest.magic = EA_Magic;                                       
         BoRequest.type = ORDER_TYPE_SELL;                                    
         BoRequest.type_filling = GetFilling(BoRequest.symbol);                     
         BoRequest.deviation=20;   
         
         OrderSend(BoRequest,BoResult);
         Print(BoResult.retcode," ",BoResult.ask," ",SymbolInfoInteger(Symbol(),SYMBOL_DIGITS)," ",BoRequest.volume);
         if(BoResult.retcode==10009 || BoResult.retcode==10008) 
           {
            Alert("completed #:",BoResult.order,"!!");
           }
         else
           {
            Alert("not completed:",GetLastError());
            ResetLastError();
            return;
           }
           return;
           }
           }

                                    

Reason: