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

Swing parameters

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

    Swing parameters

    First off can I use the BarsArray as I do below? It compiles fine but just wanted to make sure.

    (Low[Math.Max(0, Swing(BarsArray[1], 3).SwingLowBar(1, 2, 10))])

    Also I'm confused on the lookbackperiod to use. If I'm looking for the 2nd most recent pivot with 10bar lookback as above, if the 2nd most recent pivot that formed is now 15 bars back will it just ignore it even if there isn't a new 2nd occurrence or pivot that formed yet?

    #2
    Hi Zachj,

    Thank you for your post.

    Yes, this is the correct way to use the BarsArray.

    The look back period is to tell the function to calculate and use those values for the amount of bars that you specify.

    For the pivots, are you referring to the swings from the Swing indicator?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Yes referring to the swings. But I guess what my question is, after it calculates a swing does that swing expire after the lookback period is passed(i.e after 10 bars as I used below)? Or will it only expire if a new 2nd occurrence swing is formed?

      Comment


        #4
        Zachj,

        If the lookback does not have the swing in that period it will return a -1 value.

        http://www.ninjatrader.com/support/h...html?swing.htm
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          I want to make sure it's looking back at least 3 hours or so. So if I'm using 5min bars that would be a 36bar lookback period. Will this cause any issues or errors at the start of the session when there are 0 previous bars?

          Comment


            #6
            Zachj,

            Just ensure that you have a CurrentBar check for greater than 36 so that you have enough bars to run your calculations.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Is it going to check back into the previous day? Otherwise if it resets every new session than I wouldn't be able to make a trade until 1230 pm which isn't practical.

              Comment


                #8
                Zachj,

                The current bar check is based on the amount of bars that you have on the chart. Meaning that if you load 5 days or more you will have plenty of bars for the script to calculate.
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  Actually is this correct below. I see you would use High[Math.Max(0, Swing...)] to find the high of the high swing bar but to find the low of the low swing bar is Low[Math.Max(0, Swing...)] correct? Or should I be using something like Low[Math.Min(1000, Swing...)].

                  (Low[Math.Max(0, Swing(BarsArray[1], 3).SwingLowBar(1, 2, 10))])

                  My print statements are not coming out correct.

                  Comment


                    #10
                    The math.Max just makes sure that you don't call something that would be invalid. Either it will be 0 (this bar) or it will be the bar that the swing returned which would greater then 0 in the that many bars in the past.

                    You would use the Math.Max on the Low[] side as well.

                    However-> If there is no swing low/high found you will return the current bar instead of not doing anything for example. This may be whats throwing off your script. If you don't want to do anything if there is no swing high/low found currently then you needed to return out if the value returned from .SwingLowBar is > 0. Which per docs here it returns -1 is no swing low/high found.

                    Comment


                      #11
                      When I use Swing(BarsArray[1], 3).SwingLow[0] the print output show the correct swing low value for the most recent swinglow but when I use..
                      (Low[Math.Max(0, Swing(BarsArray[1], 3).SwingLowBar(0, 1, 10))])
                      it prints the incorrect number.

                      Shouldn't these two be printing the same swinglow value? Only reason I'm trying to use the later more complicated script is because I need to be able to check for a 1st occurrence swinglow > 2nd occurrence swinglow. And I guess I can't do that with the first statement unless I have another swinglow that starts back say 10 bars ago. But that could cause issues.

                      Comment


                        #12
                        Yes would expect they return the same low.

                        Try

                        (Low[Math.Max(0, Swing(BarsArray[1], 3).SwingLowBar(0, 0, 10))])

                        As it seems instance you are feeding 1 which would be the previous instance.

                        Comment


                          #13
                          Are you sure, in manual it says..

                          instance
                          The occurrence to check for (1 is the most recent, 2 is the 2nd most recent, etc...)

                          Comment


                            #14
                            I must be mistaken then apologies,

                            In that case last idea I got without debugging is to up the lookback period. Try something like 50 any change?

                            If not then can you let me know what bar value is being returned and also what bar the swing is actually on? Does the bar being returned correlate to any previous swing value or anything like that? Basically trying to isolate exactly what value you are getting and try to find out which one is off and what its actually reporting to give us a hint to where to go next.

                            -Brett

                            Comment


                              #15
                              That's the thing it doesn't seem to correlate to any swing at all, the number in the output is nearby a swing but it's off by many ticks. And I had it at 20 bars back in which period there is 2 or 3 swings. And the simpler value swing script is picking them up in the output print out correctly. I may have to stick with the value swing and add some other conditions to make sure the swings are not too far back.

                              Was trying to figure out how to make sure that Swing(BarsArray[1], 3).SwingLow[0] is not more than 5 bars back, not sure how to do this. And then check for a 2nd occurence by doing Swing(BarsArray[1], 3).SwingLow[10] which starts checking 10 bars back.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by lightsun47, Today, 03:51 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post lightsun47  
                              Started by 00nevest, Today, 02:27 PM
                              1 response
                              8 views
                              0 likes
                              Last Post 00nevest  
                              Started by futtrader, 04-21-2024, 01:50 AM
                              4 responses
                              44 views
                              0 likes
                              Last Post futtrader  
                              Started by Option Whisperer, Today, 09:55 AM
                              1 response
                              13 views
                              0 likes
                              Last Post bltdavid  
                              Started by port119, Today, 02:43 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post port119
                              by port119
                               
                              Working...
                              X