Unit testing the boring bits of your EA before they touch money
Most EA bugs I've seen weren't in the clever part. They were in the plumbing. Lot size rounding, pip size on JPY pairs vs everything else, a stop calculated on the wrong side for shorts, a session check that breaks across midnight.
These are exactly the kind of things you can test without the market. Pull the helper functions out so they take inputs and return outputs, then feed them known cases and check the answers. Lot size for a given balance, risk and stop on EURUSD, USDJPY and gold. Stop price for a long and a short. Session check at 23:59 and 00:01. That sort of thing.
In MQL it's a bit clunky, there's no proper test framework built in, but a script that calls your functions with fixed inputs and prints pass or fail does the job. In Python it's easy with pytest.
I'd add a test every time you find a bug. Then that bug can't quietly come back after you change something else.
It sounds like overkill for a small EA. It isn't, honestly. The stuff that blows up accounts is usually one wrong sign or one wrong multiplier, and tests catch those in seconds.
Unit testing the boring bits of your EA before they touch money
Re: Unit testing the boring bits of your EA before they touch money
A good set of cases to include is the edge of the broker's limits. Minimum lot, maximum lot, lot step, and stop level. If your risk calc gives 0.004 lots and the minimum is 0.01, what does the function do? Round up and over-risk, or skip the trade? Either can be right, but it should be a choice you made, not an accident. Same for a stop distance that comes out smaller than the broker's stop level. Write the expected answer in the test so the next time you change the function, you'll see straight away if the behaviour shifted.
It’s Fairman 
Re: Unit testing the boring bits of your EA before they touch money
For anything that depends on account currency, test with a couple of different ones. Pip value for a USD account on EURGBP isn't the same as for a GBP account, and code that assumes USD everywhere tends to break the moment someone runs it on a EUR or GBP account. If you share your EA or sell it, that's going to happen sooner or later, so build those cases in early. JPY quote pairs and gold deserve their own test cases too, since pip size and contract size are where a lot of these bugs live. One wrong decimal there can multiply risk by ten or a hundred.
It’s Fairman 