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

Getting SMA values of a specific-period bar chart

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

    Getting SMA values of a specific-period bar chart

    Hi all,

    I want to know how to get the value of 10-period SMA, where the lengh of a period is configurable (e.g. 1 period can be 30 minutes (30-minute bar) or 1 hour (1-hour bar) and so on) or 1 hour using Ninjascript. How can I do that? Please advise.

    #2
    You will need to Add your needed time frame in the Initialize of your strategy and then calculate the SMA value for your desired period on this frame using this BarsArray then as input for the IDataSeries input -

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      You will need to Add your needed time frame in the Initialize of your strategy and then calculate the SMA value for your desired period on this frame using this BarsArray then as input for the IDataSeries input -

      http://www.ninjatrader-support.com/H...BarSeries.html
      Thanks for you advice and information given.

      Actually I am not going to write a strategy, but instead write an indicator showing the absolute difference between two SMAs of different time frames. When I tried to compile the program, the following compile-time error is shown:

      No overload for Method "Add" takes "2" arguments.

      What happened? Below is a part of my code:

      protected override void Initialize()
      {
      Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
      Add(new Line(Color.FromKnownColor(KnownColor.DarkOliveGree n), 20, "Convergence"));
      Add(PeriodType.Minute, timeFrame1);
      Add(PeriodType.Minute, timeFrame2);
      CalculateOnBarClose = true;
      Overlay = false;
      PriceTypeSupported = false;
      }

      Comment


        #4
        DGMan, if you're using NT6.5, multi-instrument indicators are not possible. If you're using NT7, please try hardcoding the values for timeFrame1 and timeFrame2.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Austin View Post
          DGMan, if you're using NT6.5, multi-instrument indicators are not possible. If you're using NT7, please try hardcoding the values for timeFrame1 and timeFrame2.
          I am currently using NT6.5, and I am not going to upgrade it to NT 7 unless it is a non-beta release.

          Speaking back to my issue, I am not intending to develop a custom mult-INSTRUMENT indicator, but an indicator with the same underlying instrument (e.g. ES) but with different timeframes. Is it possible in NT6.5?

          Comment


            #6
            DGMan, unfortunately an indicator with the same instrument but different time frames is still classified as a multi-instrument indicator. As such, it is not possible in NT6.5.
            AustinNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by fitspressoburnfat, Today, 04:25 AM
            0 responses
            2 views
            0 likes
            Last Post fitspressoburnfat  
            Started by Skifree, Today, 03:41 AM
            1 response
            4 views
            0 likes
            Last Post Skifree
            by Skifree
             
            Started by usazencort, Today, 01:16 AM
            0 responses
            1 view
            0 likes
            Last Post usazencort  
            Started by kaywai, 09-01-2023, 08:44 PM
            5 responses
            604 views
            0 likes
            Last Post NinjaTrader_Jason  
            Started by xiinteractive, 04-09-2024, 08:08 AM
            6 responses
            23 views
            0 likes
            Last Post xiinteractive  
            Working...
            X