Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Previous Swing Highs and Lows

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

    Previous Swing Highs and Lows

    Hello, I'm using the Swing indicator in my strategy and I'm having trouble finding information on how to access previous highs and lows. For example, using Swing(5).SwingHigh[0] will give me the most recent Swing High with a strength of 5, but I would like to know where the last x number of highs were so I can plot higher highs and lower lows. Can someone provide a simple example? Thanks

    #2
    Hello KNalley,

    The SwingHigh series will just return the value at the number of BarsAgo you requested. For working with the instances of the swings you would need to use SwingHighBar:


    Here is an example of gathering the last two instances of high swings and then getting their values:


    Code:
    int BarsAgo = Swing(4).SwingHighBar(0, 1, Bars.BarsSinceNewTradingDay); 
    if(BarsAgo < 0 || CurrentBar <= BarsAgo) return;
    
    double swingHigh = Swing(4).SwingHigh[BarsAgo];
    Print(swingHigh);
    
    int BarsAgo2 = Swing(4).SwingHighBar(0, 2, Bars.BarsSinceNewTradingDay); 
    
    if(BarsAgo2 < 0 || CurrentBar <= BarsAgo2) return;
    
    double swingHigh2 = Swing(4).SwingHigh[BarsAgo2];
    Print(swingHigh2);
    you can also use the High series as shown in the help guide sample.


    I look forward to being of further assistance.

    Comment


      #3
      Thank you, I can work with that example

      Comment


        #4
        hello what is Swing(4) ??

        Comment


          #5
          Hello jimmy_NT,

          Swing is the swing indicator, the 4 is the strength parameter the swing takes: https://ninjatrader.com/support/help...lightsub=swing

          Comment


            #6
            Originally posted by NinjaTrader_Jesse View Post
            Hello KNalley,

            The SwingHigh series will just return the value at the number of BarsAgo you requested. For working with the instances of the swings you would need to use SwingHighBar:


            Here is an example of gathering the last two instances of high swings and then getting their values:


            Code:
            int BarsAgo = Swing(4).SwingHighBar(0, 1, Bars.BarsSinceNewTradingDay);
            if(BarsAgo < 0 || CurrentBar <= BarsAgo) return;
            
            double swingHigh = Swing(4).SwingHigh[BarsAgo];
            Print(swingHigh);
            
            int BarsAgo2 = Swing(4).SwingHighBar(0, 2, Bars.BarsSinceNewTradingDay);
            
            if(BarsAgo2 < 0 || CurrentBar <= BarsAgo2) return;
            
            double swingHigh2 = Swing(4).SwingHigh[BarsAgo2];
            Print(swingHigh2);
            you can also use the High series as shown in the help guide sample.


            I look forward to being of further assistance.
            How would you go back to say the last 5 swing highs NinjaTrader_Jesse

            Comment


              #7
              Hello Trader17,

              You would need to use the swings customs methods for that, you can see examples of how to find swing instances in the help guide swing page here: https://ninjatrader.com/support/help.../nt8/swing.htm

              The instance number you want is the parameter for SwingHighBar or SwingLowBar.

              Comment


                #8
                Originally posted by NinjaTrader_Jesse View Post
                Hello Trader17,

                You would need to use the swings customs methods for that, you can see examples of how to find swing instances in the help guide swing page here: https://ninjatrader.com/support/help.../nt8/swing.htm

                The instance number you want is the parameter for SwingHighBar or SwingLowBar.
                Thanks NinjaTrader_Jesse I was looking to get the swing high and low values themselves, not number of bars ago they occured. Unless I am not reading your reply correctly.

                Comment


                  #9
                  Hello Trader17,

                  The sample that you quoted shows how to get the prices. The custom methods return a bars ago so you can get the price from the plot.

                  Comment


                    #10
                    Originally posted by NinjaTrader_Jesse View Post
                    Hello Trader17,

                    The sample that you quoted shows how to get the prices. The custom methods return a bars ago so you can get the price from the plot.
                    Thanks NinjaTrader_Jesse Do you have a working example of this somewhere?

                    Comment


                      #11
                      Hello Trader17,

                      The code in post 2 is working example of that, the first 4 lines of code show how to get the first instance of the swings price. If you are having difficulty understanding a part of that code please let me know which part you needed help with.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      601 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      347 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      103 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      559 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      558 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X