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 Indicator NT8

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

    Swing Indicator NT8

    Is there any way to adjust the plot options of the swing points? I want to only have one circle at the swings rather than multiple ones going across.

    For example, instead of seeing this: ............ I would like to see just .
    Any help would be greatly appreciated.

    Thanks

    #2
    Swing is an NT coded indicator. This means you cannot make changes to it.
    The dots continue to draw until the swing value is broken. To make changes, you will need to make a copy of the indicator.

    For a quick fix... edit out lines 252 and 253 and that should stop the low swing dots continuing.
    Editing out lines 234 and 235 should stop the high swing dots.

    Note that I haven't tested this out. I just gave a quick look and I think that might do the job for you.
    To do this properly, you will have to spend some time and actually modify the code.

    Comment


      #3
      Hi Vozdovac,

      Zeos6 is on the right path. You should make a copy first.

      Below is a link to a video.
      Dive into manipulating C# code from within an unlocked NinjaScript strategy using the NinjaScript Editor.3:11 Creating a New NinjaScript Strategy13:52 Analyz...



      This script changes its plots values historically after the bar has passed.

      The swing is detected a few bars after its started, then the script loops through the previous bars and changes the plot.

      Where its running through those loops, you would want to make sure it only sets the plot for the current bar.

      I'll need to do some trial and error and test this but it might be more complicated than expected and I'd like to assist.

      I appreciate your patience while I do some testing.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Hello Vozdovac,

        Thank you for your patience on this item.

        I modified the Swing indicator to plot only 1 dot at its Strength lookback point. Please see the attached example.

        This required that I removed the for loop that would fill in the plot from the current bar back to the Strength setting on line 148 and 190.

        Then I removed the logic that filled in the swing value until the next high/low was reached on line 158 and 200.

        Please let me know if you have any questions about this modification.
        Attached Files
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Hello,

          It seems that Swing indicator works fine with "Price" series and also with Open Source indicators (like Stochastic).

          However, it seems that it doesn't work with 3rd party vendors when trying to use their dataseries as an input (in these cases it seems that the line of code doesn't work correctly):
          double high0 = (Input is Indicator || Input is Series<double>) ? Input[0] : High[0];

          I am using NT8 13.1.

          Thanks

          Comment


            #6
            Hello music_p13,

            Thanks for the note.

            Can you look at the code for the third party indicator? It is possible that the series they are using is not a Series<double> but a Series<some other type>, and if you try to set an double to something like an int, it will not work unless you cast the input value to a double.

            I look forward to your reply.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Hello,

              I found another issue with Swing Indicator (probably related, haven't got to the first one yet but I think it is related). It is not recognizing BarsArray[0] as PriceSeries when adding it from strategy... so it basically using "Close" series instead of High/Low of Price series for Swing Indicator.

              Please see screenshots attached.
              Attached Files

              Comment


                #8
                Hello music_p13,

                Thanks for the reply.

                When you supply an input to the swing array, that is what will happen. Swing sees that you supplied an input so it will use Input[0] for everything. If you just want to use the High and Low of the input series, pass no input to the Swing indicator.

                Please let us know if we may be of any further assistance.
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  I don't know if that is related, but after adding Swing indicator to the strategy and using it as a trailing stop (or in fact doing other things as well) - as soon as I start running optimization on more than 8 iterations I started getting error Strategy 'X': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.

                  Is that related to "Swing" indicator that it cannot be heavily optimized? Just started getting these errors today consistently after adding swing indicator to strategy...

                  I do have 8 core CPU - so I am wondering what is happening when running more than 8 optimization cycles...

                  I was running with modified version of "Swing" indicator by basically removing checks "Is PriceSeries" and automatically getting High/Low but don't think that is the reason... Is there any "Optimization" setting I should set at indicators level? I did change strategy setting "IsInstantiatedOnEachOptimizationIteration = false;" and maybe that is what has started causing errors for some indicators...?

                  Thanks

                  Comment


                    #10
                    And Yes, I changed the "IsInstantiatedOnEachOptimizationIteration" within strategy to "True" and it all started working again...

                    Thanks

                    Comment


                      #11
                      Hello music_p13,

                      Thanks for the reply.

                      I was able to use the Swing indicator in my sample script.

                      Please compare the attached script to yours. It is simply a modification of the SampleMA crossover strategy with a swing indicator added and used.
                      Attached Files
                      Chris L.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks for all the replies! Just saw this..

                        Comment


                          #13
                          Hello,
                          Does anyone happen to have the swing indicator with price plotted on the swing? Or is there a way the indicator could be modified to show price as well? Thanking, Mukaddim

                          Comment


                            #14
                            Hello Mukaddim,

                            Thanks for your post.

                            In a quick check of the "User Apps" (accessed in the User Apps in the red banner at the top of the page) I did not see a swing variant that provided the price of the swing. You are welcome to review these user apps in detail. Please note: The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

                            You can certainly create an indicator that uses the swing indicator and can use the Draw.Text() method to print the values on the chart. You would access the swing methods to determine the swing high/low bar as well as the swing high/low price. I'll provide help guide links to those methods (Swing and Draw) below:



                            It would also be possible to make a copy of the Swing indicator and modify the code to also draw the price data on the chart, also using Draw.Text(). Please note that we do not provide coding or debugging services.

                            If you would like the indicator created or modified, we can provide references to 3rd party programmers who can perform this service.
                            Paul H.NinjaTrader Customer Service

                            Comment


                              #15
                              Dear PaulH,
                              Thank you so very much for your detailed reply. I'm going through the links you provided to see if it can be made according to what I need.

                              On a different note, do you have any suggestion/examples to make it Multi Time Frame, that user can select from indicator UI?
                              Mukaddim
                              Last edited by Mukaddim; 08-15-2019, 11:29 PM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by algospoke, 04-17-2024, 06:40 PM
                              3 responses
                              26 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by bmartz, 03-12-2024, 06:12 AM
                              3 responses
                              27 views
                              0 likes
                              Last Post NinjaTrader_Zachary  
                              Started by Aviram Y, Today, 05:29 AM
                              2 responses
                              8 views
                              0 likes
                              Last Post Aviram Y  
                              Started by gentlebenthebear, Today, 01:30 AM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by cls71, Today, 04:45 AM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X