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

Difference between Stochastics

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

    Difference between Stochastics

    Hello,

    I downloaded the Spread Indicator from here and I was wondering if it is possible to add a formula that shows the difference between the two symbols that are being displayed. If so, where I sould write the formula?

    I tried to use the Spread Indicator but there is something wrong as Symbol1-Symbol2 is not the difference between them.
    I attached so you can see.

    Thanks

    Sincerely

    Daniel
    Attached Files

    #2
    dvercher,

    I am happy to assist you.

    Here is a spread indicator you can use that is Multiplier1 * Symbol1 - Multiplier2 * Symbol 2

    Please let me know if I may assist further.
    Attached Files
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Hello Adam,

      Thank you for the indicator. What does the indicator take into account for calculating the spread?Open,close,High,Low?? I tried to calculate with the close of the last bar and i didn't get the exact number of the spread.

      Another question I have and I was not able to express myself right in my last post is:

      I downloaded the Spread Indicator from here and I was wondering if it is possible to add the difference between the 2 stochastics of the two symbols displayed. If so, where should I write the formula?

      Comment


        #4
        dvercher,

        It should be the the close price.

        If you add something like Stochastics(input1, periodD, periodK, smooth).K[0] - Stochastics(input2, periodD, periodK, smooth).K[0]

        Please don't hesitate to contact us should you require additional assistance.
        Last edited by NinjaTrader_AdamP; 12-19-2011, 09:29 AM.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          I tried to add the following but it didn't work:

          Tools< Edit Ninja Script< Indicator

          First, in initialize:

          Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "StochasticDiff"));

          and then in OnBarUpdate:

          StochasticDiff.Set(Stochastics(input1, periodD, periodK, smooth) - Stochastics(input2, periodD, periodK, smooth) ;

          The problem I find is that it does not recognizr StochasticDiff and Input1 and input2

          What can I do?

          Thanks

          Comment


            #6
            dvercher,

            Stochastics(input1, periodD, periodK, smooth).K[0] - Stochastics(input2, periodD, periodK, smooth).K[0]

            or

            Stochastics(input1, periodD, periodK, smooth).D[0] - Stochastics(input2, periodD, periodK, smooth).D[0]

            Is required, apologies for the confusion. Plots are accessible from indicators with the Indicator().PLOT[X] where PLOT is the plot name, and X is the bar index.

            The input1 and input2 are based on what dataseries you want to use for your stochastic calculation. You could use something like "Closes[0]" for input1 and "Closes[1]" for input 2 so long as this is a multi-instrument indicator.
            Last edited by NinjaTrader_AdamP; 12-19-2011, 10:47 AM.
            Adam P.NinjaTrader Customer Service

            Comment


              #7
              It didn't compile either. I attach you what I have done.

              A question about this "Closes[0][0]" for input1 and "Closes[1][0]" for input 2 ",

              I understand the first [0] in input1 and [1] in input 2 are for the close of the current bar and the precious bar, but what about the other [0]. What does it mean?

              Thanks
              Attached Files

              Comment


                #8
                Dvercher,

                Looking at that code, you would want to do :

                Stochastics(input1, periodD, periodK, smooth).K[0] - Stochastics(input2, periodD, periodK, smooth).K[0]

                or

                Stochastics(input1, periodD, periodK, smooth).D[0] - Stochastics(input2, periodD, periodK, smooth).D[0]

                With Input1 as "BarsArray[1]" and Input 2 as "BarsArray[2]". The number is the number of the instrument, with 0 being the chart instrument, 1 being the first instrument, and 2 being the second.

                The compiling error you are getting here is related to the fact that you are missing a declaration for the plot. You need to add one in the properties section, which is highlighted #region properties. Once there, take a look at the "Spread" plot for syntax on how to add the 'StochasticDiff" plot.

                Please let me know if I may assist further.
                Last edited by NinjaTrader_AdamP; 12-19-2011, 10:46 AM.
                Adam P.NinjaTrader Customer Service

                Comment


                  #9
                  About the declaration of the plot I will try to solve it later, first I would like to have the StochasticDiff right.

                  I think I did what you told me but no working yet. I attach the picture for you to see.

                  thanks
                  Attached Files

                  Comment


                    #10
                    dvercher,

                    It won't compile until you get the plot declared. The plot is a dataseries, and all dataseries must be declared before you can reference them. Simply adding them in the Initialize() method will not work as it is also required to have the plot declared in the properties section to initialize them this way.

                    Please let me know if I may assist further.
                    Adam P.NinjaTrader Customer Service

                    Comment


                      #11
                      I attach what I did to declare the plot in the properties section to initialize them this way.But I get some errors when compiling

                      And I also attach the error I get when I compile

                      Thanks
                      Attached Files

                      Comment


                        #12
                        dvercher,

                        Im sorry, I wasn't thinking. Must have been lack of sleep and no coffee this morning yet.

                        The correct syntax is to use "BarsArray[1]" and "BarsArray[2]", no second index since Stochastics is wanting a dataseries, not an individual element for its first input.

                        Stochastics(BarsArray[1], periodD, periodK, smooth).K[0] - Stochastics(BarsArray[2], periodD, periodK, smooth).K[0]

                        I have edited errors in my posts below to be correct.

                        Please let me know if I may assist further.
                        Adam P.NinjaTrader Customer Service

                        Comment


                          #13
                          It worked now

                          From now on remember, always coffee in the mornings...

                          Thanks Adam, it was possible for your help

                          Comment


                            #14
                            Is it possible to graph the two different symbols in the same graph? It would be very helpful that.

                            Thanks

                            Daniel

                            Comment


                              #15
                              Yes Daniel, you could create a MultiSeries chart and then apply your spread indicator to one symbol to visualize all the info - please see the 2nd and last section of my link below for the 'how to' :

                              BertrandNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by samish18, Yesterday, 08:31 AM
                              4 responses
                              14 views
                              0 likes
                              Last Post elirion
                              by elirion
                               
                              Started by funk10101, Yesterday, 09:43 PM
                              1 response
                              13 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                              5 responses
                              551 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by rtwave, 04-12-2024, 09:30 AM
                              5 responses
                              37 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by funk10101, Today, 12:02 AM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Working...
                              X