Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ninja Swing Indicator Question

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

    #16
    Hello Bertrand

    I just sent you an email.

    Thanks

    Comment


      #17
      Hello

      I'm still struggling with the integration of the Swing indicator into my strategy.
      What I'm trying to achieve is really simple but for some reason it doesn't work.

      Concept: If two consecutive Swing Lines make a lower low pattern (see attached picture), the strategy should refrain from generating a Long Signal.

      If a generous soul could have a look at the attached picture & code and suggest a solution I'd be very grateful.

      Variables
      double SwingHigh;
      double SwingLow;
      bool SwingLong;
      private DataSeries sLow;
      private DataSeries sHigh;

      protected override void Initialize()
      {
      sLow = new DataSeries(this);
      sHigh = new DataSeries(this);
      CalculateOnBarClose = true;
      }

      protected override void OnBarUpdate()
      {

      sLow.Set(sLow[1]);
      if(Swing(3).SwingLow[0] != Swing(3).SwingLow[1] && Swing(3).SwingLow[0] != 0)
      sLow.Set(Swing(3).SwingLow[0]);

      sHigh.Set(sHigh[1]);
      if(Swing(3).SwingHigh[0] != Swing(3).SwingHigh[1] && Swing(3).SwingHigh[0] != 0)
      sHigh.Set(Swing(3).SwingHigh[0]);
      }

      if(Swing(3).SwingHigh[0] < Swing(3).SwingHigh[1])
      {
      SwingLong = false;
      }
      else
      {
      SwingLong = true;
      }



      //Black Arrow Long
      if (Close[0] > Open[0] && Close[1] < Open[1] && SwingLong == true)
      {
      DrawArrowUp("BlackArrowLongTest" + CurrentBar, false, 0, Low[0]- 2*(TickSize), Color.Black);
      }
      Attached Files

      Comment


        #18
        Laocoon,

        You will run into this with swing indicator. You can't see a swing low until future bars develop. If you wanted to evaluate it properly, you'd have to account for this and reference the SwingLong value 3 bars back (the amount of strength).

        This requires setting up a bool series so you can evaluate bool conditions x # of bars back.
        Ryan M.NinjaTrader Customer Service

        Comment


          #19
          RyanM,

          I did exactly what you are suggesting in your reply (see code in my previous post). I'm referencing the SwingLong value 3 bars back and I created a bool series. Still it doesn't work.

          Thanks

          Comment


            #20
            You're going to have to debug all these values. Print everything you're trying to compare to see what it's doing.

            Print (Swing(3).SwingHigh[0]);
            Print(Swing(3).SwingHigh[1]);
            Print(SwingLong[0]);

            SwingHigh[1] is not the high of the previous swing. It's just the value of the data series one bar back. You may want to look into SwingHighBar:

            Swing(int strength).SwingHighBar(int barsAgo, int instance, int lookBackPeriod)
            http://www.ninjatrader.com/support/helpGuides/nt7/swing.htm

            Ryan M.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            600 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            346 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
            558 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