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 terofs, Yesterday, 04:18 PM
            1 response
            21 views
            0 likes
            Last Post terofs
            by terofs
             
            Started by CommonWhale, Today, 09:55 AM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by Gerik, Today, 09:40 AM
            2 responses
            7 views
            0 likes
            Last Post Gerik
            by Gerik
             
            Started by RookieTrader, Today, 09:37 AM
            2 responses
            13 views
            0 likes
            Last Post RookieTrader  
            Started by alifarahani, Today, 09:40 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X