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