Automatic validator - problems

 

I try to update the EA version and get an error.

The same EA is in the strategy tester.


I am also writing EAs for MT4 at the same time, everything is OK there. Code for 4 and 5 EAs is the same, the only difference is include file (they are different for 4 and 5).

Last time I updated this EA, it was in January and everything was OK.

Software version - MetaTrader 5 x64 build 2025 started (MetaQuotes Software Corp.)

- Terminal Windows 10 (build 14393) x64, IE 11, UAC, Intel Celeron N2815 @ 1.86GHz, Memory: 1866 / 3967 Mb, Disk: 5 / 35 Gb, GMT+3

 
Uladzimir Kirychenka:

I try to update the EA version and get an error.

The same EA is in the strategy tester.


I am also writing EAs for MT4 at the same time, everything is OK there. Code for 4 and 5 EAs is the same, the only difference is include file (they are different for 4 and 5).

Last time I updated this EA, it was in January and everything was OK.

Software version - MetaTrader 5 x64 build 2025 started (MetaQuotes Software Corp.)

- Terminal Windows 10 (build 14393) x64, IE 11, UAC, Intel Celeron N2815 @ 1.86GHz, Memory: 1866 / 3967 Mb, Disk: 5 / 35 Gb, GMT+3

Pretend to be an idiot and put in a $1 deposit or a 100500 lot and see if there will be any trades. And will there be alerts that only an idiot would set such parameters.

 
Alexey Viktorov:

Pretend you are an idiot and put a deposit of 1$ or lot 100500 and check whether there will be trades. And whether there will be alerts that only an idiot can set such parameters.

The same problem. Tried it - doesn't help ). Can't update since 13 April. If I check everything and everything - I get only one inscription on all symbols "trehe are no trading operations". If I do not check everything I get an error - not enough equity to open the position. The version for MT4, as well as for the TS author updated without any problems.

123

I would see in the picture the minimum lot is 2000, balance is 10000 and clearly there is not enough money to open the position. I do not pass the check anyway.

What to do in such cases?

 

Of course there will be no deals. And what are the alerts supposed to be? I have only in OnInit if lot size is not in range SYMBOL_VOLUME_MIN and SYMBOL_VOLUME_MAX, then initialization error INIT_PARAMETERS_INCORRECT

 
Uladzimir Kirychenka:

Of course there will be no deals. And what are the alerts supposed to be? I have only in OnInit if lot size is not in range SYMBOL_VOLUME_MIN and SYMBOL_VOLUME_MAX, then initialization error INIT_PARAMETERS_INCORRECT

I remember I had about the same thing back then with the moderators checking after auto-checking. In case of incorrect parameters, OnInit also terminated with code INIT_PARAMETERS_INCORRECT. And auto-check generated the same error that there was no trade operation. So, the moderator advised me not to terminate OnInit() with this code, but to issue an Alert.

 

Probably once a month, someone brings it up. It's been going on for a while now.

The thing is that when trading (in real life) not only the size of the balance may change, but also the lot size.

And during testing the deposit size (from 1 to 10000000) or lot size (from 1000000 to 0.01) can vary.

Therefore, these checks should be performed not only once at OnInit, but permanently, in the loop (for example, in OnTick).

To avoid the log overflow, it is necessary to output the warning(Print Message or Alert) only once.

 
Uladzimir Kirychenka:

Of course there will be no deals. And what are the alerts supposed to be? I have only in OnInit if lot size is not in range SYMBOL_VOLUME_MIN and SYMBOL_VOLUME_MAX, then initialization error INIT_PARAMETERS_INCORRECT

I understand that it's very hard to pretend to be an idiot, but this skill sometimes helps. Try again. You set an EA, with $1 in your account, set a lot of 100500 and wait... You wait a day, a second, a third... then you start to resent, "What did I pay for. Why isn't this shit working?" and no one says anything, no one wants to say something like "You're an idiot... You can't work in Forex market with such a deposit. Only an idiot would put a lot 100500"... That's the way it is.

 
Petros Shatakhtsyan:

Probably once a month, someone brings it up. It's been going on for a while now.

The thing is that when trading (in real life) not only the size of the balance may change, but also the lot size.

And during testing the deposit size (from 1 to 10000000) or lot size (from 1000000 to 0.01) can vary.

Therefore, these checks should be performed not only once at OnInit, but permanently, in the loop (for example, in OnTick).

The warning (Print Message or Alert) must be printed only once to avoid the log overflow.

Even a very simple code cannot pass the validation. It seems to satisfy the conditions you mention.

void OnTick()
  {
   ENUM_POSITION_TYPE PosType=POSITION_TYPE_SELL;
   MqlTradeRequest request;
   MqlTradeResult result;
   MqlTradeCheckResult check;
   ZeroMemory(request);
   ZeroMemory(result);
   ZeroMemory(check);
   long digit;
   double point,Bid;
   SymbolInfoDouble(_Symbol,SYMBOL_BID,Bid);
   request.type   = ORDER_TYPE_SELL;
   request.price  = Bid;
   request.action = TRADE_ACTION_DEAL;
   request.symbol = _Symbol;
   request.volume = SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
   request.sl=0;
   request.tp=0;
   request.deviation=10;
   request.magic=55555;
   request.comment=NULL;
   request.type_filling=0;
   if(PositionsTotal()==0
   &&CheckMoneyForTrade(_Symbol,SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN),ORDER_TYPE_SELL)==true
   ){
   OrderSend(request,result);
   }else{
      ExtExpert.Deinit();
      return;
   }
  }
  bool CheckMoneyForTrade(string symb,double lots,ENUM_ORDER_TYPE type)
  {
//--- получим цену открытия
   MqlTick mqltick;
   SymbolInfoTick(symb,mqltick);
   double price=mqltick.ask;
   if(type==ORDER_TYPE_SELL)
      price=mqltick.bid;
//--- значения необходимой и свободной маржи
   double margin,free_margin=AccountInfoDouble(ACCOUNT_MARGIN_FREE);
   //--- вызовем функцию проверки
   if(!OrderCalcMargin(type,symb,lots,price,margin))
     {
      //--- что-то пошло не так, сообщим и вернем false
      Print("Error in ",__FUNCTION__," code=",GetLastError());
      return(false);
     }
   //--- если не хватает средств на проведение операции
   if(margin>free_margin)
     {
      //--- сообщим об ошибке и вернем false
      Print("Not enough money for ",EnumToString(type)," ",lots," ",symb," Error code=",GetLastError());
      return(false);
     }
//--- проверка прошла успешно
   return(true);
  }
with money check - there are no trading operations, without check - not enough money
 
Petros Shatakhtsyan:

Probably once a month, someone brings it up. It's been going on for a while now.

The thing is that when trading (in real life) not only the size of the balance may change, but also the lot size.

And during testing the deposit size (from 1 to 10000000) or lot size (from 1000000 to 0.01) can vary.

Therefore, these checks should be performed not only once at OnInit, but permanently, in the loop (for example, in OnTick).

The warning (Print Message or Alert) must be output only once to avoid log overflow.

These checks (LotMin, LotMax, LotNormalizeStep, check balance, OrderCheck) are performed each time a position is opened. And the check of lot only in OnInit. I don't know the logic of checking the balance in OnInit.

PS: Alert doesn't save me from validator errors ((((((((((

 
Uladzimir Kirychenka:

These checks (LotMin, LotMax, LotNormalizeStep, check balance, OrderCheck) are performed each time a position is opened. And onInit only checks the lot. I don't know the logic of checking the balance in OnInit.

PS: Alert doesn't save from validator errors ((((((((((

Validator has no errors :)

The validator just shows that in the provided code

  • there are no full-fledged checks
  • there is no error handling
The validator shows that the so-called code writer has never put himself in the place of the user.

 
Vladimir Karputov:

The validator has no errors :)

The validator just shows that the code provided

  • there are no full-fledged checks
  • There is no error handling
The validator shows that the so-called code writer has never put himself/herself in the user's shoes.

))

Reason: