• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do you determine an "Up" or "Down" bar?

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

    How do you determine an "Up" or "Down" bar?

    I would like to know if a given bar was a black or white candlestick (Red or Green). Was the bar an "Up" or a "Down"? (if(Open[0] > Close[0])) I was hoping for something really simple (custom code) or NTD out of the box.

    Your ideas are very much appreciated!

    Thank You,
    Robert
    Last edited by RobVig; 06-02-2016, 04:41 PM.

    #2
    That looks good to me.

    Comment


      #3
      Originally posted by RobVig View Post
      I would like to know if a given bar was a black or white candlestick (Red or Green). Was the bar an "Up" or a "Down"? (if(Open[0] > Close[0])) I was hoping for something really simple (custom code) or NTD out of the box.
      As mentioned by Sledge, you're already there.

      However, I've devised many one liners that help me in these cases.

      Eg, instead of your example, I'd use,

      Code:
      if (IsBarDown)
      {
        // same as your Open[0] > Close[0]
      }
      Using the Compare method, documented here,
      http://ninjatrader.com/support/helpG...trument_co.htm

      I have this code in my toolbox,

      Code:
      protected int ComparePrice(double PriceValue1, double PriceValue2)
      {
          return Instrument.MasterInstrument.Compare(PriceValue1, PriceValue2);
      }
      
      /* --------------------------------------------------------------------------------------------------- */
      
      protected bool IsBarUp { get { return ComparePrice(Close[0], Open[0]) > 0; } }
      protected bool IsBarDown { get { return ComparePrice(Close[0], Open[0]) < 0; } }
      protected bool IsBarUpDoji { get { return ComparePrice(Close[0], Open[0]) >= 0; } }
      protected bool IsBarDownDoji { get { return ComparePrice(Close[0], Open[0]) <= 0; } }
      protected bool IsBarDoji { get { return ComparePrice(Close[0], Open[0]) == 0; } }
      protected bool IsBarSuperDoji { get { return ComparePrice(High[0], Low[0]) == 0; } }

      Comment


        #4
        Thanks Guys!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Seastragg, Today, 04:41 PM
        0 responses
        2 views
        0 likes
        Last Post Seastragg  
        Started by n8dogg59, Today, 03:07 PM
        0 responses
        4 views
        0 likes
        Last Post n8dogg59  
        Started by Newtrader101, Today, 10:31 AM
        1 response
        20 views
        0 likes
        Last Post koganam
        by koganam
         
        Started by nepenthean, Today, 12:36 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by sun0781, Yesterday, 05:02 PM
        1 response
        25 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Working...
        X