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

Previous Swing High

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

    Previous Swing High

    Hi Guys, I was wondering how to get the previous swing high ? I have this code for the current swing high:

    Print("The high of the swing bar is " + High[Math.Max(0, Swing(5).SwingHighBar(0, 1, 10))]);

    Thanks
    DJ

    #2
    Hi DJ, you would then refer back to one instance higher of the Swing High Bar found - http://www.ninjatrader.com/support/h.../nt7/swing.htm
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Previous Swing ValuesSwing

      Hi and thanks Bertrand. Changing the instance from 1 to 2 is exactly what I did. For example this is what I tried including numerous other iterations:

      DrawTextFixed("updowntick1",(High[Math.Max(1, Swing(5).SwingHighBar(0, 2, 10))]).ToString("N1"), bPosition,Color.White,textFontLarge, Color.Black, Color.Lime, 10);

      DrawTextFixed("updowntick2",(Low[Math.Max(1, Swing(5).SwingLowBar(0, 2, 10))]).ToString("N1"), blPosition,Color.White,textFontLarge, Color.Black, Color.Lime, 10);

      Attached is the chart. I was expecting to see values of 691.5 for the previous swing high and 685.9 for the previous swing low. Instead I got 681.9 and 684.0 respectively which I cannot make sense. I tried to increase look back period from 200 to 100 but that didn't help either. Am I missing the obvious here?

      Thanks
      DJ
      Attached Files

      Comment


        #4
        DJ, please take a look at my screenshot attached - you would need to keep in mind when those levels would become accessible / known in realtime, the Swing indicator itself is more used as a visual chart aid to define market structure and as the chart progresses indicator values could be recalculated.
        Attached Files
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Hey Bertrand,

          I am having a similar problem today, i hope you don't mind if i add to this thread.

          I'm simply trying to figure out (as a starting point) if the current swing high is higher or lower than the previous swing high. I would have thought this would have done it, based on the document at http://www.ninjatrader-support.com/H...ide.html?Swing

          So, here's what i tried:

          Code:
          if (High[Math.Max(0, Swing(5).SwingHighBar(0, 1, 50))] > High[Math.Max(0,Swing(5).SwingHighBar(0, 2, 50))]) Trend = Trend++;
          else Trend = Trend--;
          That didn't seem to work. I plot Trend, and it never goes above or below 0.

          I tried a few other ideas, variations of the above, but no luck. Am i missing something? Perhaps there's something about that help document i'm not getting. Do you have any idea how to accomplish this?

          Thanks!

          Comment


            #6
            Swings

            Thanks Bertrand. Actually it does work after all. Here you go Mr Orange. I have put the value on the top left as per this piece of code. The values line up to my chart.

            Cheers
            DJ
            Attached Files
            Last edited by djkiwi; 09-15-2011, 08:05 PM.

            Comment


              #7
              Hi Bertrand, although it does work it's not doing what I want it to achieve after all. For example if you please look at the attached chart. You will see solid cyan lines below the price where the swing high has been breached I also have dotted cyan lines above the price which is the next swing high target. What I am trying to do is get the value of that next dotted swing high target above which is not necessarily the last swing high or even 5 swing highs back. Any ideas on this one would address a long outstanding issue.

              Thanks in advance
              DJ
              Attached Files

              Comment


                #8
                DJ, glad to hear that worked - so you're trying to get the next price value where a prior swing high / low was found?
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Swing High

                  Hi Bertrand, yes exactly. How do I get the the next highest swing high above the current price? i.e one that hasn't already been breached.

                  Cheers
                  DJ

                  Comment


                    #10
                    Originally posted by djkiwi View Post
                    Hi Bertrand, yes exactly. How do I get the the next highest swing high above the current price? i.e one that hasn't already been breached.

                    Cheers
                    DJ
                    You would likely have to create an ArrayList of the SwingHighs and of the SwingLows. Then test the ArrayList for the most recent Swing value that is outside the current price.

                    Comment


                      #11
                      DJ, thanks for the code! One of the segments in it did just what i wanted!

                      Comment


                        #12
                        Swing array

                        Hi Koganam and Bertrand, does anybody have any samples on how to do this array list? I don't have a clue on where to start.

                        Thanks
                        DJ

                        Comment


                          #13
                          Hi DJ, a quick google search yielded some samples - http://www.dotnetperls.com/arraylist.
                          AustinNinjaTrader Customer Service

                          Comment


                            #14
                            Hi Austin.thanks for the examples but I am unsure how to apply them to ninjatrader. Does anybody have an example relevant to ninjatrader? For example how would this apply to the unviolated swing highs and lows?

                            using System.Collections; class Program { static void Main() { // // Create an ArrayList and add three elements. // ArrayList list = new ArrayList(); list.Add("One"); list.Add("Two"); list.Add("Three"); } }

                            Thanks
                            DJ

                            Comment


                              #15
                              HI DJ,

                              Arraylists are used in this sample.


                              Unfortunately we do not have a specific example storing swing points with them.
                              Ryan M.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by ghoul, Today, 06:02 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post ghoul
                              by ghoul
                               
                              Started by Barry Milan, Yesterday, 10:35 PM
                              6 responses
                              18 views
                              0 likes
                              Last Post Barry Milan  
                              Started by DanielSanMartin, Yesterday, 02:37 PM
                              2 responses
                              13 views
                              0 likes
                              Last Post DanielSanMartin  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              4 responses
                              13 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by terofs, Today, 04:18 PM
                              0 responses
                              12 views
                              0 likes
                              Last Post terofs
                              by terofs
                               
                              Working...
                              X