Error Message on EA Run

 

Dear all

 

I am running an EA on a Strategy tester on MT4 and it runs okay but it doesn't executes any trades.

 

I get an error message like this below:

 

2015.06.04 22:55:31.858 1993.09.21 23:00  Stark_EA_prototype AUDUSD,M30: OrderSend error 131

2015.06.04 22:55:28.017 1993.09.14 23:00  Stark_EA_prototype AUDUSD,M30: Alert: Ordersend failed with error: 131

2015.06.04 22:55:28.017 1993.09.14 23:00  Stark_EA_prototype AUDUSD,M30: OrderSend error 131

2015.06.04 22:55:27.967 Stark_EA_prototype inputs: passwordInp=61305968; trailingStopPipsInp=20; stopLossPipsInp=50; movingAveragePeriod=13; movingAverageShift=0; movingAverageMethod=1; movingAverageAppliedPrice=0; maxAllowedSlippageInp=10; startTradingHour=0; endTradingHour=24; riskPercent=10; leverageMultiplier=5; initialHighInput=0; initialLowInput=0; movingAverageGradient=15; usedStrategy=1; reverseOnStop=1; backTestingGradient=1; 

2015.06.04 22:55:27.798 TestGenerator: current spread 29 used


Any ideas as why this may be happening?

 

Much appreciated in advance.

Cheers

Stark

 
ERR_INVALID_TRADE_VOLUME                    131

 

 Check your lot size. 

 

Thanks a lot Penic. I will have a look again at the trade volume calculation.

 

Any ideas on a function so that only 10% of available balance is traded on any one position would be welcomed? 


Regards 

Stark 

 

Search through the Codebase for "money management" or "risk calculation".

You will find number of complete source code examples. 

 

Try to normalize the lot size before using it in the OrderSend() function to something like this ...

double lot = NormalizeDouble(Lots, LotDigits);

 Where LotDigits represents the number of digits in the lot representation after the decimal point. It is normally equal to 2 or 1 in some cases and rarely 3.

 

Thanks all for you kind and helpful feedback.

Problem is now resolved,

Stark

Reason: