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,


      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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        96 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        55 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        84 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        83 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        65 views
        0 likes
        Last Post CarlTrading  
        Working...
        X