Can anyone shed some light on this?
I`m geting zero divide error when my EA calculates lot size. It only happens in Strategy tester on EURUSD and USDJPY when testing in tick mode ( control points works fine)
This is the code I use:
double lot = MathFloor(((risk / NumberOfOrders)) / (((openPrice-sl) / Point) * MarketInfo(Symbol(),MODE_TICKVALUE)) / LotStep)*LotStep;
Also tried this and get the same result
double lot = NormalizeDouble((risk/ NumberOfOrders)/(openPrice-sl)*Point/(MarketInfo(Symbol(), MODE_TICKVALUE)),2);
Looks to me that for some reason Point and MODE_TICKVALUE return 0 values?
Any help much appreciated.
No not NumberOfOrders.
It was TICKVALUE got it sorted now anyway, Thanks
Speaking from a programming side of things (not MQL, but I have an Associates Degree in computers), a zero error is a pain in the ass. The best way to resolve it, if it pops up, is to test for the possibility of the item you are dividing for being a zero, usually with an if/else type of statement, like the following
do this code
To add comments, please log in or register