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 CortexZenUSA, Today, 12:53 AM
    0 responses
    1 view
    0 likes
    Last Post CortexZenUSA  
    Started by CortexZenUSA, Today, 12:46 AM
    0 responses
    1 view
    0 likes
    Last Post CortexZenUSA  
    Started by usazencortex, Today, 12:43 AM
    0 responses
    5 views
    0 likes
    Last Post usazencortex  
    Started by sidlercom80, 10-28-2023, 08:49 AM
    168 responses
    2,265 views
    0 likes
    Last Post sidlercom80  
    Started by Barry Milan, Yesterday, 10:35 PM
    3 responses
    12 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X