Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by JoMoon2024, Today, 06:56 AM
    0 responses
    6 views
    0 likes
    Last Post JoMoon2024  
    Started by Haiasi, 04-25-2024, 06:53 PM
    2 responses
    17 views
    0 likes
    Last Post Massinisa  
    Started by Creamers, Today, 05:32 AM
    0 responses
    6 views
    0 likes
    Last Post Creamers  
    Started by Segwin, 05-07-2018, 02:15 PM
    12 responses
    1,786 views
    0 likes
    Last Post Leafcutter  
    Started by poplagelu, Today, 05:00 AM
    0 responses
    3 views
    0 likes
    Last Post poplagelu  
    Working...
    X