Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

swing

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

    swing

    good afternoon, investigating the swing indicator sometimes it marks the last swing but it doesn't graph it, and I don't know if it's my fault
    Print(suin.SwingHigh[0]);
    Print(suin.SwingLow[0]);
    I use this to get the last swing, which I don't know if it's right, the information in the documentation gives me the last stop within the last swing and that's not what I want​

    #2
    Hello franatas,

    To get the swing values you can use the SwingHighBar and SwingLowBar methods. You would specify the lookback period and the instance of the swing which you wanted to find.

    There is a sample of getting the most recent high swing within 10 bars in the following page: https://ninjatrader.com/support/help...lightsub=swing

    Comment


      #3
      Print(High[Math.Max(0, Swing(5).SwingHighBar(0, 1, 10))]);
      Print(Low[Math.Min(0, Swing(5).SwingLowBar(0, 1, 10))]);​
      If I do it like this, the bass gives an error: 0
      0
      73.24
      ' BreakSwing ' strategy: Error calling ' OnBarUpdate' method on bar 4: You are accessing an index with a value that is invalid because it is out of range. That is to say; has access to an array [barsAgo] with a value of 5 when there are only 4 bars in the chart
      07/11/2023 0:07:22 CancelAllOrders: BarsInProgress=0
      Print(High[Math.Max(0, Swing(5).SwingHighBar(0, 1, 10))]);
      Print(Low[Math.Max(0, Swing(5).SwingLowBar(0, 1, 10))]);​
      y si dejo Math.Max no me da el ultimo swing bajo
      ​and if I leave Math.Max ​​it doesn't give me the last low swing

      Comment


        #4
        Hello franatas,

        You need to use Math.Max, not Math.Min. The purpose of that code is to make sure a 0 or greater value is used for the bars ago.

        Comment


          #5
          ​ Print("OTRA");
          Print(High[Math.Max(0, Swing(5).SwingHighBar(0, 1, 10))]);
          Print(Low[Math.Max(0, Swing(5).SwingLowBar(0, 1, 10))]);
          As you can see, the value doesn't work for me

          ​It gives me the value of the previous height, not the last one
          Attached Files

          Comment


            #6
            Hello franatas,

            You may need to increase the lookback period. If a swing if found it will pull the price from the series, if a swing is not found then the current high would be printed. You can print out the result of the method without access a price to see what bars ago is being found.

            Print(Swing(5).SwingHighBar(0, 1, 10));

            Comment


              #7
              correct, thank you very much

              Comment

              Latest Posts

              Collapse

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