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 traderqz, Today, 12:06 AM
    5 responses
    8 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by Mongo, Today, 11:05 AM
    2 responses
    7 views
    0 likes
    Last Post Mongo
    by Mongo
     
    Started by guillembm, Today, 11:25 AM
    0 responses
    3 views
    0 likes
    Last Post guillembm  
    Started by Tim-c, Today, 10:58 AM
    1 response
    3 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by traderqz, Yesterday, 09:06 AM
    4 responses
    29 views
    0 likes
    Last Post traderqz  
    Working...
    X