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 and strategy builder

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

    #16
    Hello aprendiz,

    Thanks for your reply.

    is posible to set the following value to a variable?

    Variable = (Swinghigh-Swinglow) * 3 / 7

    Yes it is possible but not easily done in the Strategy Builder.

    Math is accomplished by using the "Offset" function. Please see the Strategy Builder help guide section " How to offset an item value" on this page: https://ninjatrader.com/support/help...on_builder.htm

    However you would not be able to accomplish (Swinghigh-Swinglow) * 3 / 7 in one step. Also using a variable does not allow you to offset.

    To accomplish your goal you would need to create 3 custom series (double type) in the "Additional data" window in the Custom series section.

    In a set without conditions (The sequence is important):
    1) Assign the first custom series to the swing high and you offset the swing high by subtracting the swinglow
    2) Assign the 2nd custom series to the first custom series and offset by multiplying times 3
    3) Assign the 3rd custom series to the 2nd custom series and offset that by dividing by 7.
    The 3rd custom series would then represent (Swinghigh-Swinglow) * 3 / 7

    I've attached an example of what the finished set would look like:


    Click image for larger version

Name:	aprendiz-3.PNG
Views:	416
Size:	8.6 KB
ID:	1078263

    Note: When assigning a custom series to a custom series, you will have to look in the Misc>Custom series> and select the series to use as the input.
    Paul H.NinjaTrader Customer Service

    Comment


      #17
      Thanks.

      Already done, but now I would like to know if I can draw a line similar as the swinghigh?

      This is what I'm trying but nothing hapens....

      This are the lines I want to draw: LineHigh and LineLow are variables (double)

      Click image for larger version

Name:	set 2 lines variables.png
Views:	422
Size:	21.0 KB
ID:	1078273

      And this is what i'm trying and not working:


      Click image for larger version

Name:	set3 drawing lines.png
Views:	413
Size:	26.0 KB
ID:	1078274

      Not sure about parameters:

      Click image for larger version

Name:	drawing line parameters.png
Views:	411
Size:	35.1 KB
ID:	1078275
      Thanks again for your help

      Comment


        #18
        Hello aprendiz,

        Thanks for your reply.

        The line you are drawing has the same start and end bars ago, of 0 (zero) so nothing can be drawn.

        You might trying using the bars ago set to the same as the strength setting of the swing indicator.

        Paul H.NinjaTrader Customer Service

        Comment


          #19
          Hello,
          I'm using the Strategy Builder and trying to find the last 4 swing highs and lows using the "Swing" indicator. I need to track those swing points. I'm a complete novice and have tried searching for a possible solution but have not found any answer (that I understand). Any help would be greatly appreciated.
          Thank you for anyone's time in helping with this.

          Comment


            #20
            Hello laoshr,

            Thanks for your post.

            The Swing indicator, in the strategy builder, is limited to providing the current swing high or swing low values.

            To keep track of the last 4 swing high values you would need to create 4 double type variables. Named, for example SH1, SH2, SH3, SH4. In a set, you would check to see if the current swing high is NOT equal to SH1. When that condition is true the action then would be to assign SH4 = SH3, SH3 = SH2, SH2 = SH1, and SH1 = to the latest swing high. So you end up shifting back the swing highs when a new one is found. You would follow the same process for the swing lows but using different variables.

            Note that you would need to shift them in order. Here is an example screenshot of what that would look like:

            Click image for larger version

Name:	laoshr-1.PNG
Views:	351
Size:	28.2 KB
ID:	1170282
            Paul H.NinjaTrader Customer Service

            Comment


              #21
              Thank you, Paul
              I was on the right track but was missing to check if the current is not equal.
              Thank you for your time.
              James

              Comment


                #22
                Hello Paul,
                I got the swings recording correctly. I was trying to figure out the best option (for a novice) to have the swing High and Lows stay printed on the chart until there is a close above a swing high or below a swing low. Currently whenever there is a new High or Low the previous High or Low stops printing across the screen.
                Thank you for your time.
                James
                Last edited by laoshr; 09-09-2021, 09:11 PM.

                Comment


                  #23
                  Hello James,

                  Thanks for your reply.

                  There is no means to change the indicator behavior from a strategy.

                  For a visual presentation, you could add another indicator called SwingRays that, when using the same strength setting, will draw rays to the right edge of the chart and when crossed by price will redraw the ray to be a line from the start point to the price where it crossed. Again this is a visual only indicator as it does not provide an output a strategy can use.

                  This indicator is publicly available on our NinjaTrader Ecosystem website:
                  Here is a basic guideline of how to import NinjaScript add-ons in NinjaTrader 8:

                  Note — To import NinjaScripts you will need the original .zip file.

                  To Import:
                  1. Download the NinjaScripts to your desktop, keep them in the compressed .zip file.
                  2. From the Control Center window select the menu Tools > Import > NinjaScript Add-on...
                  3. Select the downloaded .zip file
                  4. NinjaTrader will then confirm if the import has been successful.

                  Critical - Specifically for some NinjaScripts, it will prompt that you are running newer versions of @SMA, @EMA, etc. and ask if you want to replace, press 'No'

                  Once installed, you may add the indicator to a chart by:
                  • Right-click your chart > Indicators... > Select the Indicator from the 'Available' list on the left > Add > OK

                  Here is a short video demonstration of the import process:
                  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.
                  Paul H.NinjaTrader Customer Service

                  Comment


                    #24
                    Thanks, Paul.
                    I did find the swingrays indicator that you created . I have a few questions.
                    If I'm using the strategy builder can I use the swingrays to plot on the chart?
                    Then if I move the strategy to an indicator will the swingrays still plot on the chart?
                    If it is possible to use the swingrays and plot on the chart, can I use a color and style plot that we discussed in our other thread on color plots?
                    Thank you for your expertise and time.
                    James

                    Comment


                      #25
                      Hello James,

                      Thanks for your reply.

                      Clarification: I did not create the original indicator which was/is available in NinjaTrader7, I converted it for use in NinjaTrader8 as a courtesy for the community when we launched NinjaTrader8.

                      If I'm using the strategy builder can I use the swingrays to plot on the chart?
                      Yes, you can do this by creating a new set and adding a condition of Indicator>SwingRays, equals, Misc>Numeric Value, 0. To show the indicator, you will have to check the "plot on chart" option. Please note that this is a bogus condition and is only used so you can click the "Plot on chart" option. This option merely adds the indicator to the chart as a convenience factor for you, it has no value in the Strategy Builder.

                      Then if I move the strategy to an indicator will the swingrays still plot on the chart?
                      To clarify, if you convert a strategy to an indicator then no you cannot use AddChartIndicator() in an indicator (AddChartIndicator() is what the strategy builder is doing for you when you select Plot on chart).

                      If it is possible to use the swingrays and plot on the chart, can I use a color and style plot that we discussed in our other thread on color plots?
                      I'm not sure I understand what you are wanting to do specifically, can you clarify?

                      Paul H.NinjaTrader Customer Service

                      Comment


                        #26
                        Thanks for the quick reply, Paul.
                        I guess what I'm wanting to do is to combine the indicators since they will not plot on the chart with an indicator.
                        Is it possible to combine the indicator I'm working on and the swingrays so it plots on the chart and use the swing highs and lows in the variables I've created?
                        Thanks again.
                        James

                        Comment


                          #27
                          Hi James,

                          Thanks for your reply.

                          I am getting a bit confused about what you are doing.

                          Please write into ScriptingSupport[at]NinjaTrader[dot]com, mark the e-mail Atten:Paul. (replace [at] with @ and [dot] with . )

                          Please include a screenshot of a chart of what you want to do along with your descriptions.

                          Thanks in advance.
                          Paul H.NinjaTrader Customer Service

                          Comment


                            #28
                            Thanks Paul.
                            Sorry for my lack of knowledge here.
                            I wanted to use the swingrays and also plot an EMA with a shaded region between the ema high and ema low.
                            I was able to get them combined but the ema shading stops plotting before the end of the chart (see screenshot).


                            Not sure if there is any help with this.
                            Thanks for any feedback.
                            James
                            Attached Files
                            Last edited by laoshr; 09-11-2021, 10:56 AM.

                            Comment


                              #29
                              Originally posted by laoshr View Post
                              Thanks Paul.
                              Sorry for my lack of knowledge here.
                              I wanted to use the swingrays and also plot an EMA with a shaded region between the ema high and ema low.
                              I was able to get them combined but the ema shading stops plotting before the end of the chart (see screenshot).


                              Not sure if there is any help with this.
                              Thanks for any feedback.
                              James
                              Hello James,
                              I answered you in below thread:-
                              Hello, how can one have for drawing object the high or low as reference instead of current bar... Draw.Line(this, "tag1"+CurrentBar, false, 0, Highs[1][0], -100, Highs[1][0], Brushes.Red, DashStyleHelper.Dash, 2); Draw.Line(this, "tag1"+Highs[1][0]....? so that one can refer to that drawingobject by price

                              You asked me the same question in diff thread, just linking it to avoid any confusion for anybody looking for it.
                              Hope it helps!

                              Comment


                                #30
                                Thank you both Paul and s.kinra for all your help. This forum has been a real asset for those who are trying to learn and develop on the NinjaTrader platform.
                                Thank you both again.
                                James

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by burtoninlondon, Today, 12:38 AM
                                0 responses
                                5 views
                                0 likes
                                Last Post burtoninlondon  
                                Started by AaronKoRn, Yesterday, 09:49 PM
                                0 responses
                                14 views
                                0 likes
                                Last Post AaronKoRn  
                                Started by carnitron, Yesterday, 08:42 PM
                                0 responses
                                11 views
                                0 likes
                                Last Post carnitron  
                                Started by strategist007, Yesterday, 07:51 PM
                                0 responses
                                13 views
                                0 likes
                                Last Post strategist007  
                                Started by StockTrader88, 03-06-2021, 08:58 AM
                                44 responses
                                3,982 views
                                3 likes
                                Last Post jhudas88  
                                Working...
                                X