MT4 Market validation: tester deposit 1.00 and 0.20 lots - how can an EA open at least one trade?

Hello, I am preparing my first MetaTrader 4 Expert Advisor for the Market (draft product ID 201415) and the automatic validation fails. I would like to understand how the validator tests MT4 Expert Advisors.


Version 1.30: the report shows 22 errors on NZDUSD,H1: "not enough money for buy 0.20 NZDUSD" and OrderSend error 134. The tester log shows PrevBalance 1.00, PrevEquity 1.00 and about 115 of required margin for 0.20 lots. On EURUSD,H1 the report says "no trading operations".


Version 1.31: following the article "The checks a trading robot must pass before publication in the Market", I added a free margin check (AccountFreeMarginCheck) and the EA no longer sends an order when funds are insufficient. The "not enough money" errors are gone, but now all four tests (EURUSD H1, NZDUSD H1, GBPUSD M30, XAUUSD Daily) report "no trading operations", because with a balance of 1.00 no order can be opened.


My questions:

1) Is a tester deposit of 1.00 the intended condition of the Market validator for MT4 Expert Advisors?

2) The validator seems to use 0.20 lots, although my EA has a fixed lot input of 0.10. Does the validator change the lot size?

3) How should an EA behave so that it passes validation with such a small deposit, without breaking the rule that forbids limits by account size?


The EA has no DLL calls, no time or account limits, and trades only inside a configurable hour window. Thank you for any advice.

I can't confirm how the validator picks its deposit or lot size. That isn't documented and MetaQuotes may change it. What usually gets an EA through is the approach below, but treat it as a common pattern, not a guarantee.

The usual way through is to shrink the lot instead of skipping the trade. Before each OrderSend, take your input lot and step it down until it fits the free margin, down to MODE_MINLOT. Skip only if even the minimum lot doesn't fit. That isn't a limit by account size: the EA trades the same way and only caps the volume at what the margin allows. The checks article describes it the same way, checking volume and margin before sending.

// Shrink the lot to what free margin allows (MQL4)
double FitLot(double wanted, int type)
{
double minLot = MarketInfo(Symbol(), MODE_MINLOT);
double maxLot = MarketInfo(Symbol(), MODE_MAXLOT);
double step = MarketInfo(Symbol(), MODE_LOTSTEP);
if(step <= 0 || minLot <= 0) return(0.0);
int digits = (int)MathMax(0, MathCeil(-MathLog10(step) - 1e-9)); // decimals of the lot step

double lot = MathMin(MathMax(wanted, minLot), maxLot);
int steps = (int)MathFloor(lot / step + 1e-7); // integer steps: no float drift

for(; steps * step >= minLot - step * 0.5; steps--)
{
lot = NormalizeDouble(steps * step, digits);
ResetLastError();
double freeAfter = AccountFreeMarginCheck(Symbol(), type, lot);
if(freeAfter > 0 && GetLastError() != ERR_NOT_ENOUGH_MONEY)
return(lot);
}
return(0.0); // even min lot doesn't fit: don't send
}

Two things to check in your logs:

  • Where does 0.20 come from? If your input is 0.10 and the order still goes out at 0.20, look for anything that rescales the lot (risk-based sizing, a multiplier, or a broker min lot of 0.20 on that symbol). I wouldn't assume the validator overrides inputs.
  • "No trading operations" on EURUSD H1 also appeared in 1.30, before the margin check existed. Your hour window may not overlap the validator's test period or server time. Try running the EA with the window fully open in your own tester on those four symbol and timeframe pairs, and make sure it opens at least one trade there.