NexusFi: Find Your Edge


Home Menu

 





math.rounding question


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one max-td with 3 posts (1 thanks)
    2. looks_two Velocity with 2 posts (0 thanks)
    3. looks_3 bukkan with 1 posts (2 thanks)
    4. looks_4 zeller4 with 1 posts (1 thanks)
      Best Posters
    1. looks_one bukkan with 2 thanks per post
    2. looks_two zeller4 with 1 thanks per post
    3. looks_3 TAJTrades with 1 thanks per post
    4. looks_4 max-td with 0.3 thanks per post
    1. trending_up 5,545 views
    2. thumb_up 5 thanks given
    3. group 2 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

math.rounding question

  #1 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927

hi,
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.

max-td
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Better Renko Gaps
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
Increase in trading performance by 75%
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Diary of a simple price action trader
26 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
23 thanks
My NQ Trading Journal
16 thanks
HumbleTraders next chapter
9 thanks
  #2 (permalink)
 zeller4 
Orlando Florida
 
Experience: Intermediate
Platform: NT8
Trading: CL, NQ, ES, RTY
Posts: 477 since Jun 2009
Thanks Given: 1,416
Thanks Received: 404

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

kz

Print(Math.Round(doublevalue*
100)/100);

Reply With Quote
Thanked by:
  #3 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927


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

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

Round an integer to nearest 10 - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum

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

max-td
Started this thread Reply With Quote
  #4 (permalink)
 
Velocity's Avatar
 Velocity 
Bloomfield Hills, MI
 
Experience: Master
Platform: NinjaTrader / Neoticker
Trading: ES
Posts: 16 since Jun 2009
Thanks Given: 0
Thanks Received: 7

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

Reply With Quote
  #5 (permalink)
 bukkan 
Calcutta, India
 
Experience: Intermediate
Platform: ArthaChitra
Posts: 278 since Jun 2009
Thanks Given: 161
Thanks Received: 271

math.round(value,2)

where 2 represents 2 decimal places

Reply With Quote
Thanked by:
  #6 (permalink)
 
max-td's Avatar
 max-td 
Frankfurt
 
Experience: Intermediate
Platform: NinjaTrader
Trading: FGBL 6E B4
Posts: 1,752 since Jun 2009
Thanks Given: 2,309
Thanks Received: 927

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

Very nice solution also for further codings.

max-td
Started this thread Reply With Quote
Thanked by:
  #7 (permalink)
TAJTrades
Here, GA
 
Posts: 158 since Jun 2009
Thanks Given: 1
Thanks Received: 86

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);

Reply With Quote
Thanked by:




Last Updated on July 29, 2009


© 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