Validation error when releasing the trading robot to the market. - page 5

 
Thanks for the tip, but probably not my case. My validator doesn't see the trading functions at all, no way to get to the maximum number of orders )))
 

Oh, shaitan... Passed validation and now

no trading operations

no longer an error.

P.S. It was a random shot. Next test is the same thing again


 
Andrey Kaunov:

There's no error here, I don't understand what's going on at all. I put a crutch (division by zero) before the trade function:

It works:

I take it out, it gives me the same

No trading operations.

I don't understand what prevents validator from OrderSend(). After all, if it reaches him, there must be billing errors (although I've fixed them all) 130, 131, 134, ..., but not"no trading operations". I've only got to put a pending order somewhere far away in OnInit() to prevent it from triggering.

And what is the sense in such a crutch if the condition under which a position must be executed does not enter the code?

 
Why isn't it coming in?! Look carefully, Alexey. Just before OrderSend there is a crutch.
 
Andrey Kaunov:
Why is there no input?! Look carefully Alexey. There is a crutch just before OrderSend.

Right. If OrderSend is not executed, it means that code execution does not reach it for some reason. And no matter what you put before it in the condition block, there is no input and no execution, not even division by zero.

 

Wait, I don't understand. If operator 1 (division by zero) is executed, then the next one is the if operator. And that means checking its condition. To check the condition, the OrderSend function must be executed, which means that it is next in line after division by zero.

But never mind. I have changed the code for the sake of purity of the experiment:


The result is the same. The result with the crutch is an error of division by zero. Without the crutch, the result is shown above: no trading operations.

 
Andrey Kaunov:

Wait, I don't understand. If operator 1 (division by zero) is executed, then the next one is the if operator. And that means checking its condition. To check the condition, the OrderSend function must be executed, which means that it is next in line after division by zero.

But never mind. I have changed the code for the sake of purity of the experiment:


The result is the same. The result with the crutch is an error of division by zero. The result is shown above without it: no trading operations.

You should not have used a picture to paste the code. It is impossible to read it at all. And the problem is not in this code fragment. The problem is that some condition is not fulfilled at some input parameters and there is no notification.

 
Andrey Kaunov:
Why doesn't it come in?!

Why are you trying to write worse for the market than for yourself?

It's simple - before sending an order, see "is it even executable?"

check the limits (you said that), check the funds and margin (you don't have that), see if there is a link and if the trade is allowed.

(option) if there were heavy calculations, it is not a sin to RefreshRates before reading Bid Ask

For your own sake you will do all these checks. Why not now?

 

You think I don't check. The lot size is checked in a separate function

//+------------------------------------------------------------------+
//| Функция нормализации лота                                        |
//+------------------------------------------------------------------+
double NormalizeLots(string symbol, double lot, bool is_margin=true) {
   if(lot<=0) return(0.0);
   RefreshRates();
   double min=SymbolInfoDouble(symbol,SYMBOL_VOLUME_MIN);
   double max=SymbolInfoDouble(symbol,SYMBOL_VOLUME_MAX);
   double step=SymbolInfoDouble(symbol,SYMBOL_VOLUME_STEP); 
   double free = AccountFreeMargin();
   double margin = MarketInfo(symbol,MODE_MARGINREQUIRED);
   double _lot=lot<min?min:(lot>max?max:lot);
          _lot=MathRound(_lot/step)*step;
   if(is_margin && _lot*margin>free)  _lot=0.0; //MathFloor(free/margin/step)*step;
   return(_lot);
}

Limits are not needed here, because Stop Loss and Take Profit are equal to zero at trade opening.RefreshRates() updates data at lot calculation. Of course, there is no check of connection, etc. before each entry, but that's not the point. If OrderSend sent a request, there would be a specific error: 130, 131, etc. But what I have is.

Not trying to send an order to open at all. Even in the last test, when I set a check position in the OnInit() function.

int OnInit() {
  
   int stops_level=(int)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL);
   iTrailStart=inpTrailStart;
   iTrailStart2=inpTrailStart2;
   iTrailStartL=inpTrailStartL;
   //---
   if(stops_level>0) {
      if(inpTrailStart<stops_level+3) iTrailStart=stops_level+3;
      if(inpTrailStart2<stops_level+3) iTrailStart2=stops_level+3;
      if(inpTrailStartL<stops_level+3) iTrailStartL=stops_level+3;
   }
   
   Comment("");
   EventSetMillisecondTimer(300);
   ButtonCreate("V_5",5,25,50,20,"FLAT",9,clrBlack,C'236,233,235', clrNONE,false);
   ButtonCreate("V_7",60,25,50,20,"TREND",9,clrBlack,C'236,233,235', clrNONE,false);
   ButtonCreate("Auto",115,25,50,20,"Auto",9,clrBlack,C'236,233,235',clrNONE,false);
   ObjectCreate(0,"Lot",OBJ_EDIT,0,0,0);
   ObjectSetInteger(0,"Lot",OBJPROP_CORNER,CORNER_LEFT_LOWER);
   ObjectSetInteger(0,"Lot",OBJPROP_XDISTANCE,115);
   ObjectSetInteger(0,"Lot",OBJPROP_YDISTANCE,50);
   ObjectSetString(0,"Lot",OBJPROP_TEXT,"");
   ObjectSetInteger(0,"Lot",OBJPROP_ALIGN,ALIGN_RIGHT);
   ObjectSetInteger(0,"Lot",OBJPROP_FONTSIZE,9);
   ObjectSetInteger(0,"Lot",OBJPROP_COLOR,clrBlack);
   ObjectSetInteger(0,"Lot",OBJPROP_YSIZE,20);
   ButtonCreate("V_5_buy",5,50,50,20,"BUY",9,clrBlack,C'236,233,235', clrNONE,false);
   ButtonCreate("V_5_sell",60,50,50,20,"SELL",9,clrBlack,C'236,233,235', clrNONE,false); 
     
   test_ticket=OrderSend(_Symbol,OP_BUYLIMIT,SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN),_Point,30,0.0,0.0,"NZT-48_test",iMagicNumber,0,clrNONE);
   
   return(INIT_SUCCEEDED);
}//-------------------------------------- End OnInit ---------------------------------------- 

Alexey Viktorov:

You should not have pasted the code in an image. It is impossible to read it. The problem is not in this code fragment. The problem is that some condition is not fulfilled in some input parameters and there is no notification of this fact.

It may be. But I have already double-checked everything. I don't know where to dig next.

 
Andrey Kaunov:

You think I don't check. The lot size is checked in a separate function

Limits are not needed here, because Stop Loss and Take Profit are equal to zero at trade opening.RefreshRates() updates data when calculating lot size. Of course, there is no check of connection, etc. before each entry, but that's not the point. If OrderSend sent a request, there would be a specific error: 130, 131, etc. But what I have is.

Not trying to send an order to open at all. Even in the last test, when I set a check position in the OnInit() function.


It is possible. But I have already double-checked everything. I do not know where to go next.

Look at how other orders have been implemented in the EA. I don't think the Expert Advisor only opens

at the opening ticket<0 has been set - look at the other logic, how it reacts to this in reality

Reason: