Hey, I have been developing an EA for a while now and wanted to publish it on the Metatrader 4 market.
The EA works %100 on live, demo and back testing. But when I Send the EA in for product valuation I get a report stating "ordersend error 131"
I have been through the coding and read up about error 131 and I can't find any problem.
All my lots and lot sizes have a values that are reasonable and nothing odd.
If anyone has a solution or has experienced the same and figured out how to fix this small issue, Please inform me.
Here is what I get
Regards Franzel
as the ea is working on live, brackets are set correctly (cross-check / count number of brackets open/closed)?
Did you check the lot sizes (especially the micro-lots?) - is the lot size normalized? Any problem with lot sizes (different brokers, account (cent), currencies might cause issues) will cause such an error.
--> see https://www.mql5.com/en/docs/convert/normalizedouble
- www.mql5.com
as the ea is working on live, brackets are set correctly (cross-check / count number of brackets open/closed)?
Did you check the lot sizes (especially the micro-lots?) - is the lot size normalized? Any problem with lot sizes (different brokers, account (cent), currencies might cause issues) will cause such an error.
--> see https://www.mql5.com/en/docs/convert/normalizedouble
thnx for the reply.
Will have a look at it. It might be because I have only been using micro-lots with two brokers. thnx for the input.
This will help me greatly
Hey, I have been developing an EA for a while now and wanted to publish it on the Metatrader 4 market.
The EA works %100 on live, demo and back testing. But when I Send the EA in for product valuation I get a report stating "ordersend error 131"
I have been through the coding and read up about error 131 and I can't find any problem.
All my lots and lot sizes have a values that are reasonable and nothing odd.
If anyone has a solution or has experienced the same and figured out how to fix this small issue, Please inform me.
Here is what I get
Please read the documentation on:
131
ERR_INVALID_TRADE_VOLUME
Invalid trade volume
Forum on trading, automated trading systems and testing trading strategies
My EA Uploaded to the market——Feedback the automatic test results,what happened?
Fernando Carreiro, 2017.08.23 15:49
Your code should always check the broker's conditions for allowable volume/lots. Use the "SymbolInfoDouble()" function to obtain the correct details for:
SYMBOL_VOLUME_MIN
Minimal volume for a deal
double
SYMBOL_VOLUME_MAX
Maximal volume for a deal
double
SYMBOL_VOLUME_STEP
Minimal volume change step for deal execution
double
SYMBOL_VOLUME_LIMIT
Maximum allowed aggregate volume of an open position and pending orders in one direction (buy or sell) for the symbol. For example, with the limitation of 5 lots, you can have an open buy position with the volume of 5 lots and place a pending order Sell Limit with the volume of 5 lots. But in this case you cannot place a Buy Limit pending order (since the total volume in one direction will exceed the limitation) or place Sell Limit with the volume more than 5 lots.
double
Forum on trading, automated trading systems and testing trading strategies
How to calculate lots using multiplier according to number of opened orders?
Fernando Carreiro, 2017.09.01 21:57
Don't use NormalizeDouble(). Here is some guidance (code is untested, just serves as example):
// Variables for Symbol Volume Conditions double dblLotsMinimum = SymbolInfoDouble( _Symbol, SYMBOL_VOLUME_MIN ), dblLotsMaximum = SymbolInfoDouble( _Symbol, SYMBOL_VOLUME_MAX ), dblLotsStep = SymbolInfoDouble( _Symbol, SYMBOL_VOLUME_STEP ); // Variables for Geometric Progression double dblGeoRatio = 2.8, dblGeoInit = dblLotsMinimum; // Calculate Next Geometric Element double dblGeoNext = dblGeoInit * pow( dblGeoRatio, intOrderCount + 1 ); // Adjust Volume for allowable conditions double dblLotsNext = fmin( dblLotsMaximum, // Prevent too greater volume fmax( dblLotsMinimum, // Prevent too smaller volume round( dblGeoNext / dblLotsStep ) * dblLotsStep ) ); // Align to Step value
Please read the documentation on:
131
ERR_INVALID_TRADE_VOLUME
Invalid trade volume
Tnx for the reply.
What I can make out is that "NormalizeDouble" is a big issue?
And looking at this part of the coding it is causing the issue?
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
/*The function for calculation the trade volume, returns lot size*/
double CalculateVolume(double init_lots,int index=0)
{
double volume=init_lots;
if(AddLots)
volume=init_lots+AddLotsSize;
if(MultiplyLots)
volume=init_lots*MuliplyLotSize;
if(ManualPositions)
{
double lots[25];
lots[0] = Lot1; lots[1] = Lot2; lots[2] = Lot3; lots[3] = Lot4; lots[4] = Lot5; lots[5] = Lot6; lots[6] = Lot7;
lots[7] = Lot8; lots[8] = Lot9; lots[9] = Lot10; lots[10] = Lot11; lots[11] = Lot12; lots[12] = Lot13;
lots[13] = Lot14; lots[14] = Lot15; lots[15] = Lot16; lots[16] = Lot17; lots[17] = Lot18; lots[18] = Lot19;
lots[19] = Lot20; lots[20] = Lot21; lots[21] = Lot22; lots[22] = Lot23; lots[23] = Lot24; lots[24] = Lot25;
int n=MathMax(0,MathMin(index,ArraySize(lots)-1));
volume=lots[n];
}
int LS=0;
double LotStep=MarketInfo(Symbol(),MODE_LOTSTEP);
if(LotStep == 0.01 || LotStep==0) LS = 2;
if(LotStep == 0.1) LS = 1;
if(LotStep == 1) LS = 0;
volume=NormalizeDouble(volume,LS);
if(volume<MarketInfo(Symbol(),MODE_MINLOT))volume=MarketInfo(Symbol(),MODE_MINLOT);
if(volume>MarketInfo(Symbol(),MODE_MAXLOT))volume=MarketInfo(Symbol(),MODE_MAXLOT);
return volume;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
What I can make out is that "NormalizeDouble" is a big issue?
And looking at this part of the coding it is causing the issue?
int LS=0;
double LotStep=MarketInfo(Symbol(),MODE_LOTSTEP);
if(LotStep == 0.01 || LotStep==0) LS = 2;
if(LotStep == 0.1) LS = 1;
if(LotStep == 1) LS = 0;
volume=NormalizeDouble(volume,LS);
if(volume<MarketInfo(Symbol(),MODE_MINLOT))volume=MarketInfo(Symbol(),MODE_MINLOT);
if(volume>MarketInfo(Symbol(),MODE_MAXLOT))volume=MarketInfo(Symbol(),MODE_MAXLOT);
Why are you ignoring the advice and the example code provided?
I have already stated NOT to use NormalizeDouble() and even provided code showing you the correct way to do it.
Please see my previous post and please always use the SRC button to add code as I have done now for your quote.
PS! The example code I provided works for both MQL4 and MQL5!
Why are you ignoring the advice and the example code provided?
I have already stated NOT to use NormalizeDouble() and even provided code showing you the correct way to do it.
Please see my previous post and please always use the SRC button to add code as I have done now for your quote.
PS! The example code I provided works for both MQL4 and MQL5!
This is the original coding. I am just pointing that I now found the problem.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hey, I have been developing an EA for a while now and wanted to publish it on the Metatrader 4 market.
The EA works %100 on live, demo and back testing. But when I Send the EA in for product valuation I get a report stating "ordersend error 131"
I have been through the coding and read up about error 131 and I can't find any problem.
All my lots and lot sizes have a values that are reasonable and nothing odd.
If anyone has a solution or has experienced the same and figured out how to fix this small issue, Please inform me.
Here is what I get
Regards Franzel