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

Drawing Tools

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

    #16
    Hello tonynt,

    Thanks for your reply.

    Swing is a complex indicator and it does take some study (and testing) to get things figured out.

    Your results would be expected based on your coding. For example, this: recentLow = Swing(5).SwingLow[0]; provides the most recent occurrence of the swing low value while this: priorLow = Low[Swing(5).SwingLowBar(0, 1, 50)]; gets the most recent swing low bar and the low value which would be the same as Swing(5).SwingLow[0];. The swing low value will continue to remain the same on each bar until a new swing low is determined 5 bars after the actual swing low.

    The key here is to note that in the help guide for Swing(int strength).SwingLowBar(int barsAgo, int instance, int lookBackPeriod) The helpguide advises that instance = The occurrence to check for (1 is the most recent, 2 is the 2nd most recent, etc...)
    So by specifying 1 you are getting the most recent swing low bar. The "prior swing low bar" would be specified as 2.

    So all you need to do is to add 1 to each of the "instances" in your code:

    prior3Low = Low[Swing(5).SwingLowBar(0, 4, 50)];
    prior3High = High[Swing(5).SwingHighBar(0, 4, 50)];
    prior2Low = Low[Swing(5).SwingLowBar(0, 3, 50)];
    prior2High = High[Swing(5).SwingHighBar(0, 3, 50)];
    priorLow = Low[Swing(5).SwingLowBar(0, 2, 50)];
    priorHigh = High[Swing(5).SwingHighBar(0, 2, 50)];
    recentLow = Swing(5).SwingLow[0];
    recentHigh = Swing(5).SwingHigh[0];


    Please also note that you may need to test the bars ago overload for a value of -1 as noted in the helpguide if for example the 4th or 3rd occurrence is not found in the lookback period of 50.
    Paul H.NinjaTrader Customer Service

    Comment


      #17
      Hello,

      thank you for your reply. I my example code I show that I do add 1 to the instances. Maybe I did the question inaccurate in english so let me ask again referring to the example in this screenshot: what do I have to change for having the 3rd swing low here at 69.15 (which might not be the 3rd in order of prices but in order of occurence, which is what I´d like to achieve).

      Thank you
      Tony
      Last edited by tonynt; 07-26-2018, 12:20 PM. Reason: typing error

      Comment


        #18
        Hello Tony,

        Thanks for your reply.

        There would be two requirements you will need to specify/meet:

        1st you would need to specify the 3rd occurrence, for example, Low[Swing(5).SwingLowBar(0, 3, 50)];

        2nd, you may need to specify more than 50 bars for the look-back period. In looking at your screenshot from your previous post, the 3rd swing low appears to be more than 50 bars back from the latest bar on the chart. This is the situation where you would see a -1 returned for the value. You will need to code for the situation where the swing is not found in the lookback period.
        Paul H.NinjaTrader Customer Service

        Comment


          #19
          Paul,


          thank you for your reply. I have specified 3rd occurrence as you can see in my post, no?


          The misunderstanding persists: you reply me again what I would need to have for getting the 3rd swing low that appears to be more than 50 bars back from the latest bar on the chart. I was asking, and I do again, how I can get the "3rd" swinglow you can see at 69.15 in the screenshot. Maybe its not the "3rd" in your understanding, therefore I try to explain with the exmaple in the screenshot to get the value of the "3rd" in order of appearance/ the 3rd recent... I dont know anymore how to describe this in english.



          Thank you!
          Tony

          Comment


            #20
            Hello tonynt,

            Thanks for your reply.

            In order for you to read the 3rd swing low, you will need to increase the lookback period as I have been advising. I've added markings to your chart to illustrate each of the swing points and what occurrence number they are, I've shown the 50 bar look back period (yellow rectangle) to show that the 2nd and 3rd swing low are outside of the 50 bar lookback period and would return a -1 until you increase the lookback bars.

            Please let us know if you would be interested in having this created for you by a 3rd party code.
            Attached Files
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Rapine Heihei, Today, 08:19 PM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by Rapine Heihei, Today, 08:25 PM
            0 responses
            4 views
            0 likes
            Last Post Rapine Heihei  
            Started by f.saeidi, Today, 08:01 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by Rapine Heihei, Today, 07:51 PM
            0 responses
            6 views
            0 likes
            Last Post Rapine Heihei  
            Started by frslvr, 04-11-2024, 07:26 AM
            5 responses
            96 views
            1 like
            Last Post caryc123  
            Working...
            X