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 Rapine Heihei, Today, 08:19 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by Rapine Heihei, Today, 08:25 PM
      0 responses
      5 views
      0 likes
      Last Post Rapine Heihei  
      Started by f.saeidi, Today, 08:01 PM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by Rapine Heihei, Today, 07:51 PM
      0 responses
      6 views
      0 likes
      Last Post Rapine Heihei  
      Started by frslvr, 04-11-2024, 07:26 AM
      5 responses
      97 views
      1 like
      Last Post caryc123  
      Working...
      X