Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Curious 399.9999999999

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Curious 399.9999999999

    I'm calling two values from the stock Darvis Indicator.. Not sure what the "double.MinValue" is about....
    public class Darvis : Indicator
    {
    #region Variables
    public double boxTop = double.MinValue;
    public double boxBottom = double.MaxValue;
    --------------------------------------------------------------------------------------------------------------------------------
    The values seem to DrawText on my chart ok but when I try to display in the Output Window there is a curious 399.99999999 that seems to be appended to the value..

    My Strategy
    private double DarvisTBox = double.MinValue;
    private double DarvisBBox = double.MaxValue;

    DarvisTBox = DarvisIndicator().boxTop;
    DarvisBBox = DarvisIndicator().boxBottom;
    DrawText("MyText"+ CurrentBar, DarvisTBox.ToString(), 0, DarvisTBox, Color.Blue);
    DrawText("MyText2"+ CurrentBar, DarvisBBox.ToString(), 0, DarvisBBox , Color.Red);

    Print(Time[0]);
    //Print( DarvisBBox);
    Print(DarvisIndicator().boxBottom);

    Output window
    339.999999999989
    8/3/2010 10:44:33 AM
    762
    339.999999999989
    8/3/2010 10:46:06 AM
    762
    339.999999999989
    8/3/2010 10:46:40 AM
    762
    339.999999999989
    8/3/2010 10:47:35 AM
    1.79769313486232E+308 (looks like this shows up when there is no value)
    339.999999999989
    8/3/2010 10:48:25 AM
    1.79769313486232E+308
    Attached Files

    #2
    Hello gg80108,

    This most likely relates to double precision issue. Below is wikipedia article on this:


    It's sometimes difficult to store the precise number in a double value. Some approaches for working on this issue are covered in this post:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Txs the Math.Abs did the trick!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      63 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      35 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      54 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      61 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      48 views
      0 likes
      Last Post CarlTrading  
      Working...
      X