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

200 MA of 5 min chart on 1 minute chart

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

    200 MA of 5 min chart on 1 minute chart

    Anybody know how to get the 200 MA of 5 min chart on a 1 minute chart?

    And no you can't just put in a 1000ma on the 1 minute chart. It's different.

    #2
    Hello stockgoblin,

    Are you wanting to do this from the code or just on a chart using the system indicators?

    Please see the following video which demonstrates how to overlay an indicator which is calculated from one data series onto another:

    MatthewNinjaTrader Product Management

    Comment


      #3
      Hey, that's great thanks. When I try it though my computer gets bogged down pretty bad. I think an indicator would be less intrusive on processing power. IS it possible as an indicator?

      Also, I'd like to upgrade my computer. What should I upgrade first so Ninjatrader runs more smoothly and doesn't lag as much from having too many rays drawn on my charts?

      Comment


        #4
        stockgoblin,

        Yes, this would be possible by using a custom indicator. You would need to use the Add() method to add the secondary data series to the chart and then tell the MA indicator to calculate from this data series.

        More information on working with Multi Series Indicators can be found below:



        The most important factor would be your CPU. I would also suggest reviewing our Performance Tips to ensure the best performance out of NinjaTrader:

        MatthewNinjaTrader Product Management

        Comment


          #5
          Okay, I put the Add(PeriodType.Minute, 5); into the SMA indicator code but I'm having problems figuring out where to put the BarsArray in the following so it references the 5 minute data.

          if (CurrentBar == 0)
          Value.Set(Input[0]);
          else
          {
          double last = Value[1] * Math.Min(CurrentBar, Period);

          if (CurrentBar >= Period)
          Value.Set((last + Input[0] - Input[Period]) / Math.Min(CurrentBar, Period));
          else
          Value.Set((last + Input[0]) / (Math.Min(CurrentBar, Period) + 1));
          }

          Any idea?

          Comment


            #6
            stockgoblin,

            Rather than duplicate the system SMA's logic, you can simply reference the SMA() function and add this as a plot.

            Code:
            protected override void Initialize()
                    {
               
                        Add(PeriodType.Minute, 1);
            
                        Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
                        Overlay                = true;
                    }
            
                      protected override void OnBarUpdate()
                    {
                    
                        // Ensures that the plot is drawn on the primary data series
                        if (BarsInProgress == 0)
                    
                        {
                            // Sets Plot0 to the SMA of the 5 minute data series
                            Plot0.Set(SMA([B]BarsArray[1][/B], Period)[0]);
                        }
            MatthewNinjaTrader Product Management

            Comment


              #7
              Hi, I'm just having trouble understanding.

              Sorry to question your code but...

              did you mean: Add(PeriodType.Minute, 5); instead of Add(PeriodType.Minute, 1); as I'm trying to put the SMA from the 5 minute data series onto the 1 minute chart

              and I'm getting: The name 'Plot0' does not exist in the current context

              for Plot0.Set(SMA(BarsArray[1], Period)[0]); - is this to be: Value.Set(SMA(BarsArray[1], Period)[0]); ???

              I'm new to coding so I'm trying to reference the SMA indicator included in Ninjatrader and alter it to plot from the 5 minute data series.

              Any help is appreciated. Thanks

              Comment


                #8
                Hi stockgoblin,

                Yes, Add(PeriodType.Minute, 5); will add a 5 minute series to the script.

                You will need to replace Plot0 with the name of your plot. Plot0 is the name of the first default plot added but you may have changed it in the indicator wizard.
                Ryan M.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by cmtjoancolmenero, Yesterday, 03:58 PM
                4 responses
                24 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
                 
                Started by suroot, 04-10-2017, 02:18 AM
                5 responses
                3,022 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by Stanfillirenfro, Today, 07:23 AM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Working...
                X