Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Can someone help me resolve this issue?

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

    Can someone help me resolve this issue?

    Hi,

    I have the following codes:-

    BP1 = Close[1]-Math.Min(Low[1],Close[2]);
    BP2 = Close[2]-Math.Min(Low[2],Close[3]);

    and the following output derived from the above codes:-

    Close[1] is0.9581
    TrueLow is0.9563
    BP1 is0.00179999999999991
    Close[2] is0.965
    TrueLow is0.9632
    BP2 is0.00180000000000002


    1. Why am I getting solutions to the 17th decimal?
    2. BP1 should equal BP2 but in the above, it isn't. How can I resolve this problem so that they will reflect as being equal.

    BP1 and BP2 are double values.

    Regards

    Kay Wai

    #2
    Originally posted by kaywai View Post
    Hi,

    I have the following codes:-

    BP1 = Close[1]-Math.Min(Low[1],Close[2]);
    BP2 = Close[2]-Math.Min(Low[2],Close[3]);

    and the following output derived from the above codes:-

    Close[1] is0.9581
    TrueLow is0.9563
    BP1 is0.00179999999999991
    Close[2] is0.965
    TrueLow is0.9632
    BP2 is0.00180000000000002


    1. Why am I getting solutions to the 17th decimal?
    2. BP1 should equal BP2 but in the above, it isn't. How can I resolve this problem so that they will reflect as being equal.

    BP1 and BP2 are double values.

    Regards

    Kay Wai
    You are handling price data, so you probably want to round your values off to the ticksize of the instrument. That should make them equal, as the difference should be at most a little rounding error caused by the computer computation size structures.

    Code:
    BP1 = Close[1]-Math.Min(Low[1],Close[2]);
    BP2 = Close[2]-Math.Min(Low[2],Close[3]);
    BP1 = Instrument.MasterInstrument.Round2TickSize(BP1);
    BP2 = Instrument.MasterInstrument.Round2TickSize(BP2);

    Comment


      #3
      Thanks much Koganam!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by terofs, Yesterday, 04:18 PM
      1 response
      21 views
      0 likes
      Last Post terofs
      by terofs
       
      Started by CommonWhale, Today, 09:55 AM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by Gerik, Today, 09:40 AM
      2 responses
      7 views
      0 likes
      Last Post Gerik
      by Gerik
       
      Started by RookieTrader, Today, 09:37 AM
      2 responses
      13 views
      0 likes
      Last Post RookieTrader  
      Started by alifarahani, Today, 09:40 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X