New Deal Error

 

hello 

I am going to test my strategy and I got error 4014 for opening new deal,

Kindly let me know,

bool Trade(int direction, double volume, double PivotStoploos)
  {
   ZeroMemory(Request);
   ZeroMemory(Results);
   ZeroMemory(Check);

   Request.action    = TRADE_ACTION_DEAL;
   Request.symbol    = Symbol();
   Request.volume    = volume;
   Request.magic     = 100;
   Request.deviation = Deviation;
   if(direction == 1)
     {
      Request.type  = ORDER_TYPE_BUY;
      Request.price =  SymbolInfoDouble(Symbol(), SYMBOL_ASK);
      Request.sl    =  StopLoss * PivotStoploos;
     }
   if(direction == -1)
     {
      Request.type  = ORDER_TYPE_SELL;
      Request.price =  SymbolInfoDouble(Symbol(), SYMBOL_BID);
      Request.sl    =  StopLoss * PivotStoploos;
     }
   if(OrderCheck(Request, Check) && Check.retcode == 0)
     {
      if(!OrderSend(Request, Results) || Results.retcode != 10009)
         return(false);
      return(true);
     }
   else
     {
      if(Check.retcode == 10025)
         Print("No changes in request");
      if(Check.retcode == 10019)
         Print("There is not enough money to complete the request");
      if(Check.retcode == 10014)
         Print("Invalid volume in the request");

      PrintFormat("OrderSend error %d",GetLastError());
      return(false);
     }
   return(true);
  }

how can I fix it?

 
Did you check what is error 4014 ?
 
Alain Verleyen:
Did you check what is error 4014 ?
yes, but i can not find any documents
 
Ehsan Amiri: yes, but i can not find any documents
      Request.price =  SymbolInfoDouble(Symbol(), SYMBOL_BID);
      Request.sl    =  StopLoss * PivotStoploos;
Isn't sl a price? What are you passing?
          Constants, Enumerations and Structures / Data Structures / Trade Request Structure - Reference on algorithmic/automated trading language for MetaTrader 5
 
StopLoss  is a variable with default value 1 and PivotStoploos is a number that calculated in market range. 
 
Ehsan Amiri: StopLoss is a variable with default value 1 and PivotStoploos is a number that calculated in market range.
Not what I asked!
 
William Roeder:
Not what I asked!

yes, sl is a price. 

 
Ehsan Amiri: yes, sl is a price. 

Is PivotStoploos?

 
William Roeder:

Is PivotStoploos?

yes