Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Swing High

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

    Swing High

    Im trying to enter a position only if the most recent swing high is higher than the swing high before that. I thought this would work, but I must be on the wrong track...

    Swing(5).SwingHigh[0]>Swing(5).SwingHigh[1]

    If I add this then it wont enter at all.

    #2
    That line is checking the current bar's swing value with the previous bar's swing value. This is probably not what you want since the current bar's swing high will most likely be the same as the previous bar's unless it just happened to be the place where the swing changed.

    Instead you want to use this syntax:
    Swing(int strength).SwingHighBar(int barsAgo, int instance, int lookBackPeriod)

    An instance of 1 = most recent high. 2 = previous high. Please refer to the Help Guide article on Swing for further examples.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Swing High

      Thanks Josh, the wizard only has Input Series, Strength, Bars Ago and Offset, so I would have to unlock the code to add that then?

      Comment


        #4
        Features beyond the scope of the wizard can be used as you unlock the code.

        Comment


          #5
          Unlock the Strategy

          Ive unlocked it and tried to change the code.
          I was able to add the swing high bar
          Swing(5).SwingLowbar(0,1,20) > Swing(5).SwingLowbar(0,2,100)

          but then got an error saying it isnt defined.

          Currently it looks like this.
          Add(Swing(5));

          Ive tried changing it andwas only able to come up with the following.
          Add(Swing(5).SwingHighBar(0,1,100));

          This gives me a different error though.

          Comment


            #6
            - not sure what you are trying to achieve by adding Swing: Add(Swing..)).
            - it always helps as you post exact and complete error messages on your reports
            - note the capitalization of your NS code
            Swing(5).SwingLowBar(0,1,20) > Swing(5).SwingLowBar(0,2,100)
            - I suggest using the editor intellesense to verify the correct spelling of NS methods

            Comment


              #7
              Capitilization

              Dierk, Thanks, I went back and checked it. Seems the capitalization was where I had gone wrong.

              Comment


                #8
                Ive managed to get the code right (well at least it verifies)

                && Swing(5).SwingLowBar(0,1,20) > Swing(5).SwingLowBar(0,2,100))

                The above filter is for a Long entry, the theory behind it a new HL is required before taking a long position.

                && Swing(5).SwingHighBar(0,1,100) < Swing(5).SwingHighBar(0,2,100)
                for a short entry

                However after applying it, it doesnt seem to be having the desired effect.
                (I would post a chart to show what I mean except Im not sure how.)
                It still enters short even after a HH has been made and most of the long entries have dissappeared completely.

                Comment


                  #9
                  For your lookback parameter try just using CurrentBar. That way it will just look all the way back to the beginning of the chart.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    I would like to enter a position if the close is below the most current Swing Low. Would the following code be correct?

                    if (Close[0] < Swing(5).SwingLow[0])
                    {
                    EnterShort(DefaultQuantity, "");
                    }

                    Comment


                      #11
                      I believe that woudl be correct but to confirm, I suggest print out values to the Output window and correlate to the chart to ensure it is what you expect...

                      Print(Swing(5).SwingLow[0]);
                      RayNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      649 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      370 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      109 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      574 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      576 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X