there are no trading operations - page 3

 

I have solved this problem.

Add this code before CheckVolumeValue :

double min_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);
   if(lotlot<min_volume)
     {
      lotlot=min_volume;
     }

//--- maximal allowed volume of trade operations
   double max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX);
   if(lotlot>max_volume)
     {
      lotlot=max_volume;
     }


Before :

extern double    Lots=0.01;

if(totalsell()==0  && IsNewOrderAllowed() && CheckVolumeValue(lotlot,lotcheck) && CheckMoneyForTrade(Symbol(),lotlot,OP_SELL))
     {
         int opensell=OrderSend(Symbol(),OP_SELL,lotlot,Bid,(int)Slippage,0,0,comment,MagicNumber,0,Green);
     }


After :

extern double    Lots=0.01;

double min_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);
   if(lotlot<min_volume)
     {
      lotlot=min_volume;
     }

//--- maximal allowed volume of trade operations
   double max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX);
   if(lotlot>max_volume)
     {
      lotlot=max_volume;
     }

if(totalsell()==0  && IsNewOrderAllowed() && CheckVolumeValue(lotlot,lotcheck) && CheckMoneyForTrade(Symbol(),lotlot,OP_SELL))
     {
         int opensell=OrderSend(Symbol(),OP_SELL,lotlot,Bid,(int)Slippage,0,0,comment,MagicNumber,0,Green);
     }


Regards

Rio Purwanggono

 
what is the value of "lotcheck" ?
 

The solution is simple, I just add the code:

iLots = NormalizeDouble(iLots,_Digits);

for the new lot orders

 
Ubaidillah: I just add the code: iLots = NormalizeDouble(iLots,_Digits);
You used NormalizeDouble, It's use is usually wrong, as it is in your case.
 
whroeder1:
You used NormalizeDouble, It's use is usually wrong, as it is in your case.

Oh I'm sorry, I mean this code:

if(Lots<SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN)){
Lots=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
Print("Lot value too small, and set to minimum symbol volume : ",Lots);

}
Maybe it's because I'm too happy to paste the wrong code...
 

Test failed with fixed defined lots@ 0.01/0.1 which are external params to my EA.Testing succeeded when i set Lots to 1.0... 

maybe that helps some of you...  

 
Manuel Joos:

Test failed with fixed defined lots@ 0.01/0.1 which are external params to my EA.Testing succeeded when i set Lots to 1.0... 

maybe that helps some of you...  

as far i observed, market validation use multiple setting/server type. Some broker or pair minimum lot order is 0.01 or 0.10 or 1.00. For example minimum lot for crude oil is 1.00 lot.

 

everything has been tried and nothing seem to work!


Problem is the message is so mysterious! they don't tell you where the error is or what is causing it in the code, nothing at all.

Just same message thrown at you every time!

I have made tons of adjustments to things ralated and not related to what seem to be the problem.

But thus far, same error message, "

there are no trading operations

"

This is no fair!

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
  • www.mql5.com
Trading is done by sending orders to open positions using the OrderSend() function, as well as to place, modify or delete pending orders. Each trade order refers to the type of the requested operation. Trading operations are described in the ENUM_TRADE_REQUEST_ACTIONS enumeration...
 
Hesham Ahmed Kamal Barakat:

everything has been tried and nothing seem to work!


This is no fair!
  1. "Doesn't work" is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
         How To Ask Questions The Smart Way. 2004
              When asking about code

    Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.
         How To Ask Questions The Smart Way. 2004
              Be precise and informative about your problem

    We can't see your broken code.

    Fix your broken code.

    With the information you've provided — we can only guess. And you haven't provided any information for that.

  2. Life is not fair. The world doesn't owe you. Get over yourself.
 
William Roeder:
  1. "Doesn't work" is meaningless — just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires — meaningless.
         How To Ask Questions The Smart Way. 2004
              When asking about code

    Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.
         How To Ask Questions The Smart Way. 2004
              Be precise and informative about your problem

    We can't see your broken code.

    Fix your broken code.

    With the information you've provided — we can only guess. And you haven't provided any information for that.

  2. Life is not fair. The world doesn't owe you. Get over yourself.

See the code on the documentation, validator does not work

double lot         = 0.01;
int    m_deviation = 30;
int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|  Проверяет объем ордера на корректность                          |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(!CheckMoneyForTrade(Symbol(), lot, OP_BUY))
      return;
   if(!CheckVolumeValue(lot))
      return;
   if(OrderSend(Symbol(), OP_BUY, NormalizeDouble(lot, 2),  NormalizeDouble(Ask, Digits()), m_deviation, 0, 0, "Comment", 0, 0, clrBlue) < 0)
     {
      Print(" OrderSend OP_BUY Error ", ::GetLastError());
      return ;
     }
  }
//+------------------------------------------------------------------+
//|  Проверяет объем ордера на корректность                          |
//+------------------------------------------------------------------+
bool CheckMoneyForTrade(string symb, double lots, int type)
  {
   double free_margin = AccountFreeMarginCheck(symb, type, lots);
   if(free_margin < 0)
     {
      string oper = (type == OP_BUY) ? "Buy" : "Sell";
      Print("Not enough money for ", oper, " ", lots, " ", symb, " Error code=", GetLastError());
      return(false);
     }
   return(true);
  }
//+------------------------------------------------------------------+
//|  Проверяет объем ордера на корректность                          |
//+------------------------------------------------------------------+
bool CheckVolumeValue(double volume)
  {
//--- минимально допустимый объем для торговых операций
   double min_volume = SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_MIN);
   if(volume < min_volume)
     {
      Print("Объем меньше минимально допустимого SYMBOL_VOLUME_MIN=%.2f", min_volume);
      return(false);
     }
//--- максимально допустимый объем для торговых операций
   double max_volume = SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_MAX);
   if(volume > max_volume)
     {
      Print("Объем больше максимально допустимого SYMBOL_VOLUME_MAX=%.2f", max_volume);
      return(false);
     }
//--- получим минимальную градацию объема
   double volume_step = SymbolInfoDouble(Symbol(), SYMBOL_VOLUME_STEP);

   int ratio = (int)MathRound(volume / volume_step);
   if(MathAbs(ratio * volume_step - volume) > 0.0000001)
     {
      Print("Объем не является кратным минимальной градации SYMBOL_VOLUME_STEP=%.2f, ближайший корректный объем %.2f",
            volume_step, ratio * volume_step);
      return(false);
     }
   return(true);
  }
Reason: