zero divide in the "LotSize_Buy" variable? Thing is, I never see it within ST? Just popped up now on the first demo trade....
It says it found it the - MarketInfo(_Symbol,MODE_TICKVALUE) equal to zero ?!
- Need Help Zero Divide Error
- zero divide error
I don't see what's wrong with it?
double loss_for_1_lot = pips_to_bsl / ts * tv ;
2014.10.14 09:20:04.797 2014.08.20 18:06 TF - v2.7.1 USDCAD,H1: loss_for_1_lot == 0.003310000000000146 / 1e-005.0 * 0.9122922254456551 = 301.9687266225252
LotSize_Buy4 = MathFloor( risk_amount4 / loss_for_1_lot/ Lot_Step) * Lot_Step; 2014.10.14 09:20:04.797 2014.08.20 18:06 TF - v2.7.1 USDCAD,H1: LotSize_Buy == 39.08068500000001 / 301.9687266225252 / 0.1 ) * 0.1 = 0.1
Forgive me, maths is not my strongest point. But I honestly cannot see how this formula doesn't work considering I am updating my EA which I have been using live for over a year now with no zero divide errors until now. Now that I place x4 trades instead of partially closing one...
Is all I can think of?
double loss_for_1_lot = pips_to_bsl / ( ts * tv ); // brackets?
Just place this before the line:
Print("LotSize_Buy == ", risk_amount," / ", loss_for_1_lot, " / ", Lot_Step, " ) * ", Lot_Step);
Then you should know - no?
Just checked FXCM MarketInfo and USDCAD Tick_Size = "0.0" where as other FX pairs return an actual ticksize... so that is my problem?
What the heck do I do about this?
2014.10.14 05:26:02.415 Account Information USDCAD,H1: Tick Size is: 0 -- Tick Value is: 0.5568
Could I just use "Point" instead of ts like so:
//What is loss for 1 lot? double loss_for_1_lot = pips_to_bsl / Point * tv ; Print("loss_for_1_lot == ", pips_to_bsl," / ", Point, " * ", tv, " = ", loss_for_1_lot);
Try SymbolInfoDouble("USDCAD",SYMBOL_TRADE_TICK_SIZE) and ask your broker may be the server is not correct?
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register