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

Relative Strength vs an Index

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

    Relative Strength vs an Index

    I don't see that this indicator is available without programming.

    Is this possible to create an indicator plotting the performance of one stock vs any other symbol, like SPY?

    The formula is simple, just not sure how to reference the price data of the other security.

    Any help would be appreciated. Thanks

    #2
    Hello peteM,

    Thanks for your note.

    Please see the Add() method for referencing another data series.
    http://www.ninjatrader.com/support/h...s/nt7/add3.htm

    The following also has some information about referencing the close, open, low, high, typical, etc of another dataseries. You will want to look at the section 'Accessing the Price Data in a Multi-Bars NinjaScript'.
    http://www.ninjatrader.com/support/h...nstruments.htm

    Also, included with NinjaTrader is the SampleMultiInstrument strategy. This also uses data from a secondary data series using a different instrument.

    Please let me know if there is more information I can provide.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Chelsea, thank you for your reply.

      Will this need to be done as a strategy or can I do it as an indicator?

      And will I be able to add a moving average and view the created indicator in a Market Analyzer as a column?

      Comment


        #4
        Hello peteM,

        This can be done as either, but you will need to write this as an indicator to be able to add this as a column to the market analyzer.

        To add this to the market analyzer you will need to set the plot of the indicator to the value you have created.

        Then in the Market Analyzer:
        • Right-click the market analyzer -> select Columns...
        • In the columns list in the upper left select Indicator -> click the New button
        • In the parameters on the right under Indicator set the value for Indicator to your indicator
        • If you have multiple plots set Plot to the desired plot


        Also yes, you can add other indicators to this indicator. You can do this by calling that indicator.

        For example:

        Plot0.Set(SMA(19)[0]);

        This would set the plot of your indicator to the value of the SMA(19).


        Please let me know if this does not resolve your inquiry.
        Last edited by NinjaTrader_ChelseaB; 07-15-2013, 11:47 AM.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Chelsea, thank you again. I got the indicator working fine. However, if I try to plot an EMA of my indicator, it goes parabolic to the far left of the chart, reflecting values that the indicator never hit. Any ideas why that might be happening?

          Comment


            #6
            Hi peteM,

            The best way to troubleshoot is to print values to the output window.

            For example:

            Print(EMA(19)[0]);

            This would print the value of the EMA(19) of 0 bars ago to the output window (Tools -> Output Window...)

            If that prints the expected value, yet the plot is not expected, please post the line of code you have written.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              I did try that last night, the prints reflect what shows on the chart, EMA values at the beginning (left) of the plot well above the value of the indicator. Towards the end of the plot (right) the values begin to reflect properly. I couldn't figure out why the moving averages at the beginning of the chart are inaccurate. I thought it might have been a data issue because the 50 period moving average is more inaccurate than the 20. I was unclear as to whether the BarsRequired / BarsInProgress if statements are required here, could that be the issue?

              The other problem I've had with this is that if I add the EMA of the indicator to a Market Analyzer, it's very slow to load initially and freezes often.


              Originally posted by NinjaTrader_ChelseaB View Post
              Hi peteM,

              The best way to troubleshoot is to print values to the output window.

              For example:

              Print(EMA(19)[0]);

              This would print the value of the EMA(19) of 0 bars ago to the output window (Tools -> Output Window...)

              If that prints the expected value, yet the plot is not expected, please post the line of code you have written.

              Comment


                #8
                Hello peteM,

                That may be the case.

                There will need to be enough bars for the call. For example if you are using the EMA(50), you will need to wait 50 bars before running the script.

                For example:

                if (CurrentBar < 50)
                {
                return;
                }

                As far as the bars in progress. This is only used when you have multiple data series added to a script.
                http://www.ninjatrader.com/support/h...inprogress.htm


                Also, try adding an EMA(50) directly to the chart? Are the values different than what is plotted by your script?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  I'll try that CurrentBar later and see how it goes, thank you.

                  As for adding the EMA manually, that is all I've done so far.

                  I tried to make Plot0 be the indicator, Plot1 be the EMA20 of the indicator and Plot2 be the EMA50 of the indicator, but I could not figure out how to do that properly. So I've only been able to add an EMA of the indicator manually to the chart so far.


                  Originally posted by NinjaTrader_ChelseaB View Post
                  Hello peteM,

                  That may be the case.

                  There will need to be enough bars for the call. For example if you are using the EMA(50), you will need to wait 50 bars before running the script.

                  For example:

                  if (CurrentBar < 50)
                  {
                  return;
                  }

                  As far as the bars in progress. This is only used when you have multiple data series added to a script.



                  Also, try adding an EMA(50) directly to the chart? Are the values different than what is plotted by your script?

                  Comment


                    #10
                    Hello peteM,

                    By manually added to the chart you do mean you right-clicked the chart -> selected Indicators... -> selected the EMA -> clicked New -> clicked OK?

                    Can I see the code you have so far (including the Initialize() part of the script)?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Yes, I selected EMA and then changed the input from DataSeries to my indicator that I created.

                      I'll have to get the code later, don't have access to it right now.


                      Originally posted by NinjaTrader_ChelseaB View Post
                      Hello peteM,

                      By manually added to the chart you do mean you right-clicked the chart -> selected Indicators... -> selected the EMA -> clicked New -> clicked OK?

                      Can I see the code you have so far (including the Initialize() part of the script)?

                      Comment


                        #12
                        Hi peteM,

                        I am unsure of what you are trying to do.

                        What values is your indicator making that you are using this for your input series on the chart?

                        I had assumed you were trying to add the EMA to your indicator. Adding the EMA directly to the chart, using the charts primary input series would give you values to compare to.

                        Adding the EMA to a chart using your indicator as the input series would be an ema of an ema.
                        (so exponential)
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          The indicator I created was basically:

                          (Current Symbol) / (SPY)

                          This creates a ratio. I want to be able to add an EMA of that indicator. So I want an EMA of the indicator I created, not an EMA of the primary input.



                          Originally posted by NinjaTrader_ChelseaB View Post
                          Hi peteM,

                          I am unsure of what you are trying to do.

                          What values is your indicator making that you are using this for your input series on the chart?

                          I had assumed you were trying to add the EMA to your indicator. Adding the EMA directly to the chart, using the charts primary input series would give you values to compare to.

                          Adding the EMA to a chart using your indicator as the input series would be an ema of an ema.
                          (so exponential)

                          Comment


                            #14
                            Hi peteM,

                            I understand.

                            Please let me know if I can be of any further assistance for you.
                            Chelsea B.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by bmartz, 03-12-2024, 06:12 AM
                            4 responses
                            31 views
                            0 likes
                            Last Post bmartz
                            by bmartz
                             
                            Started by Aviram Y, Today, 05:29 AM
                            4 responses
                            12 views
                            0 likes
                            Last Post Aviram Y  
                            Started by algospoke, 04-17-2024, 06:40 PM
                            3 responses
                            28 views
                            0 likes
                            Last Post NinjaTrader_Jesse  
                            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