yes.
How To Ask Questions The Smart Way. 2004
Only ask questions with yes/no answers if you want "yes" or "no" as the answer.
But since you were argumentative (twice) and (five times) I won't be helping.
Hi there I have this code working fine on the simple version of my advisor:
But it's giving a zero divide error in the multipair version:
The same code is also working in the MQ5 multipair version:
Anyone knows what's the mistake on that code?
Hi David,
It is probably because the MarketInfo function gives you zero.
Try to print SPoint and STick variables.
The error generates when the market is off (weekend)?
Jan.
Hi David,
It is probably because the MarketInfo function gives you zero.
Try to print SPoint and STick variables.
The error generates when the market is off (weekend)?
Jan.
Hi there Jan, thank you, I forgot to Print values. This is the result:
2020.07.26 22:15:16.334 2017.07.03 03:00:40 (Advisor) EURUSD,M1: SPoint: 1e-05, STick: 0.8580229435335102
Now am trying to get this value by NormalizeDouble with symbol digits:
int SDigits=(int)MarketInfo(SName,MODE_DIGITS); double SPoint=NormalizeDouble(MarketInfo(SName,MODE_POINT),SDigits); double STick=NormalizeDouble(MarketInfo(SName,MODE_TICKVALUE),SDigits);
2020.07.26 22:23:46.725 2017.07.05 02:55:00 (Advisor) EURUSD,M1: SDigits: 5, SPoint: 1e-05, STick: 0.85802
It's not working... there is also some point where tickvalue is zero (zero divide):
2020.07.26 22:29:40.714 2017.07.06 05:42:50 (Advisor) EURUSD,M1: SDigits: 5, SPoint: 1e-05, STick: 0.0
Hi there Jan, thank you, I forgot to Print values. This is the result:
2020.07.26 22:15:16.334 2017.07.03 03:00:40 (Advisor) EURUSD,M1: SPoint: 1e-05, STick: 0.8580229435335102
Now am trying to get this value by NormalizeDouble with symbol digits:
2020.07.26 22:23:46.725 2017.07.05 02:55:00 (Advisor) EURUSD,M1: SDigits: 5, SPoint: 1e-05, STick: 0.85802
It's not working... there is also some point where tickvalue is zero (zero divide):
2020.07.26 22:29:40.714 2017.07.06 05:42:50 (Advisor) EURUSD,M1: SDigits: 5, SPoint: 1e-05, STick: 0.0
Hello,
try to check ATR value.
If return 0.0, then the problem is in ATR calculate method.
Hello,
try to check ATR value.
If return 0.0, then the problem is in ATR calculate method.
ATR is ok, the flaw might be between SPoint which its strange value and STick which sometimes it's giving 0.0. This is not happening on chart symbol version.
These things happen all the time so you have to detect them before failure in your code.
You can always add something like a check before dividing the value.
I've ensured to get a higher value than zero for TickValue(STick):
double SPoint=MarketInfo(SName,MODE_POINT),STick=MarketInfo(SName,MODE_TICKVALUE); double LotSize=0;if(STick!=0){NormalizeDouble(((RiskFactor/100)*AccountBalance()/((ATR/3)/SPoint))/STick,2);}
And now the advisor is running... but it's working 0.01 lots everytime, when it might be around 0.08 for 1000 eur. capital.
2020.07.27 13:59:05.733 2019.05.15 04:24:06 (Advisor) EURUSD,M1: open #284 sell 0.01 EURUSD at 1.12050 sl: 1.12216 tp: 1.11801 ok
So still it's not properly calculating the two percent riskfactor to make lotsizing. I'm just thinking that MetaTrader4 does not work properly on every case.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi there I have this code working fine on the simple version of my advisor:
But it's giving a zero divide error in the multipair version:
The same code is also working in the MQ5 multipair version:
Anyone knows what's the mistake on that code?