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 NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    56 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    132 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    73 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    45 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    49 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X