Invalid volume error?

 

Hello, I hope your making money and had an interesting day.

I would like to know a bit about how to invalid volume error, during one of my ea back-tests around 2016 the bot stopped trading caused by an invalid volume error.


I am new to meta trader five and this is one of the first successful EA's I coded and am hoping to sell on the market place, any help in this regard will be greatly appreciated.


2021.08.10 22:08:41.704    Core 1    2020.12.03 02:08:40   CTrade::OrderSend: instant buy 503.40 EURUSD at 1.21091 sl: 1.19091 [invalid volume]


double Balance = AccountInfoDouble(ACCOUNT_BALANCE);

double IncreaseLots = NormalizeDouble(Balance/50000,2);

static double Lots = IncreaseLots;

trade.Buy(Lots,NULL,Ask,0,0,NULL);
Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
Documentation on MQL5: Constants, Enumerations and Structures / Codes of Errors and Warnings / Trade Server Return Codes
  • www.mql5.com
Trade Server Return Codes - Codes of Errors and Warnings - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Files:
 
The checks a trading robot must pass before publication in the Market
The checks a trading robot must pass before publication in the Market
  • www.mql5.com
Before any product is published in the Market, it must undergo compulsory preliminary checks in order to ensure a uniform quality standard. This article considers the most frequent errors made by developers in their technical indicators and trading robots. An also shows how to self-test a product before sending it to the Market.
 

Thank you, the ea is now working.

double IncreaseLots = NormalizeDouble(Balance/10000,2);

double min_volume = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN),_Digits);
   
   double max_volume = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MAX),_Digits);
   
   if(IncreaseLots > max_volume)
   {
   
   IncreaseLots = max_volume;
   }
Files:
Reason: