Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

to check if condition occured in lat 8 bars

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

    to check if condition occured in lat 8 bars

    HI i have a condition below that evaluates a imbalanceLongHTF condition to true. How can i add aditional logic to determine if imbalanceLongHTF occured in the last 6 bars?

    if(((Close[2] > Open[2] || Close[2] < Open[2])
    && Close[1] > Open[1] && (Close[0] > Open[0] || Close[0] < Open[0])) &&
    Low[0] > High[2] && (Math.Abs(Low[0] - High[2]) >= 2))
    {
    longimbalanceHTFTopLevel = Low[0];
    longimbalanceHTFBotLevel = High[2];
    imbalanceLongHTF = true;

    }​

    #2
    First, you could shorten some of your code:
    From (Close[2] > Open[2] || Close[2] < Open[2])
    To Close[2] != Open[2]
    And from (Close[0] > Open[0] || Close[0] < Open[0])
    To Close[0] != Open[0]

    Then you might need to modify Math.Abs(Low[0] - High[2]) >= 2)
    To Math.Abs(Low[0] - High[2]) >= 2*TickSize) if that is what you actually wanted.

    Then you could use a bool series: private Series<bool> ImbalanceLongSeries;

    When you test imbalanceLongHTF = true; you can store it in the series ImbalanceLongSeries[0] = true;
    Ex.
    if(imbalanceLongHTF)
    ImbalanceLongSeries[0] = true;
    else
    ImbalanceLongSeries[0] = false;

    Then loop through the last 6 bars to check for any true condition.
    eDanny
    NinjaTrader Ecosystem Vendor - Integrity Traders

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    163 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    82 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    125 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    206 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    184 views
    0 likes
    Last Post CarlTrading  
    Working...
    X