Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

LowestBar starting from a previous bar

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

    LowestBar starting from a previous bar

    I am trying to get the LowestBar in 5 the previous bars, not from the CurrentBar, but from a bar corresponding to a past event (such as an indicator printing a Swing Low - please see code)

    is there a way of doing that?

    Code:
    if ((!LSwDMIbool && DMI1[1] - DMI1[2] > 0.001 && DMI1[3] - DMI1[2] > 0.001)
          || (CurrentBar - flatDMIbarEnd == 2 && DMI1[1] - FlatDMI[a-1] > 0.001 && DMI(Closes[2], Convert.ToInt32(DmiPeriod)).Values[0].GetValueAt(flatDMIbarStart-1) - FlatDMI[a-1] > 0.001))
    {                              
       LSwDMI.Add(DMI1[2]);
       var lSwDMIbar = CurrentBar - 2;
       LSwDMIbar.Add(lSwDMIbar);
    ...
    
       if (!LLsDmiAdd && c > 1 && LSwDMI[c] - LSwDMI[c-1] > 0.001 && LSwDMI[c-2] - LSwDMI[c-1] > 0.001)
       {
          LastLSwDMI.Add(LSwDMI[c-1]);      
          lastLSwDMIbar = LSwDMIbar[c-1];
          LastLSwDMIbar.Add(lastLSwDMIbar);
          var newLowBar = LastLSwDMIbar[k] - LowestBar(Lows[2], 5);   // [I][B]I need the LowestBar counting 5 bars back from LastLSwDMIbar[k], not from the CurrentBar[/B][/I]
          LastLSwDMIpriceBar.Add(newLowBar);    
    ...
          k++;
       } 
    c++;
    }

    #2
    Hi itrader46, thanks for your post.

    You can use the Minimum method to find a minimum value in a series. Use the BarsAgo indexing to start the counting from X bars back.

    https://ninjatrader.com/support/help...inimum_min.htm - MIN()

    To find the bar value of that price value your own method would need to be created.

    There is also the LowestBar method where you can find the lowest bar from the current bar, but this does not have a BarsAgo function:



    Please let me know if you have any further questions.

    Comment

    Latest Posts

    Collapse

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