Number of Decimal Places from Instrument  [SOLVED]

Questions about MultiCharts and user contributed studies.
IT-Trader
Posts: 10
Joined: 22 Sep 2010
Has thanked: 2 times
Been thanked: 1 time

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: 8479
Joined: 25 Aug 2011
Has thanked: 1211 times
Been thanked: 2720 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: 10
Joined: 22 Sep 2010
Has thanked: 2 times
Been thanked: 1 time

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: 6572
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 968 times
Been thanked: 1902 times

Re: Number of Decimal Places from Instrument

Postby TJ » 10 Oct 2012

IT-Trader wrote: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) ;
These users thanked the author TJ for the post (total 3):
IT-TraderHenry MultiСhartsJoshM

IT-Trader
Posts: 10
Joined: 22 Sep 2010
Has thanked: 2 times
Been thanked: 1 time

Re: Number of Decimal Places from Instrument

Postby IT-Trader » 10 Oct 2012

Perfect, thanks TJ.

Very much appreciated.


Return to “MultiCharts”