Good candidates for unit tests:
- Position size calculation, with edge cases: very small balance, minimum lot, volume step, metals.
- Pip size and point conversions for 2, 3, 4 and 5 digit symbols.
- Time filter logic around clock changes.
- Stop distance validation against stop level.
Example test case: balance 2,000, risk 1%, stop 7 pips, EURUSD, volume step 0.01. Expected lots around 0.28 to 0.31, depending on the exchange rate.
Run the tests after every change to the include file.
Over time, a small test suite becomes a safety net that makes changes less risky, especially when the code is shared between several EAs.
Does anyone write tests for their MQL code?