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

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 carnitron, Today, 08:42 PM
            0 responses
            5 views
            0 likes
            Last Post carnitron  
            Started by strategist007, Today, 07:51 PM
            0 responses
            6 views
            0 likes
            Last Post strategist007  
            Started by StockTrader88, 03-06-2021, 08:58 AM
            44 responses
            3,974 views
            3 likes
            Last Post jhudas88  
            Started by rbeckmann05, Today, 06:48 PM
            0 responses
            8 views
            0 likes
            Last Post rbeckmann05  
            Started by rhyminkevin, Today, 04:58 PM
            4 responses
            58 views
            0 likes
            Last Post dp8282
            by dp8282
             
            Working...
            X