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

A Real Swing Indicator

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

    A Real Swing Indicator

    Dear Support,

    I am looking for a real swing indicator where the low or high swings are plotted only once and not repeated (as in default swing indicator) before an opposite swing is plotted. Can the current default swing be edited so that this objective is met?

    Thanks.

    #2
    Can you provide any screenshots to explain what you mean by "plotted only once and not repeated"?

    Does the ZigZag indicator not do what you want?

    Comment


      #3
      Hello aligator,

      I'm not quite understanding your meaning by "low or high swings are plotted only once and not repeated ", but yes, you can absolutely make a copy of the Swing indicator and change the logic however you would like.

      To make a copy of a script, open the script in the NinjaScript Editor (click New -> NinjaScript Editor, then double click Indicators, then double click Swing).
      Right-click the code within the editor -> select Save As
      Give the script a new unique name -> click Save
      In the new copy you can change the logic however you would like.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_ChelseaB View Post
        Hello aligator,

        I'm not quite understanding your meaning by "low or high swings are plotted only once and not repeated ",
        Originally posted by bltdavid View Post
        Can you provide any screenshots to explain what you mean by "plotted only once and not repeated"?

        Does the ZigZag indicator not do what you want?
        Ok, I will try:

        Just plot the default Swing indicator on a 5 min (or any) chart. You will notice that in some situations there are more than one swing high between two swing lows (or the opposite) as shown in the following example sequence:

        The default swing looks like:

        SwingH - SwingL -SwingH - SwingH - SwingL - SwingH, etc. (swing high or low repeated)

        and a correct swing is like the following:

        SwingL - SwingH - SwingL - SwingH - SwingL - SwingH - SwingL - SwingH, etc. (no repeats).

        Here is a picture:

        Click image for larger version  Name:	AAPL (10 Minute) 2019_12_16 (6_22_45 PM).png Views:	0 Size:	57.0 KB ID:	1081172
        Last edited by aligator; 12-16-2019, 08:37 PM.

        Comment


          #5
          I think the ZigZag indicator has the "no repeat" quality you seek ... does it not?

          Comment


            #6
            Originally posted by NinjaTrader_ChelseaB View Post
            Hello aligator,

            I'm not quite understanding your meaning by "low or high swings are plotted only once and not repeated ", but yes, you can absolutely make a copy of the Swing indicator and change the logic however you would like.

            To make a copy of a script, open the script in the NinjaScript Editor (click New -> NinjaScript Editor, then double click Indicators, then double click Swing).
            Right-click the code within the editor -> select Save As
            Give the script a new unique name -> click Save
            In the new copy you can change the logic however you would like.
            Hi ChelseaB,

            I hope the chart markings in my post #4 illustrate what I mean by repeated high or lows . Perhaps "2 or more successive High Swings after a Low Swing" is a better definition for repeated High Swings. Similarly for successive low swings.

            What I am looking for is a couple of line code to modify the Swing indicator to plot a swing high or swing low only once after a swing low or swing high, respectively.

            The ZigZag indicator is based on percentage or points price change and is not really a swing indicator for this purpose.

            Many thanks

            Comment


              #7
              Hello aligator,

              Unfortunately, in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. This is so that we can maintain a high level of service for all of our clients as well as our partners.

              That said, I am happy to answer any questions you may have about NinjaScript if you decide to code this yourself.

              This thread will remain open for any community members that would like to write this code as a convenience for you.

              You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.



              That said, you are saying you would like to prevent a new high swing if the previous swing is not a low swing, is this correct?

              Perhaps you could use a bool that when the swing is a high swing is set to true and when there is a low swing set to false.. Then in the conditions for high swing require the bool to be false and in the conditions for a low swing require the bool to be true.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_ChelseaB View Post
                Hello aligator,

                Unfortunately, in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. This is so that we can maintain a high level of service for all of our clients as well as our partners.
                Thank you Chelsea,

                After so many years with NinjaTrader, I thinks I understand the policy and I was not asking to create, debug, or modify the code or logic for me. I was basically asking if such code or logic exist.

                The default swing indicator in its current logic is not what it is supposed to be as a true swing indicator and is not suitable for any system development. The following is a definition for a correct swing indicator that will not create successive highs or lows:

                The Ultimate Trading Guide; by John R. Hill, George Pruitt, and Lundy Hill
                published (2000) by John Wiley and Sons, Inc, ISBN 0-471-38135-7

                "A swing high bar is the highest high prior to penetration of the low
                of that highest high bar. A swing low bar is the lowest low prior to
                penetration of the high of that lowest low bar."

                This concept is used by gurus like Larry Williams, etc. and other trading greats. This definition can be applied to NT default Swing indicator and use a 'Strength' parameter for swing size variability.
                As the size of 'Strength' increases, it causes the indicator to ignore the smaller swings, as in the current NT Swing indicator. The result will be a real swing indicator suitable for including in system building.

                The following picture shows a swing ZigZag that I modified based on the above concept compared to the NinjaTrader default Swing indicator for a Strength size of 5. Please notice the marked successive swing highs or lows produce by default Swing indicator compared to the drawn ZigZag line from the mahSwing.

                Cheers!
                Attached Files

                Comment


                  #9
                  Chelsea B.
                  On the same issue of using Swing and ZigZag, could you please explain the following:

                  1. When calling Swing / ZigZag functions inside OnRender(), the results are all -1. ( note the checking of the bBarUpdated variable inside OnRender() ).

                  2. If the Swing / ZigZag functions are called at least once inside OnBarUpdate() at CurrentBar == Count-2, the correct results are returned from the Swing / ZigZag functions when called inside OnRender().

                  Attached is the test indicator file showing the above.
                  Attached Files

                  Comment


                    #10
                    Try something like,

                    Code:
                    protected override void OnBarUpdate()
                    {
                        if (CurrentBar < iSwing_Strength)
                            return;
                        bBarUpdated = true;
                    }
                    Does that work?

                    Comment


                      #11
                      Hello kkc2015,

                      When calling series information from a non-data-driven method like OnRender(), TriggerCustomEvent() must be used.

                      Below is a link to the help guide.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Chelsea B.
                        Thanks for the quick response, which allows me to ensure the functionality of my custom indicator without relying on a dummy function call inside OnBarUpdate(). Much appreciated.

                        bltdavid,
                        Thanks for the suggestion. The bBarUpated was already confirmed to be true inside OnRender(), where the calls to the Swing / ZigZag were made. Without synchronizing all internal pointers by TriggerCustomEvent(), it is not probably to ensure the integrity of return data from the calls to other indicators.

                        Comment


                          #13
                          Originally posted by NinjaTrader_ChelseaB View Post
                          Hello kkc2015,

                          When calling series information from a non-data-driven method like OnRender(), TriggerCustomEvent() must be used.

                          Below is a link to the help guide.
                          https://ninjatrader.com/support/help...ustomevent.htm
                          Hi Chelsea,

                          Before diverging too far from the original question in post #1, further explanation in posts # 4, and an actual comparison in post #8, please comment on the real question that the default Swing indicator is not a real swing indicator and incorrectly draws successive high pivots and low pivots.

                          Please see the screenshot in post #8. Every high swing must be followed by a low swing and every low swing must be followed by a high swing as in the ZIgZag line. The default Swing indicator draws successive high and low swings shown. Both plots have a Strength of 5.

                          Thanks.

                          Comment


                            #14
                            Hello aligator,

                            To confirm, you are stating that the Swing indicator included with NinjaTrader has incorrect calculations?

                            On your chart, the swing indicator is not plotting from the highest high until a reversal to the lowest low until a reversal?
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_ChelseaB View Post
                              Hello aligator,

                              To confirm, you are stating that the Swing indicator included with NinjaTrader has incorrect calculations?

                              I assume the Default Swing calculations are OK. But the logic is not correct. The definition for a correct and real swing is simply:

                              "a high swing point should follow a low swing point and a low swing point should follow a high swing point." See black ZIgZag line in Post #8

                              However, as you can see in Posts #4 and #8, the default NT Swing indicator plots multiple highs after a low and multiple lows after a high, as marked in circles.


                              On your chart, the swing indicator is not plotting from the highest high until a reversal to the lowest low until a reversal?

                              No. The black swing line is based on the rule in post #8 and applies a "Strength" for swing variability. See the attached ZigZagUTC.zip indicator.

                              Thanks.
                              Here is the ZigZagUTC indicator, it plots a true swing zigzag line with no repeated high or low points:
                              Attached Files
                              Last edited by aligator; 09-14-2020, 02:43 PM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              170 responses
                              2,273 views
                              0 likes
                              Last Post sidlercom80  
                              Started by Irukandji, Yesterday, 02:53 AM
                              2 responses
                              17 views
                              0 likes
                              Last Post Irukandji  
                              Started by adeelshahzad, Today, 03:54 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post adeelshahzad  
                              Started by CortexZenUSA, Today, 12:53 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post CortexZenUSA  
                              Started by CortexZenUSA, Today, 12:46 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post CortexZenUSA  
                              Working...
                              X