Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Up or Down bar?

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

    Up or Down bar?

    Hello,

    I would like to create a condition that bases some of its logic on whether the previous candle closed up or down. Is there a way to use IsRising() to do this? Or would there be some other way that is better?

    Thanks is advance!

    #2
    Hi NjTMatthew,

    Your question could be interpreted two ways.
    1. The previous candle close is above/below its previous candle close.
    2. The previous candle close is greater/less than its open. That is, you have a green/red candle, or a Doji with the close the same as the open.

    For #1, use
    Code:
    if (Close[1] > Close[2]) {
       // Closed higher than the previous candle
       ... your logic ...
    }
    else if ((Close[1] < Close[2]) {
       // Closed lower than the previous candle
       ... your logic ...
    }​
    else {
       // same close
       ... your logic ...
    }
    For #2, use
    Code:
    if (Close[1] > Open[1]) {
    // Green candle
    ... your logic ...
    }
    else if (Close[1] < Open[1] {
    // Red candle
    ... your logic ...
    }
    else {
    // Doji - Close of the candle equals the Open
    ... your logic ...
    }
    Hope that helps!
    Matt

    Comment


      #3
      Yes, that is exactly what I was looking for.

      Thank you!

      Comment


        #4
        NjTMatthew Excellent.. You're very welcome!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        47 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        23 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        33 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        51 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        42 views
        0 likes
        Last Post CarlTrading  
        Working...
        X