math.rounding question - NinjaTrader Programming | futures io social day trading
futures io futures trading

math.rounding question
Updated: Views / Replies:3,793 / 6
Created: by max-td Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 100,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Thread Tools

math.rounding question

Elite Member
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: FGBL 6E B4
max-td's Avatar
Posts: 1,754 since Jun 2009
Thanks: 2,309 given, 921 received

math.rounding question

who knows how i make a rounding of an EMA to a wished format ie :

121.25 instead of 121.2469857...

i want to use my EMA-value in an indicator but want it rounded to 2 numbers behind the point - like 121.25 instead of 121.2469857
if i use an EMA in my chart it is always set to the ticksize of the instrument - but if i use it in an indicator the value is given in a long number.
i dont wanna transform it in a string - i need a double value.
any ideas ?
Thanks in advance.

Elite Member
Futures Experience: Intermediate
Platform: NT7
Favorite Futures: CL, NQ, NG
Posts: 461 since Jun 2009
Thanks: 1,369 given, 386 received

max,I normally just do this - not very elegant but it works for me...



The following user says Thank You to zeller4 for this post:
Elite Member
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: FGBL 6E B4
max-td's Avatar
Posts: 1,754 since Jun 2009
Thanks: 2,309 given, 921 received

well - found an interesting way to do this in NT-forum :

double EMArounded = Math.Round(valueEMA*100)/100;

Round an integer to nearest 10 - NinjaTrader Support Forum

and hey ... there is a guy involved called cunparis


Last edited by max-td; July 2nd, 2009 at 12:34 PM.
Just starting out...
Bloomfield Hills, MI
Futures Experience: Master
Platform: NinjaTrader / Neoticker
Favorite Futures: ES
Velocity's Avatar
Posts: 16 since Jun 2009
Thanks: 0 given, 7 received

Multiply it by four, then round it, then divide it by four.

Elite Member
Calcutta, India
Futures Experience: Intermediate
Platform: ArthaChitra
Posts: 278 since Jun 2009
Thanks: 161 given, 262 received


where 2 represents 2 decimal places

The following 2 users say Thank You to bukkan for this post:
Elite Member
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: FGBL 6E B4
max-td's Avatar
Posts: 1,754 since Jun 2009
Thanks: 2,309 given, 921 received

bukkan - great!
tested >> works too
and its the most elegant way i would say !

Very nice solution also for further codings.

The following user says Thank You to max-td for this post:
Trading for Fun
Here, GA
Futures Experience: Intermediate
Platform: Ninja
Posts: 147 since Jun 2009
Thanks: 1 given, 74 received

You may want to consider using Round2TickSize. It can be used on more than just price. It will round any number to the nearest Instrument Tick Size. For example if the indicator is placed on an ES chart the ES Tick Size is .25. So using this example will round any number to the nearest .25. There may be some issues doing it this way but I have not found them.

Indicator.Set(Instrument.MasterInstrument.Round2TickSize(value to be rounded);

The following user says Thank You to TAJTrades for this post:


futures io > > > > > math.rounding question
Thread Tools

Upcoming Webinars and Events (4:30PM ET unless noted)

July Journal Challenge - $500 in Amazon Gift Cards!


Battlestations: $750 in prizes - Show us your trading desk!


TBA: FuturesTrader71 w/Morad Askar

Elite only

Similar Threads
Thread Thread Starter Forum Replies Last Post
Murrey Math Big Mike Traders Hideout 238 June 25th, 2018 11:53 AM
C# Math Library MXASJ Matlab, R project and Python 15 April 14th, 2015 06:11 AM
Murray Math Lines - Question Todd NinjaTrader 6 July 27th, 2011 09:08 PM
Murray Math Discussion? jwhtrades Traders Hideout 5 July 27th, 2011 09:06 PM
anyone know how to fix rounding errors in NT7? Math.Round(CO.Value,4); Todd NinjaTrader Programming 5 May 25th, 2010 08:33 PM

All times are GMT -4. The time now is 06:49 AM. (this page content is cached, log in for real-time version)

Copyright © 2018 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432,
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.
no new posts
Page generated 2018-07-21 in 0.11 seconds with 14 queries on phoenix