Problem with Validation MQl Market invalid lots amount for OrderSend function

 

Hi,

i got a Problem with validation on market here with my EXpert Advisor

this is the Problem ;   

invalid lots amount for OrderSend function The EA IS RUNNING ON Mt4 without Problems. But Validation on Market here dont works. Can anyone help me? here is the code




//+-------------------------------------------------------------------+
//| pofit                                                             |
//+-------------------------------------------------------------------+
double pofit()
  {
   double profit=0;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic)
           {
            profit+=OrderProfit()+OrderSwap();
           }
        }
     }
   return(profit);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   if(ACCOUNT_NUMBER>0 && ACCOUNT_NUMBER!=AccountNumber())
     {
      Comment("Wrong Account number!");

        }
     }
   return(LOOPs);
  }
//+------------------------------------------------------------------+
int cmd() // additional
  {
   int cmds=OrderType();
   return(cmds);
  }
double OOP() // additional
  {
   double OOPs=OrderOpenPrice();
   return(OOPs);
  }
string OT2() // additional
  {
   string OT2s=StringSubstr(OrderComment(),0,1);
   return(OT2s);
  }
int LCT()
  {
   int LCTs=StrToInteger(StringSubstr(OrderComment(),1,3));
   return(LCTs);
  }
bool hedges() // additional
  {
   bool hedge_2=false;
   if(hedge && T()>=h_level && T()<=h_top_level)
      hedge_2=true;
   return(hedge_2);
  }
//+------------------------------------------------------------------+
double h_entry() // additional
  {
   double rsi_1=0;
   if(hedges() && h_cnt==0)
     {
      if(h_rsi_entry)
         rsi_1=iRSI(Symbol(),0,rsi_period_2,PRICE_CLOSE,rsi_shift_2);
     }
   return(rsi_1);
  }
double h_exit() // additional
  {
   double rsi_2=0;
   if(hedges() && h_cnt>0)
     {
      if(h_rsi_exit)
         rsi_2=iRSI(Symbol(),0,rsi_period_3,PRICE_CLOSE,rsi_shift_3);
     }
   return(rsi_2);
  }
double h_tp_over() // additional
  {
   double rsi_3=0;
   if(hedges() && h_cnt>0)
     {
      if(tp_override)
         rsi_3=iRSI(Symbol(),0,rsi_period_4,PRICE_CLOSE,rsi_shift_4);
     }
   return(rsi_3);
  }
double h_velo()
  {
   double velo=0; // additional
   if(hedge && h_cnt==0)
     {
      if(h_rsi_entry && h_velocity)
         velo=iCustom(NULL,0,"J_TPO_Velocity",vel_period,0,0);
     }
   return(velo);
  }
//+------------------------------------------------------------------+
int order_send()
  {
   int o_sends=2;
   if(use_trading_sessions)
     {
      int total_shift=gmt_shift;
      if(daylight_savings)
         total_shift=gmt_shift+1;
      int asian_open=0+total_shift, asian_close=8 +total_shift;
      int euro_open=6 +total_shift, euro_close=16 +total_shift;
      int ny_open=12  +total_shift, ny_close=21   +total_shift;
      //----
      if(DayOfWeek()==0) // sunday
        {
         if(asian_daily)
           {
            asian_open=sun_asian_open;
            asian_close=sun_asian_close;
           }
         if(euro_daily)
           {
            euro_open=sun_euro_open;
            euro_close=sun_euro_close;
           }
         if(ny_daily)
           {
            ny_open=sun_ny_open;
            ny_close=sun_ny_close;
           }
         //---
         if(!t_day[0])
           {
            t_day[0]=true;
            mtd_time=TimeCurrent();
            t_day[5]=false;
           }
        }
      if(DayOfWeek()==1) // monday
        {
         if(asian_daily)
           {
            asian_open=mon_asian_open;
            asian_close=mon_asian_close;
           }
         if(euro_daily)
           {
            euro_open=mon_euro_open;
            euro_close=mon_euro_close;
           }
         if(ny_daily)
           {
            ny_open=mon_ny_open;
            ny_close=mon_ny_close;
           }
         //---
         if(!t_day[1])
           {
            t_day[1]=true;
            mtd_time=TimeCurrent();
            t_day[0]=false;
           }
        }
      if(DayOfWeek()==2) // tuesday
        {
         if(asian_daily)
           {
            asian_open=tue_asian_open;
            asian_close=tue_asian_close;
           }
         if(euro_daily)
           {
            euro_open=tue_euro_open;
            euro_close=tue_euro_close;
           }
         if(ny_daily)
           {
            ny_open=tue_ny_open;
            ny_close=tue_ny_close;
           }
         //---
         if(!t_day[2])
           {
            t_day[2]=true;
            mtd_time=TimeCurrent();
            t_day[1]=false;
           }
        }
      if(DayOfWeek()==3) // wednesday
        {
         if(asian_daily)
           {
            asian_open=wed_asian_open;
            asian_close=wed_asian_close;
           }
         if(euro_daily)
           {
            euro_open=wed_euro_open;
            euro_close=wed_euro_close;
           }
         if(ny_daily)
           {
            ny_open=wed_ny_open;
            ny_close=wed_ny_close;
           }
         //---
         if(!t_day[3])
           {
            t_day[3]=true;
            mtd_time=TimeCurrent();
            t_day[2]=false;
           }
        }
      if(DayOfWeek()==4) // thursday
        {
         if(asian_daily)
           {
            asian_open=thu_asian_open;
            asian_close=thu_asian_close;
           }
         if(euro_daily)
           {
            euro_open=thu_euro_open;
            euro_close=thu_euro_close;
           }
         if(ny_daily)
           {
            ny_open=thu_ny_open;
            ny_close=thu_ny_close;
           }
         //---
         if(!t_day[4])
           {
            t_day[4]=true;
            mtd_time=TimeCurrent();
            t_day[3]=false;
           }
        }
      if(DayOfWeek()==5) // friday
        {
         if(asian_daily)
           {
            asian_open=fri_asian_open;
            asian_close=fri_asian_close;
           }
         if(euro_daily)
           {
            euro_open=fri_euro_open;
            euro_close=fri_euro_close;
           }
         if(ny_daily)
           {
            ny_open=fri_ny_open;
            ny_close=fri_ny_close;
           }
         //---
         if(!t_day[5])
           {
            t_day[5]=true;
            mtd_time=TimeCurrent();
            t_day[4]=false;
           }
        }
      //----
      bool o_time=false;
      if(asian_session && Hour()>=asian_open && Hour()<=asian_close)
         o_time=true;
      if(euro_session  && Hour()>=euro_open  && Hour()<=euro_close)
         o_time=true;
      if(ny_session    && Hour()>=ny_open    && Hour()<=ny_close)
         o_time=true;
      //----
      if(o_time)
        {
         if(signal()==buy)
            o_sends=0;
         if(signal()==sell)
            o_sends=1;
        }
     }
   return(o_sends);
  }
//+------------------------------------------------------------------+
int signal()
  {
   if(T()==0) // additional
     {
      if(forward_trend)
        {
         if(!use_velocity)
           {
            double rsi_1=iRSI(Symbol(),0,rsi_period_1,PRICE_CLOSE,rsi_shift_1);
            if(rsi_1>upper_min && rsi_1<upper_max)
               return(buy);
            if(rsi_1<lower_min && rsi_1>lower_max)
               return(sell);
           }
         if(use_velocity)
           {
            double velo=iCustom(NULL,0,"J_TPO_Velocity",fv_period,0,0);
            if(velo>vel_offset)
               return(buy);
            if(velo<-vel_offset)
               return(sell);
           }
        }
      if(!forward_trend)
        {
         double upBB=iBands(Symbol(),0,bb_period,bb_deviation,0,PRICE_CLOSE,MODE_UPPER,bb_shift);
         double loBB=iBands(Symbol(),0,bb_period,bb_deviation,0,PRICE_CLOSE,MODE_LOWER,bb_shift);
         double stoch=iStochastic(Symbol(),0,k,d,slowing,MODE_SMA,price_field,MODE_SIGNAL,stoch_shift);
         double rsi=iRSI(Symbol(),0,rsi_period,PRICE_CLOSE,rsi_shift);
         if(use_bb && use_stoch && use_rsi)
           {
            if(High[bb_shift]>upBB && stoch>up_level && rsi>upper)
               return(sell);
            if(Low[bb_shift]<loBB && stoch<lo_level && rsi<lower)
               return(buy);
           }
         if(use_bb && use_stoch && !use_rsi)
           {
            if(High[bb_shift]>upBB && stoch>up_level)
               return(sell);
            if(Low[bb_shift]<loBB && stoch<lo_level)
               return(buy);
           }
         if(use_bb && !use_stoch && !use_rsi)
           {
            if(High[bb_shift]>upBB)
               return(sell);
            if(Low[bb_shift]<loBB)
               return(buy);
           }
         if(!use_bb && use_stoch && use_rsi)
           {
            if(stoch>up_level && rsi>upper)
               return(sell);
            if(stoch<lo_level && rsi<lower)
               return(buy);
           }
         if(!use_bb && use_stoch && !use_rsi)
           {
            if(stoch>up_level)
               return(sell);
            if(stoch<lo_level)
               return(buy);
           }
         if(use_bb && !use_stoch && use_rsi)
           {
            if(High[bb_shift]>upBB && rsi>upper)
               return(sell);
            if(Low[bb_shift]<loBB && rsi<lower)
               return(buy);
           }
         if(!use_bb && !use_stoch && use_rsi)
           {
            if(rsi>upper)
               return(sell);
            if(rsi<lower)
               return(buy);
           }
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
void closeall()
  {
  Print("closeall");
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      bool os = OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic)
         continue;
      if(cmd()>1)
         bool od = OrderDelete(OrderTicket());
      else
        {
         if(cmd()==0)
            bool oc = OrderClose(OrderTicket(),OrderLots(),Bid,3,CLR_NONE);
         else
            bool oc = OrderClose(OrderTicket(),OrderLots(),Ask,3,CLR_NONE);
        }
     }
  }
//HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
 
Alexander Manfred Fleck:

Hi,

i got a Problem with validation on market here with my EXpert Advisor

this is the Problem ;   

invalid lots amount for OrderSend function The EA IS RUNNING ON Mt4 without Problems. But Validation on Market here dont works. Can anyone help me? here is the code

In your code, the order_send() function determines the type of order (buy, sell, or do nothing) based on certain conditions. However, it doesn't handle the calculation or specification of the lot size for the orders. The order_send() function is returning an invalid value for the o_sends variable, which is then used to determine the type of order to send. This variable is set to 2 by default, and it seems that this value is not being changed under certain conditions, leading to the "invalid lots amount for OrderSend function" error when attempting to send orders.
 
Alexander Manfred Fleck: i got a Problem with validation on market here with my EXpert Advisor

Your posted code does nothing.

int start()
  {
   if(ACCOUNT_NUMBER>0 && ACCOUNT_NUMBER!=AccountNumber())       { … }
   return(LOOPs);
  }
 
Ok and what can i do?