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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        571 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        331 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        549 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        549 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X