• 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 srbdoc, Today, 11:21 AM
        0 responses
        4 views
        0 likes
        Last Post srbdoc
        by srbdoc
         
        Started by TazoTodua, Today, 11:20 AM
        0 responses
        3 views
        0 likes
        Last Post TazoTodua  
        Started by TazoTodua, Today, 11:19 AM
        0 responses
        5 views
        0 likes
        Last Post TazoTodua  
        Started by sdauteuil, Today, 10:22 AM
        3 responses
        9 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by bc24fl, Today, 10:03 AM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X