coding

 

Hello


i'm translating my mql4 code to mql5

is this part right?

the ea set no order in the backtest



  MqlDateTime h;
      TimeCurrent(h);


   double High[],Low[], Open[]; // für die Berechnung von Hoch und Tief
   int Spread[];
   double Hoch    = CopyHigh  (_Symbol,_Period,Pins_back-Offset_Start,Pins,High);
   double Tief    = CopyLow   (_Symbol,_Period,Pins_back-Offset_Start,Pins,Low);            
   double DayOpen = CopyOpen  (_Symbol,_Period,Offset_Start,1,Open);
   int    spread  = CopySpread(_Symbol,_Period,0,0,Spread);

   
   

   //Setup orders
   if( h.hour == Start ){
      long order_magic= 130777;SetOrders(Text, order_magic, Hoch, Tief, DayOpen, spread);
      }

   Sleep(1000);
   
      
   
   return(0);
   }

void SetOrders(string Text,long order_magic, double Hoch, double Tief, double DayOpen, int spread){
 

  datetime from=0;
  datetime to = TimeCurrent();

 //sucht die Orders aus der Hostory raus

   HistorySelect(from,to);
//--- variables for returning values from order properties

   ulong    ticket;
   double   open_price;
   double   initial_volume;
   datetime time_setup;
   string   symbol;
   ulong   type;
   ulong    Bought;
   ulong    Sold;
   //long     order_magic;
   
//--- number of current pending orders
   uint     total=OrdersTotal();
//--- go through orders in a loop
   for(uint i=0;i<total;i++)
     {
      //--- return order ticket by its position in the list
      if(ticket=OrderGetTicket(i) && order_magic == OrderGetInteger(ORDER_MAGIC) && Text == OrderGetString(ORDER_COMMENT)) {
         //--- return order properties
         
        
         symbol             =      OrderGetString(ORDER_SYMBOL);
         //order_magic        =      OrderGetInteger(ORDER_MAGIC);
         type               =      OrderGetInteger(ORDER_TYPE);
         //Text               =      OrderGetString(ORDER_COMMENT);

      switch(type) {
         case (ORDER_TYPE_BUY):            Bought++;
         case (ORDER_TYPE_SELL):           Sold++;
         case (ORDER_TYPE_BUY_LIMIT):      Bought++;
         case (ORDER_TYPE_SELL_LIMIT):     Sold++;
         case (ORDER_TYPE_BUY_STOP):       Bought++;
         case (ORDER_TYPE_SELL_STOP):      Sold++;
         case (ORDER_TYPE_BUY_STOP_LIMIT): Bought++;
         case (ORDER_TYPE_SELL_STOP_LIMIT):Sold++;
         };
      }
    }
    
        
         
        
   
//---
  

   MqlTradeRequest request;
   MqlTradeResult result;
      if(Bought == 0){
   
      request.action = TRADE_ACTION_PENDING;
      request.type = ORDER_TYPE_BUY_STOP;
      request.symbol = Symbol();
      request.magic = order_magic;
      request.price = Long;     //double value
      request.volume = 1;// Lots;
      request.tp = 0;
      request.sl = SL_Long;  //double Value
      request.deviation = 5;
      request.type_filling = ORDER_FILLING_AON;
      request.expiration = TimeCurrent()+23*60*60;
      request.comment = Text;
     
     bool ok = OrderSend(request,result);
     if(!ok)
     {
         int err = GetLastError();
         Print("error buy stop (",err,")");
     }
   }

 
amando:

Hello

i'm translating my mql4 code to mql5

is this part right?

the ea set no order in the backtest

You have published just part of your source code, so I think nobody can say anything about them. 

 

this is the part what isnt working