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

Problem with OHLC methods

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

    Problem with OHLC methods

    Seems like the Open[], Close[], High[], Low[] statements are not always reliable. I have the following code which draws a triangle when a bar closes on its low. It appears that the equality test does not always evaluate to true, even when the Close and the Low of the bar are actually equal to each other

    if ( Close[0] == Low[0] ) {
    DrawTriangleDown("bad"+CurrentBar, false, 0, High[0], Color.Yellow);
    }

    As you can see in the included chart picture. several of the red bars closing on their low did not get a triangle. The Data Box of the bar pointed to by the cross hair clearly shows that the Low of the bar and Close of the bar are both at 829.8, but that bar did not get a triangle.
    Attached Files

    #2
    You could try
    if (Instrument.MasterInstrument.Compare(Close[0], Low[0]) == 0)

    Comment


      #3
      Originally posted by MJT View Post
      You could try
      if (Instrument.MasterInstrument.Compare(Close[0], Low[0]) == 0)
      Sure I could, but I should not have to. Open[],Close[],High[],Low[] should include the rounding to nearest valid tick in the native code. These are high level functions, I should not have to worry about math rounding errors. I don't have to worry about that in eSignal, or TradeStation, or any of the other competitive software !!!

      To get the code to work properly I have to use:

      if ( Instrument.MasterInstrument.Round2TickSize(Close[0]) == Instrument.MasterInstrument.Round2TickSize(Low[0]) )

      This means that 75 other strategies I've written all have the potential of screwing up without me noticing. I have to go back and change them all to insure the code is doing what it is suppose to. That goes for everyone who ever uses code like Open[0] > Open[1] etc.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by xiinteractive, 04-09-2024, 08:08 AM
      5 responses
      13 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by swestendorf, Today, 11:14 AM
      2 responses
      5 views
      0 likes
      Last Post NinjaTrader_Kimberly  
      Started by Mupulen, Today, 11:26 AM
      0 responses
      2 views
      0 likes
      Last Post Mupulen
      by Mupulen
       
      Started by Sparkyboy, Today, 10:57 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by TheMarlin801, 10-13-2020, 01:40 AM
      21 responses
      3,918 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Working...
      X