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

Daily SMA on Intraday Chart

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

    Daily SMA on Intraday Chart

    In ThinkOrSwim I can have daily simple moving averages displayed on my intraday charts. Their code looks like this.

    input price = FundamentalType.CLOSE;
    input aggregationPeriod = AggregationPeriod.DAY;
    input period_SMA20 = 20;
    input period_SMA50 = 50;
    input period_SMA100 = 100;
    input period_SMA200 = 200;
    input displace = 0;
    input averageType = AverageType.SIMPLE;
    plot SMA_20 = MovingAverage(averageType, Fundamental(price, period = aggregationPeriod), period_SMA20);
    plot SMA_50 = MovingAverage(averageType, Fundamental(price, period = aggregationPeriod),period_SMA50);
    plot SMA_100 = MovingAverage(averageType, Fundamental(price, period = aggregationPeriod),period_SMA100);
    plot SMA_200 = MovingAverage(averageType, Fundamental(price, period = aggregationPeriod),period_SMA200);

    Is there a way for NinjaTrader to display daily moving averages on the intraday charts?

    Thanks
    doug_p

    #2
    Hello,

    Yes, this is possible.

    It would be easy to do through the user interface itself. Please see the following video on how to add multiple data series to a chart and calcualte an indicator from the added data series:

    Download NinjaTrader FREE at http://www.ninjatrader.comThis video demonstrates how to plot an indicator based off of one data series, overlay it onto another...


    It would also be possible using custom programming to have indicator display this information as well. I'd suggest reviewing our Help Guide article on Multi-Time Frame Indicators for information on how this would be done:

    MatthewNinjaTrader Product Management

    Comment


      #3
      Hello!
      How can we do the same thing, but coding in strategy script?
      Thanks a lot!

      Comment


        #4
        Hi Vvu1980,

        You can add multiple data series by using the Add() function with NinjsScript.
        http://www.ninjatrader.com/support/h....html?add3.htm

        Additionally, please take a look the link below on how to use multiple time frames with NinjaScript and how that data is referenced.
        http://www.ninjatrader.com/support/h...nstruments.htm

        Let me know if I can be of further assistance.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Can you help me more exactly!?
          For example, this sentence corect for adding 120-min KAMA chart to 30-min main chart?

          KAMA PlotC = KAMA(BarsArray[2], 2, periodKAMA, 30);
          Add(new Plot(Color.Green, "PlotC"));

          Comment


            #6
            Hi Vvu1980,

            You add the 120 minute time frame from the initialize section of the code
            Code:
            protected override void Initialize()
            {
            			Add("AAPL", PeriodType.Minute, 120); // BarsArray [1]
                                    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "KAMALine"));
            }
            Then you can add the KAMA to the new plot using the BarsArray[1]
            Code:
            private override void OnBarUpdate()
            {
                  KAMALine.Set(KAMA(BarsArray[1], 2, periodKAMA, 30));
            
            }
            You will also need to add a properties code for the plot data series

            Code:
            #region Properties
                    [Browsable(false)]	
                    [XmlIgnore()]		
                    public DataSeries KAMALine
                    {
                        get { return Values[0]; }
                    }
            #endregion
            Cal H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by dward123, 01-02-2024, 09:59 PM
            4 responses
            174 views
            0 likes
            Last Post Lancer
            by Lancer
             
            Started by ETFVoyageur, Today, 04:00 PM
            2 responses
            19 views
            0 likes
            Last Post ETFVoyageur  
            Started by AaronKTradingForum, Today, 03:44 PM
            1 response
            10 views
            0 likes
            Last Post AaronKTradingForum  
            Started by Felix Reichert, 04-26-2024, 02:12 PM
            11 responses
            80 views
            0 likes
            Last Post Felix Reichert  
            Started by junkone, 04-28-2024, 02:19 PM
            7 responses
            84 views
            1 like
            Last Post junkone
            by junkone
             
            Working...
            X