The error refers to https://www.mql5.com/en/articles/2555#invalid_lot
//+------------------------------------------------------------------+//| Check the correctness of the order volume |//+------------------------------------------------------------------+bool CheckVolumeValue(double volume,string &description)
Do I have to use this specific function? How do I use
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.
I would like to upload my EA-structure with simplified code - I got rid of all code which is not relevant for the topic (mostly). This upload to mql does not work either.
Is there somewhere a mistake which I don't see? The mq4-file is attachted
This is really anoying as it works in Backtests & live trading...
If we tell you what you need, you can't code it. We are willing to help you when you post your attempt (using code button ) and state the nature of your problem, but we are not going to debug your hundreds of lines of code
...
externdouble LotsExponent = 1.40;
...
if(OpenTicketsBuy > 0) {
NextLots_Buy = NormalizeDouble(YoungestOL_Buy * LotsExponent,2);
...
if(OpenTicketsSell > 0) {
NextLots_Sell = NormalizeDouble(YoungestOL_Sell * LotsExponent,2);
...
if(...) { YoungestOL_Buy = OrderLots();
...
if(...) { YoungestOL_Sell = OrderLots();
...
// IN CASES WHEN OrderLots() == SymbolInfoDouble(Pair,SYMBOL_VOLUME_MIN) FOR EXAMPLE = 0.01
// AND SymbolInfoDouble(Pair,SYMBOL_VOLUME_STEP) == SymbolInfoDouble(Pair,SYMBOL_VOLUME_MIN) FOR EXAMPLE = 0.01
// THEN
// PINK CODE WILL LEAD TO INCORRECT ORDER VOLUME
// BECAUSE
// 0.01 * 1.4 = 0.014 BUT ALLOWED VOLUMES ARE 0.01 0.02 AND SO ON <FOR THIS EXAMPLE>
//
About using NormalizeDouble(..) in cases other than prices for sending orders
======================================================================= Most cases of using NormalizeDouble(..) at least are useless Many => harmful like this => mql5.com/ru/forum/160683/page1049 =======================================================================
Let's say my mini account has margin of $10,000, and i want to risk 2% on the next trade (that is, simply use $200 to buy of contracts). You don't need to calculate the lot size here as you see
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
OrderSend
use Print("Lot size: "+Lots); before OrderSend function and observe the lot size in the terminal expert log.
use Print("Lot size: "+Lots); before OrderSend function and observe the lot size in the terminal expert log.
Hello,
thanks for your reply.
In the backtest the EA behaves like it's supposed to be:
2024.03.14 23:43:01.172 2021.02.05 17:00:00 TestEA v1.00 EURNZD,H1: open #11 sell 0.01 EURNZD at 1.67230 ok
2024.03.14 23:43:01.172 2021.02.05 17:00:00 TestEA v1.00 EURNZD,H1: Enter sell 1 trade for EURNZD | lots: 0.01
I tried my code with 1.000.000 € and 1.000 € as deposit. The EA-calculations are correct.
Does someone has some other thoughts?
Hello,
Does someone has some other thoughts?
Hello,
Try to apply this check:
Hello,
Try to apply this check:
Hello,
thanks for the idea. I already implemented this.
The error refers to https://www.mql5.com/en/articles/2555#invalid_lot
Do I have to use this specific function? How do I use
&descriptionThis is an input. What do I have to insert here?
Maybe this helps? Bu honestly I don't think so.
Normally I use such a code to cut digits
Is this something different to your code?
Hello,
I would like to upload my EA-structure with simplified code - I got rid of all code which is not relevant for the topic (mostly). This upload to mql does not work either.
Is there somewhere a mistake which I don't see? The mq4-file is attachted
This is really anoying as it works in Backtests & live trading...
I appreciate any help! :-)
test on EURUSD,H1 2021.04.05 16:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 16:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 16:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 16:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 16:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 16:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 16:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 16:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 16:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 16:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 20:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 20:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 20:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 20:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 20:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 20:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 20:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 20:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 20:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.05 20:00:00 Test_EA EURUSD,H1: OrderSend error 131 2021.04.06 00:00:00 Test_EA EURUSD,H1: OrderSend error 131 strategy tester report 7 total trades
About using NormalizeDouble(..) in cases other than prices for sending orders
=======================================================================
Most cases of using NormalizeDouble(..) at least are useless
Many => harmful like this => mql5.com/ru/forum/160683/page1049
=======================================================================
This statement is similar to
if ( lots < minLot ) lots = minLot ;Both are very popular but very incorrect
Because lead to the possibility of taking more risk than allowed by risk-management calculations of =lots=
For example when lots = 0.01 and minLot = 0.10 then accepted risk will be 10 times greater than required
Must be
Links
https://www.mql5.com/en/forum/111230
https://www.mql5.com/en/forum/112782
https://www.mql5.com/en/forum/132147
https://www.mql5.com/en/forum/336236