NexusFi: Find Your Edge


Home Menu

 





Decimals in TickSize


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Jigsaw Trading with 2 posts (1 thanks)
    2. looks_two Baseheadz with 2 posts (1 thanks)
    3. looks_3 bukkan with 1 posts (1 thanks)
    4. looks_4 cutzpr with 1 posts (0 thanks)
    1. trending_up 6,292 views
    2. thumb_up 3 thanks given
    3. group 5 followers
    1. forum 7 posts
    2. attach_file 0 attachments




 
Search this Thread

Decimals in TickSize

  #1 (permalink)
 Baseheadz 
Las Vegas, USA
 
Experience: Master
Platform: Ninja, Multicharts, Proprietary
Trading: Energies
Posts: 48 since Jun 2011
Thanks Given: 1
Thanks Received: 9

Is there a way in NT to return the number of decimals in the TickSize of a futures contract?

Thanks

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Trade idea based off three indicators.
Traders Hideout
Exit Strategy
NinjaTrader
REcommedations for programming help
Sierra Chart
ZombieSqueeze
Platforms and Indicators
Increase in trading performance by 75%
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
36 thanks
Spoo-nalysis ES e-mini futures S&P 500
24 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #3 (permalink)
 bukkan 
Calcutta, India
 
Experience: Intermediate
Platform: ArthaChitra
Posts: 278 since Jun 2009
Thanks Given: 161
Thanks Received: 271


i use this code. i got it from the nt forum, cant remember the original author so my apologies.

 
Code
double d = TickSize - (int)TickSize;
string dstr = d.ToString();
int decimalplaces = 0;
if (dstr.IndexOf(".") > 0) decimalplaces = dstr.Length - 2;
else decimalplaces = 0;

Reply With Quote
Thanked by:
  #4 (permalink)
 Baseheadz 
Las Vegas, USA
 
Experience: Master
Platform: Ninja, Multicharts, Proprietary
Trading: Energies
Posts: 48 since Jun 2011
Thanks Given: 1
Thanks Received: 9

I got a solution I did it a little differently.

if (TickSize == 0.1)
Rounding=1;
else if(TickSize == 0.01)
Rounding=2;
else if (TickSize == 0.25)
Rounding=2;
else if (TickSize == 0.005)
Rounding=3;
else if (TickSize == 0.0001)
Rounding=4;
else if (TickSize == 0.0005)
Rounding=4;
else if (TickSize == 0.00005)
Rounding=5;

Started this thread Reply With Quote
Thanked by:
  #5 (permalink)
 
cutzpr's Avatar
 cutzpr 
United States
 
Experience: None
Platform: TWS,Ninja Trader
Trading: Forex, Futures, Stocks
Posts: 35 since Apr 2012
Thanks Given: 10
Thanks Received: 10

Even though this is an old post, I had to reply. There is a better way to get the number of decimal places.


 
Code
                            
//Number of decimals places


double decimals Math.Log10(1/TickSize); 

Reply With Quote
  #6 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425


cutzpr View Post
Even though this is an old post, I had to reply. There is a better way to get the number of decimal places.


 
Code
                            
//Number of decimals places

double decimals Math.Log10(1/TickSize); 

Nice, but no cigar, needs to handle 0.5 increments (and the like.)

e.g.

 
Code
		protected override void OnStartUp ()
		{
			double decimals = Math.Log10(1/Instrument.MasterInstrument.TickSize);
			Print("TickSize for " + Instrument + " is " + Instrument.MasterInstrument.TickSize + " and has " + decimals + " decimal places");
		}
Gives:

TickSize for FDXM 03-16 Eurex is 1 and has 0 decimal places
TickSize for FDAX 03-16 Eurex is 0.5 and has 0.301029995663981 decimal places
TickSize for ^DAX Xetra is 0.01 and has 2 decimal places

Cheers

Travel Well
Visit my NexusFi Trade Journal Reply With Quote
  #7 (permalink)
 
Jigsaw Trading's Avatar
 Jigsaw Trading  Jigsaw Trading is an official Site Sponsor
 
Posts: 2,988 since Nov 2010
Thanks Given: 831
Thanks Received: 10,393


bukkan View Post
i use this code. i got it from the nt forum, cant remember the original author so my apologies.

 
Code
double d = TickSize - (int)TickSize;
string dstr = d.ToString();
int decimalplaces = 0;
if (dstr.IndexOf(".") > 0) decimalplaces = dstr.Length - 2;
else decimalplaces = 0;

Wont work in Europe

If you have any questions about the products or services provided, please send me a Private Message or use the futures.io " Ask Me Anything" thread
Visit my NexusFi Trade Journal Reply With Quote
  #8 (permalink)
 
Jigsaw Trading's Avatar
 Jigsaw Trading  Jigsaw Trading is an official Site Sponsor
 
Posts: 2,988 since Nov 2010
Thanks Given: 831
Thanks Received: 10,393

 
Code
decimal workTickSize = (decimal)tickSize;
workTickSize -= (int)workTickSize;
int decimals = 0;
while (workTickSize > 0)
{
		decimals++;
		workTickSize *= 10;
		workTickSize -= (int)workTickSize;
}
the int "decimals" will contain what you need

If you have any questions about the products or services provided, please send me a Private Message or use the futures.io " Ask Me Anything" thread
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on February 4, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts