OrderCalcMargin returns TRUE with zero required margin for GOLD CFD.

Hello,

I am investigating a recorded margin-calculation observation in the MetaTrader 5 Strategy Tester.

The native OrderCalcMargin() function returned TRUE, but the required margin was exactly 0.0, with an immediate GetLastError() value of 0.

Recorded environment and inputs

Property Recorded value
Environment MetaTrader 5 Strategy Tester
Broker server FxPro-MT5 Demo
Account currency USD
Account mode Hedging
Leverage 1:100
Symbol GOLD
Calculation mode CFD
Contract size 100
Tick size 0.01
Order type BUY
Volume 0.01 lot
Calculation price 4081.6899999999996
Initial margin amount 0
Initial margin rate Approximately 0.000001
Function result TRUE
Required margin 0.0
Immediate error 0

Using the published CFD margin formula, these recorded inputs produce an arithmetic estimate of approximately 0.00408169 USD. This is not being substituted for the native result.

The diagnostic records the margin result before formatting. No trading order was submitted. The risk engine rejected the non-positive native required margin.

Technical questions

  1. Does OrderCalcMargin() internally round small margin amounts to zero based on currency precision in the Strategy Tester?

  2. If so, what documented precision or rounding rule applies?

  3. If not, could this result be caused by symbol margin configuration or a Strategy Tester calculation issue?

  4. What additional diagnostic evidence would be required to distinguish these possibilities?

Available evidence

File: SEQ027_CLEAN_MARGIN_READER_20261008_000000_40.csv

SHA256:
9AEB99D44FEACA4B82DCF69DC811DBFC7B16D7E394E8E39969969A69443CE73D

CSV line 41 corresponds to Journal line 71.

Thank you.

@saratradeco, contact your broker-dealer to find out whether margin specifications are fully supported in their demo accounts.


@saratradeco Could you share the code that reads the margin rates and calls OrderCalcMargin(), plus your terminal and tester agent build numbers?

Since you’ve already checked the result before formatting, the next useful comparison would be 0.01, 0.10 and 1.00 lots, where those volumes are valid for the symbol. Keep the symbol, order type and price unchanged. For each calculation, log the return value, margin and initial margin rate at full precision, and check that SymbolInfoMarginRate() succeeds. No orders need to be sent.

This would show whether only small volumes return zero. It wouldn’t prove rounding, and the documentation doesn’t specify an internal rounding rule, so the cause is still open.

saratradeco - Trader's profile
saratradeco - Trader's profile
  • 2026.10.10
  • www.mql5.com
Trader's profile
Insufficient information to answer. We need code, logs and settings used in the Strategy Tester.