OrderSend error 4051, can you help me? - page 2

 
RaptorUK:
You can't see the final brace, there may be a return value, just not posted in this thread.
o, so how can we help
 
qjol:
o, so how can we help
Not easily . . .
 

qjol, RaptorUK Heelflip43 and WHRoeder, thank you all for the comments, I didn't have time to look into it yesterday, I'll try to fix it now. Sorry for those stupids mistakes, I'm steel learning with you guys.

Thank again for you help

 
RaptorUK:
Please show the code for LotsOptimized()
I forgot to put here the end of my function - return(lot). Sorry
//---- Entry Size ----//
double LotsOptimized()
  {
   double lot=Lots;
   if(Fixed_Lots==false)
   {
//---- select lot size
   lot=NormalizeDouble(MathFloor(AccountFreeMargin()*TradeSizePercent/1000)/100,2);
   // Check if mini or standard Account
   if(AccountIsMini)
     {
      lot=MathFloor(lot*100)/100;
      // Use at least 1 mini lot
      if(lot<0.1) lot=0.1;
      if (lot > MaxLots) lot=MaxLots;
     }
     else
     {
      if (lot < 1.0) lot=1.0;
      if (lot > MaxLots) lot=MaxLots;
     }
    }
    else
    {
      lot=Lots;
    }
//----
   return(lot);
  }

//---- Past P&L result ----//
double inteligent_Lot()
   {
      double lot;
      double Last.Return[];
      double Last_2.Return[];
      double Last_3.Return[];
      for(int iPos=OrdersHistoryTotal()-1; iPos >= 0 ; iPos--) 
        {
            if 
            (OrderSelect(iPos, SELECT_BY_POS, MODE_HISTORY)      // Only orders w/
            &&  OrderMagicNumber() == Magic.Number                  // my magic number
            &&  OrderSymbol()      == Symbol()                      // and my pair.
            &&  OrderType()        <= OP_SELL// Avoid cr/bal forum.mql4.com/32363#325360
            )
               {
               Last.Return[iPos]=OrderProfit();                 // my last trade result
               Last_2.Return[iPos-1]=OrderProfit();             // my penultimate result
               Last_3.Return[iPos-2]=OrderProfit();             // my ante penultimate result
                  if(Last.Return[iPos]>0 && Last_2.Return[iPos]>0)       // win in my last two trades
                  {
                     lot=NormalizeDouble(LotsOptimized()/3,2);
                  }
                  else
                  {
                     lot=LotsOptimized();
                  }
               }
               
               
        }
//----
   return(lot);        

   }  
   
// the end

//+------------------------------------------------------------------+ 
 
WHRoeder:
  1. These arrays have no size and you never give them any with ArrayResize()
  2. Why are you setting the same value to 3 different arrays in 3 different positions?


Thanks WHRoeder

1. I will study how to fix it

2.I thought that I was setting different values on it, now I realize that I'm inserting the same value, but I'm not sure how to do it, looping?

 
Reason: