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

Moving Average line included in Spread indicator.

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

    Moving Average line included in Spread indicator.

    Hi,

    Currently I'm using the Spread Indicator (http://www.ninjatrader.com/support/f...=15&page=8) to plot the spread between WTI Crude (CL) and Brent Crude (BRN). But I would like to add a Moving Average to the Spread Indicator. Does anybody have to code for me which I can add the original script?

    If you have any questions about what I try to do, please let me know too.

    Thanks,
    Robin

    #2
    Hello robinhenderson,

    You can call an indicator inside of another indicator to be able to use one of the predefined Moving Averages. For example:

    Code:
    double tempvar = SMA(14)[0];

    Otherwise, if you would like to actually add the code into the indicator you can view the source code of all the predefined indicators by going to the Control Center -> Edit NinjaScript -> Indicators and then double click on the indicator that you want to open.

    For a link to our Help Guide that goes over the SMA you may view the link below.
    http://www.ninjatrader.com/support/h...simple_sma.htm

    Let me know if I can be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      Thanks, where do I copy that code? Or can I just add a standard NinjaTrader MA Indicator into the Spread Indicator? But then the MA has to apply to the spread and not the price of the instrument.... Will it do that?

      Comment


        #4
        Hello robinhenderson,

        That is just a sample of how to get the value of the SMA, but typically you would call this in OnBarUpdate(). If you would like to get the SMA of the Spread Indicator you would have to take the logic from inside of the SMA and apply it to the Spread or create a new Indicator and have that indicator reference the SMA and the Spread Indicator.

        Let us know if we can be of further assistance.
        JCNinjaTrader Customer Service

        Comment


          #5
          Need ma for spread indicator

          I know this is an old thread but I was trying to find the same thing. But I can't write code so I am looking for a moving average that can be used WITH the spread indicator. I track the PL/GC spread and would like to have a MA to plot. Thanks,

          Comment


            #6
            Hello diver,

            Thank you for writing in.

            If you are unable to code, what you can do is add an SMA to your chart with the Spread indicator as its input series. This will plot the SMA of the spread indicator.

            To do this, right-click within your chart and select Indicators.

            Scroll down the list until you find the SMA indicator. Select it and click on New.

            The parameters to the right will now be modifiable. Click to the right of Input series and you should see an ellipsis (...) button. Click on this.

            This will bring up the Input Series window. Select the plus (+) sign next to Indicators. Then, scroll until you find Spread. Select Spread, input its parameters at the bottom and click OK.

            The SMA now has the Spread indicator as its input series.

            One more parameter we'll want to change is the Panel parameter. Ensure this matches the Spread indicator's Panel parameter so the SMA indicator plots within the same panel as the Spread indicator.

            Press OK in the Indicators window and now the SMA indicator will plot the SMA of the Spread indicator.

            For more information about working with indicators, please take a look at this help guide link: https://ninjatrader.com/support/help...indicators.htm

            I've also created a slightly modified Spread indicator with a 14 period SMA included. I've included it within this post. To import this NinjaScript file, click on File -> Utilities -> Import NinjaScript within the Control Center.

            To view the code and see what was modified, click on Tools -> Edit NinjaScript -> Indicator. Select SpreadwithMA and click OK. I have commented the portions modified. You can open the Spread indicator as well to compare.

            Please, let us know if we may be of further assistance.
            Attached Files
            Zachary G.NinjaTrader Customer Service

            Comment


              #7
              Zachary,

              Thank you for your detailed reply. I did try what you suggested but when I did the spread indicator did not appear as an option. Only the two commodities that are being charted showed up.

              Even when I just did it again as you outlined it did not give me the option of using the spread indicator as a place to put the MA.

              I tried to download your zip file so I could install it but it is coming across as a php only, not a zip file that I can load into NT.

              Am I doing something wrong here? Thanks again.

              Comment


                #8
                Hello diver,

                Do you already have the Spread indicator? If not, you would need to download the Spread indicator: http://www.ninjatrader.com/support/f...d=4&linkid=367

                I'm not quite sure what would be causing the zip file to download as a php file. Have you attempted downloading from another web browser?

                If you are still unable to download the file, please send an email to platformsupport [AT] ninjatrader [DOT] com with my name and a link to this thread referenced so I can email you the file I have uploaded.

                Please, let us know if we may be of further assistance.
                Zachary G.NinjaTrader Customer Service

                Comment


                  #9
                  Yes, I downloaded and am using the old spread indicator now. I wanted to ADD the MA to this chart.

                  I will send you an email so you can forward to me the one you made WITH the MA in already. Not sure why it's coming as a php either. I download all the time from NT with no issues.

                  I am trying to overlay a 100 period sma onto my chart. Thanks.

                  Comment


                    #10
                    Hello diver,

                    I will follow up through email.

                    Please, let us know if we may be of further assistance.
                    Zachary G.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by rexsole, Today, 08:39 AM
                    0 responses
                    4 views
                    0 likes
                    Last Post rexsole
                    by rexsole
                     
                    Started by trilliantrader, Yesterday, 03:01 PM
                    3 responses
                    30 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Started by cmtjoancolmenero, Yesterday, 03:58 PM
                    4 responses
                    26 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by Brevo, Today, 01:45 AM
                    1 response
                    14 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by rjbtrade1, 11-30-2023, 04:38 PM
                    2 responses
                    74 views
                    0 likes
                    Last Post DavidHP
                    by DavidHP
                     
                    Working...
                    X