• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Swing Indicator

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

    Swing Indicator

    Hello,

    I am using the Swing indicator and trying to programatically capture the bar at which a Swing begins.

    For instance, say I am looking at a chart and see that 9 minutes ago, a Swing High occurred and lasted for 7 bars (i.e. there are 7 green dots). How do I capture that the Swing commenced 9 bars ago? I just want to retrieve the bar at which the Swing began.

    Thank you.

    Isaac

    #2
    Hello,
    Thanks for posting today.

    This could be done by adapting the code from the Swing indicator, which is included in NinjaTrader, and tracking when the first item is plotted using a Boolean value such as isFirst = true;

    Once this first occurrence has occurred you can change that Boolean to false and no longer receive values that you do not need.

    Once you reset the swing plot you can then also reset your isFirst Boolean back to true so that it will be the first instance when it plots again.

    To adapt this code follow these steps.
    • From the Control Center>Tools>Edit NinjaScript>Indicators>Swing
    • Right mouse click and Save As... rename the indicator to create the custom indicator.
    • Adapt the code to meet your needs
    • Right mouse click and select Compile
    • This custom indicator will now appear in your list of default indicator and can be added to a chart

    Please let us know if we may be of further assistance for anything NinjaTrader.
    Alex G.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by ivb73077 View Post
      Hello,

      I am using the Swing indicator and trying to programatically capture the bar at which a Swing begins.

      For instance, say I am looking at a chart and see that 9 minutes ago, a Swing High occurred and lasted for 7 bars (i.e. there are 7 green dots). How do I capture that the Swing commenced 9 bars ago? I just want to retrieve the bar at which the Swing began.

      Thank you.

      Isaac
      The MRO method will help you here.

      Please refer to this thread:

      http://www.ninjatrader.com/support/f...ad.php?t=71828

      Edit: Alex and I posted at the same time. Alex has given a very effective method. The one I've suggested is a different approach.
      Last edited by arbuthnot; 05-25-2015, 09:10 AM.

      Comment


        #4
        Thank you.

        Before moving ahead, I wondered if you could provide some more clarity on the arguments taken by the Swing indicator. Specifically,

        barsAgo
        instance
        lookBackPeriod

        I have already seen this link: http://www.ninjatrader.com/support/h...html?swing.htm

        but remain a bit unclear of what the arguments refer to and how to populate them. The strength parameter tells us the number of bars before and after that are required to identify a swing. I am quite unclear as to how the lookbackPeriod works with this.

        Please provide some more detail or refer me to another source.

        Thank you.

        Comment


          #5
          Originally posted by ivb73077 View Post
          Hello,

          I am using the Swing indicator and trying to programatically capture the bar at which a Swing begins.

          For instance, say I am looking at a chart and see that 9 minutes ago, a Swing High occurred and lasted for 7 bars (i.e. there are 7 green dots). How do I capture that the Swing commenced 9 bars ago? I just want to retrieve the bar at which the Swing began.

          Thank you.

          Isaac
          The shipping Swing indicator, more or less directly gives you that information.
          #region Functions
          /// <summary>
          /// Returns the number of bars ago a swing low occurred. Returns a value of -1 if a swing low is not found within the look back period.
          /// </summary>
          /// <param name="barsAgo"></param>
          /// <param name="instance"></param>
          /// <param name="lookBackPeriod"></param>
          /// <returns></returns>
          public int SwingLowBar(int barsAgo, int instance, int lookBackPeriod)
          {...}

          Comment


            #6
            I will play around with it and see if I can get what I need.

            I still am unclear as to what the lookbackPeriod parameter does? Can you please provide some added detail of how this works? Thank you.

            Comment


              #7
              Originally posted by ivb73077 View Post
              I will play around with it and see if I can get what I need.

              I still am unclear as to what the lookbackPeriod parameter does? Can you please provide some added detail of how this works? Thank you.
              This is what the NTHelp says. I am not sure how else it can be explained any more clearly. What is the problem with the statement?
              Attached Files

              Comment


                #8
                Hello ivb73077,
                Thanks for the reply.

                The lookBackPeriod parameter determines how far back you would like to run the test condition.

                In other words, the swing indicator condition is testing on the current bar and then it will test if the condition is true for x number of bars back as indicated by the lookBackPeriod parameter. So if you set it to 5 as your lookBackPeriod, it will test on the current bar and then test on 1 bar back, 2 bars back, 3 bars back... until the 5th bar back is tested to determine if the condition is met.

                Please let me know if that clarifies that parameter definition or if we can offer further clarification or assistance.
                Alex G.NinjaTrader Customer Service

                Comment


                  #9
                  That is a very helpful reply. Thank you.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by pmmkm, Yesterday, 11:13 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post pmmkm
                  by pmmkm
                   
                  Started by pulpiwapi, 03-04-2019, 11:18 PM
                  11 responses
                  149 views
                  0 likes
                  Last Post music_p13  
                  Started by indy73, 06-25-2019, 10:52 PM
                  3 responses
                  20 views
                  0 likes
                  Last Post sledge
                  by sledge
                   
                  Started by priceisking, Yesterday, 12:51 PM
                  1 response
                  23 views
                  0 likes
                  Last Post NinjaTrader_PaulH  
                  Started by chartish, Yesterday, 10:33 AM
                  3 responses
                  30 views
                  0 likes
                  Last Post chartish  
                  Working...
                  X