Amount of Decimals Changing in the Background?  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
User avatar
Jobauma
Posts: 102
Joined: 16 Apr 2013
Has thanked: 22 times
Been thanked: 4 times

Amount of Decimals Changing in the Background?

Postby Jobauma » 24 Feb 2019

Hi.

I've achieved to automatically make ticks to pips ( or what a tick is ), but there seems to be something wrong. It doesn't work all the time.

The concept is to count the decimals to decide what 1 tick (pip) is. I've made an average of the counting of decimals ( of the value of "close" ). This makes it work almost all the time, but not always ( to make it more stable ).

The code is like this:

Code: Select all

// Ticks to Pips:

// Count Decimals:
m_Price_TicksToPips_CountDecimals.Value = BitConverter.GetBytes(decimal.GetBits((decimal)(Bars.Close[0]))[3])[2];

// Count Decimals Average ( on Last Bar ):
if (Bars.LastBarOnChart)
m_Price_TicksToPips_CountDecimals_Average = Math.Round(Average( m_Price_TicksToPips_CountDecimals, 34 ));

// Set Tick:
if ( m_Price_TicksToPips_CountDecimals_Average == 5 || m_Price_TicksToPips_CountDecimals_Average == 4 )
m_Price_TicksToPips_SetTick = 0.00001;
else if ( m_Price_PointsToPips_CountDecimals_Average == 3 ) m_Price_TicksToPips_SetTick = 0.001;
Is it true that the amount of decimals change in the background? Or am I missing something? :)

The code should work all the time, but doesn't.

Any help is appreciated. :)



Best regards,
Johannes Hillestad Baumann

User avatar
Henry MultiСharts
Posts: 9089
Joined: 25 Aug 2011
Has thanked: 1258 times
Been thanked: 2923 times

Re: Amount of Decimals Changing in the Background?  [SOLVED]

Postby Henry MultiСharts » 25 Feb 2019

Hello Johannes,

You can calculate the tick size using Bars.Info.MinMove and Bars.Info.PriceScale.
1 tick = MinMove * PriceScale.
Keep in mind that the symbol should be properly configured in Quote Manager.

User avatar
Jobauma
Posts: 102
Joined: 16 Apr 2013
Has thanked: 22 times
Been thanked: 4 times

Re: Amount of Decimals Changing in the Background?

Postby Jobauma » 26 Feb 2019

Thank you very much!


Return to “MultiCharts .NET”