Number of Decimal Places from Instrument  [SOLVED]

Questions about MultiCharts and user contributed studies.
IT-Trader
Posts: 26
Joined: 22 Sep 2010
Has thanked: 4 times
Been thanked: 4 times

Number of Decimal Places from Instrument  [SOLVED]

Postby IT-Trader » 10 Oct 2012

Is there a way to get the number of decimal places used by an instrument.
e.g. The ES would be 2, for GBP/USD it would be 4 etc.

Any suggestions?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Number of Decimal Places from Instrument

Postby Henry MultiСharts » 10 Oct 2012

Hello IT-Trader,

Here is a simple example that comes to my mind:

Code: Select all

var:NumOfDecDig(0);

if PriceScale=100 then NumOfDecDig=2;
if PriceScale=10000 then NumOfDecDig=4;

print (NumOfDecDig:0:0);

IT-Trader
Posts: 26
Joined: 22 Sep 2010
Has thanked: 4 times
Been thanked: 4 times

Re: Number of Decimal Places from Instrument

Postby IT-Trader » 10 Oct 2012

ah ha! a low tech solution! Didn't even think of that.

If someone has an automated answer then please let me know but I can use the low tech answer in the meantime.

Thanks for the quick reply Henry.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Number of Decimal Places from Instrument

Postby TJ » 10 Oct 2012

Is there a way to get the number of decimal places used by an instrument.
e.g. The ES would be 2, for GBP/USD it would be 4 etc.

Any suggestions?

Code: Select all

decimal = Log(PriceScale) / Log(10) ;

IT-Trader
Posts: 26
Joined: 22 Sep 2010
Has thanked: 4 times
Been thanked: 4 times

Re: Number of Decimal Places from Instrument

Postby IT-Trader » 10 Oct 2012

Perfect, thanks TJ.

Very much appreciated.


Return to “MultiCharts”