It is not bugged. The max lots is the current free margin on your account all over the margin size for 1.0 lot. Note that the max permitted lot on the broker means a different thing to the max available lot that you can trade with.
And sometimes the max sell lot you can trade with can be different to the max buy lot that you can trade with.
double LotCheckBuy(){ double margin_for_one_lot; static double lotSize; double currentMargin = AccountInfoDouble(ACCOUNT_MARGIN_FREE); if (!OrderCalcMargin(ORDER_TYPE_BUY, _Symbol, 1.0, SymbolInfoDouble(_Symbol, SYMBOL_ASK), margin_for_one_lot)) Print("Could not obtain the margin required to open 1 lot"); lotSize = currentMargin / margin_for_one_lot; double minLot = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN); double maxLot = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX); double lotStep = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP); lotSize = MathMax(minLot, MathFloor(lotSize / lotStep) * lotStep); return lotSize; } double LotCheckSell(){ double margin_for_one_lot; static double lotSize; double currentMargin = AccountInfoDouble(ACCOUNT_MARGIN_FREE); if (!OrderCalcMargin(ORDER_TYPE_SELL, _Symbol, 1.0, SymbolInfoDouble(_Symbol, SYMBOL_BID), margin_for_one_lot)) Print("Could not obtain the margin required to open 1 lot"); lotSize = currentMargin / margin_for_one_lot; double minLot = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN); double maxLot = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX); double lotStep = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP); lotSize = MathMax(minLot, MathFloor(lotSize / lotStep) * lotStep); return lotSize; }
the margin size is supposed to be very high when the contract size is just 1, in Forex the contract size is typically 100,000
I'm not following.
I wish to use AccountInfo.MaxLotCheck
It's returning 0 as the max lot size I can trade.
That's incorrect. The max I can trade is around 0.1 lots. So there's a bug.
And the problem seems to be with the OrderCalcMargin that it's using.
Your functions also calculate the wrong lot size and are returning 0.01 always for me in strategy tester.
On a live chart, both methods work fine and return around 0.1
I'm not following.
I wish to use AccountInfo.MaxLotCheck
It's returning 0 as the max lot size I can trade.
That's incorrect. The max I can trade is around 0.1 lots. So there's a bug.
And the problem seems to be with the OrderCalcMargin that it's using.
Your functions also calculate the wrong lot size and are returning 0.01 always for me in strategy tester.
On a live chart, both methods work fine and return around 0.1
the strategy tester needs to be configured with the leverage used on your account, and with real ticks model
Still need help here.
I've pinned down the issue with OrderCalcMargin so I hope a dev can take a closer look.
In strategy tester it seems to be considering the '30' margin rate as x30 (3000%) margin requirement for 1 lot and I don't know what it's even doing in the real account with it since it's returning an ok result for me.
Leverage in both broker account and strategy tester is 1:1 for this symbol
In a real account I get a result of "47802.98" margin required for 1 lot
In strategy tester I get a result of "1357662.65" margin required for 1 lot
Parameters used: OrderCalcMargin(ORDER_TYPE_BUY, _Symbol, 1, 50000, marginRequiredCandidate);
My account is in euros.
I think in the real account it's relying on the EUR/LOT requirement and not the '30' which is correct since I have 1:1 leverage, the euros amount represent the current BTCUSD price.
In strategy tester there is no EUR/LOT so it's relying on '30' incorrectly and ignoring my 1:1 leverage that I set.
If you're using 1:1 leverage, you'll need a huge account size to execute positions with very small lot size.
The open price is just for the test.
The symbol is BTCUSD
I don't need huge account sizes. As you can see in my real account result, I need exactly the amount of the asset price to buy 1 lot. (50000 usd = 47802.98 euros). which is fine.
Now that I come to think of it, this may be a broker issue. I think they should set "1" as margin requirement and not 30. I'll speak to them about it.The open price is just for the test.
The symbol is BTCUSD
I don't need huge account sizes. As you can see in my real account result, I need exactly the amount of the asset price to buy 1 lot. (50000 usd = 47802.98 euros). which is fine.
Now that I come to think of it, this may be a broker issue. I think they should set "1" as margin requirement and not 30. I'll speak to them about it.Yes email the broker about it. In fact, the margin rate should be 100.0 for 1:1 leverage. It would be 1 for 1:100 leverage.
Yes email the broker about it. In fact, the margin rate should be 100.0 for 1:1 leverage. It would be 1 for 1:100 leverage.
All of their other symbols are showing 1.
And if I change manually to 1 for the strategy tester then I get the same margin requirement result. And if I increase the leverage it changes accordingly.
At least I finally figured it out this was driving me crazy.
Well, the broker got back to me.
They consider '30' as 300% margin requirement and have no intention of changing it.
Don't know if that's true or not, but OrderCalcMargin considers it 3000% in strategy tester.
Would be nice if a dev had a look.
According to your screenshot, your symbol is using the "CFD Leverage" calculation method. So, according to the documentation, that means that the margin is calculated as:
SYMBOL_CALC_MODE_CFDLEVERAGE
CFD Leverage mode - calculation of margin and profit for CFD at leverage trading
Margin: (Lots * ContractSize * MarketPrice) / Leverage * Margin_Rate
Profit: (close_price-open_price) * Contract_Size * Lots
And also according to the documentation, the "Margin Rate" value is taken as is, without any scaling.
That means that 30 is indeed 3000% (not 300%), so the onus is on the broker to correct the value, not the devs.
Leverage in both broker account and strategy tester is 1:1 for this symbol
Absolutely correct. 30 is indeed 3000%. The Strategy Tester is handling it correctly. The broker must not have set the correct values on the contract specifications compared to their internal calculations.
It will probably be an uphill battle to convince the broker that they did it incorrectly. They will most definitely consider you in the wrong instead of themselves.
However, on the Strategy Tester, you can edit the contract specifications to a degree, so try to change it to match their internal calculations ...

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello.
I'm using latest MT5 terminal. (5.0.0 build 4620)
I'm trying to use this function with strategy tester.
Symbol: BTCUSD
Account size: 10000
Leverage: 1:1
Here's an example output when I'm trying to debug it inside Trade\AccountInfo.mqh (the MaxLotCheck function):
Output:
Leverage: 1
Contract size: 1.0
Price: 88600.06
Margin Calculated: 2496198.23
Symbol specs:
Why is the margin I'm getting so high??