market_info = Digits(); if(market_info ==4 || market_info ==2 ) scale = 1;Digits is only the current pair. You must compute scale for each currency individually
You could use an array for the symbols
string SymbolArray[]={"AUDUSD", "EURJPY", "EURUSD", "GBPJPY", "GBPUSD", "NZDUSD", "USDCAD", "USDJPY"}; int as=ArraySize(SymbolArray); double points_to_pips; string comm=""; for(int x=0;x<as;x++) { double symbol_spread=MarketInfo(SymbolArray[x], MODE_SPREAD); double dig=MarketInfo(SymbolArray[x], MODE_DIGITS); if(dig==3 || dig==5) points_to_pips=0.1; else points_to_pips=1; comm+=SymbolArray[x]+" = "+DoubleToStr(symbol_spread*points_to_pips,2)+" pips\n"; } Comment(comm);
You could use an array for the symbols
Keith,
Excellent idea. Greatly appreciated.
if(dig==3 || dig==5) points_to_pips=0.1; else points_to_pips=1;You've got them backwards. if dig%2==1 then points_to_pips = 10 * Point of that symbol else it's just Point (*1) of that symbol. See Problems with a calculation - MQL4 forum
WHRoeder:
if(dig==3 || dig==5) points_to_pips=0.1; else points_to_pips=1;
You've got them backwards. if dig%2==1 then points_to_pips = 10 * Point of that symbol else it's just Point (*1) of that symbol. See Problems with a calculation - MQL4 forum
William & Keith,
Can I get a final confirmation on the correct handling of the digits? I am testing with 3 different brokers: one broker is quoting 2 & 4 digits, another broker is quoting 3 & 5 digits, and yet the third broker is quoting 3 & 4 & 5 digits. See attached pictures.
2&4 Digits
3 & 5 Digits
3, 4 & 5 Digits
It shouldn't matter
2,3,4 or 5 digits
because MarketInfo Digits is retrieved for each individual symbol.
Note: there may be differences between the comment and what you see in the market watch window. This is because the comment will only be updated when the is a new tick on the chart that the code is attached to.
- 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,
Is there a better way to write this indicator so that it will work for both 4 & 5 digits brokers?