Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      580 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      336 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      103 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      554 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      552 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X