PDA

View Full Version : Floating-Point Arithmetic


nico_p
04-10-2008, 07:02 PM
Hi,
I have a indicator output that i need to format
TrailingStop =200,669999999999
This should be formatted to TrailingStop =200,67

Could somebody be so kind to show me how I do this

Thank you very much
Nico

I've read this thread but this is comparing values, I just want it formatted
http://www.ninjatrader-support.com/vb/showthread.php?t=3929

NinjaTrader_Ray
04-10-2008, 07:10 PM
What is that you want?

- Format for visual display purposes?
- Format to use for an order price?

If the latter, you need not worry about this since NinjaTrader internal will take care of rounding it to a valid tick size increment. If you want to format for display, look at the ToString() method, there are options to do something like TrailStop.ToString("0.00").

Don't quote me on the syntax but I believe that its correct.

nico_p
04-10-2008, 07:21 PM
Hi Ray,

I need it formatted so I can compair this output value to previous bar close
(Close = indicator output)
I've looked into this thread http://www.ninjatrader-support.com/vb/showthread.php?t=3823
but then later on I get an error message
"Operator '>' cannot be applied to operands of type 'string' and double'

NinjaTrader_Josh
04-11-2008, 12:56 AM
Try Math.Round(TrailingStop, 2). 2 is the parameter that determines how many decimal places you want.

nico_p
04-11-2008, 02:48 AM
Try Math.Round(TrailingStop, 2). 2 is the parameter that determines how many decimal places you want.
Thank you Josh
just what I needed

Nico