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

20% and 80% lines of stochastic indicator

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

    20% and 80% lines of stochastic indicator

    How to specify the condition where stochastic indicator cross below the 80% line or cross above the 20% line in strategy builder?

    #2
    The attached pictures contain the requested settings. Please let us know if there are any other ways we can help.
    Attached Files
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Similar question for Ninjascript

      I have:

      AddChartIndicator(Stochastics(stochPeriodD, stochPeriodK, stochSmooth));

      The chart is displayed with indicator lines and 20 and 80. How do I change those in Ninjascript?

      Thanks

      Comment


        #4
        Hello jamesmjones00123,

        AddChartIndicator is a NT8 method and will not work in NT7.

        To change the default value of the 2 lines as part of the Stochastics, you could use the following in NT7,

        Code:
        protected override void Initialize()
        {
        	Add(Stochastics(Close, 2,10,30));
        			
        	Stochastics(Close, 2,10,30)[B].Lines[1].Value=20 ;[/B]
        	Stochastics(Close, 2,10,30)[B].Lines[0].Value=10 ;[/B]
        
        	CalculateOnBarClose	= true;
        }
        Please let us know if you need further assistance.
        Attached Files
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          I'm using NT 8, how do I do it in that code? Thanks.

          Comment


            #6
            Hello jamesmjones00123,
            Thanks for your response.

            To accomplish the same thing in NT8 you could do something similar to the following snippet to set your lines to 40 and 60.

            Code:
            else if (State == State.DataLoaded)
            			{
            				AddChartIndicator(Stochastics(stochPeriodD, stochPeriodK, stochSmooth));
            				Stochastics(stochPeriodD, stochPeriodK, stochSmooth).Lines[0].Value = 40;
            				Stochastics(stochPeriodD, stochPeriodK, stochSmooth).Lines[1].Value = 60;
            			}
            Please let me know if you have any further questions.
            Josh G.NinjaTrader Customer Service

            Comment


              #7
              Hello

              How do I specify the condition where stochastic indicator is below (instead of cross below) the 80% line or above (instead of cross above) the 20% line in strategy builder?
              I have tried following the instruction above by using "Greater" and "Less" operator but that does not seem to work.

              Comment


                #8

                Line 1 & 2 together is valid.
                Line 3 by itself is valid.
                Combining Line 1, 2 and 3 is INVALID.

                What am I doing wrong here?
                Attached Files

                Comment


                  #9
                  Hello hisanoster,

                  Thanks for your post and welcome to the Ninjatrader forums!

                  To create an or condition, you would need to create a "group" with both of the conditions and set the group to "If any" (instead of the default of "if all")

                  Please see the help guide here for an example that creates a group (the example uses "if all"): https://ninjatrader.com/support/help...ateTimeFilters

                  Here are the educational resource available on the strategy builder:
                  Free live webinar every other Thursday at 4:00 PM EST, through this link to all webinars: https://ninjatrader.com/PlatformTraining
                  Previous recording of the Strategy Builder 301 webinar: https://youtu.be/HCyt90GAs9k?list=PL...auWXkWe0Nf&t=2
                  Help guide for the strategy builder: https://ninjatrader.com/support/help...gy_builder.htm

                  Paul H.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi Paul, thanks.

                    However, what I would like is to have all of the following conditions to be true to be qualified for order execution.

                    1) Stochastic K line to be greater equal than line 20
                    2) Stochastic K line to be less equal than line 80
                    3) Stochastic K line to be greaer than D line

                    Do you see a conflict in my conditions?
                    Last edited by hisanoster; 01-27-2021, 08:11 PM.

                    Comment


                      #11
                      Hello hisanoster,

                      Thanks for your reply.

                      I misunderstood/misread your conditions as wanting to be above 80 and less than 20, my mistake.

                      No, I do not see a conflict with your conditions.

                      I have attached an example of your conditions and using the Strategy Builder to show when those collective conditions are true by coloring the background of the chart silver.

                      Click image for larger version

Name:	hisanoster-1.PNG
Views:	531
Size:	75.1 KB
ID:	1138743
                      Paul H.NinjaTrader Customer Service

                      Comment


                        #12
                        Paul,

                        Thank you.
                        When I combine with additional conditions, it just does not calculate.. do you see any issues with this below?

                        Attached Files

                        Comment


                          #13
                          Hello hisanoster,

                          Thanks for your reply.

                          I do not see any issues based on the limited information presented.

                          What I recommend would be to debug your strategy by constructing a print statement where you can print out all of the values involved in that sets conditions on a bar by bar basis and then compare your chart to those values to see what isn't working.

                          To assist here is a short video that demonstrates the process: https://paul-ninjatrader.tinytake.co...NV8xMDk5MDc5Nw
                          Paul H.NinjaTrader Customer Service

                          Comment


                            #14
                            Thanks Paul.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Perr0Grande, Today, 08:16 PM
                            0 responses
                            2 views
                            0 likes
                            Last Post Perr0Grande  
                            Started by elderan, Today, 08:03 PM
                            0 responses
                            5 views
                            0 likes
                            Last Post elderan
                            by elderan
                             
                            Started by algospoke, Today, 06:40 PM
                            0 responses
                            10 views
                            0 likes
                            Last Post algospoke  
                            Started by maybeimnotrader, Today, 05:46 PM
                            0 responses
                            12 views
                            0 likes
                            Last Post maybeimnotrader  
                            Started by quantismo, Today, 05:13 PM
                            0 responses
                            7 views
                            0 likes
                            Last Post quantismo  
                            Working...
                            X