Announcement

Collapse
No announcement yet.

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 larkmail, Today, 12:30 PM
      0 responses
      4 views
      0 likes
      Last Post larkmail  
      Started by Danila, Today, 11:08 AM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by dbida001, Today, 10:31 AM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_ChristopherJ  
      Started by Brandon9821, Today, 08:27 AM
      3 responses
      25 views
      0 likes
      Last Post Brandon9821  
      Started by tonynt, Today, 10:00 AM
      2 responses
      9 views
      0 likes
      Last Post tonynt
      by tonynt
       
      Working...
      X