Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Moving Average of Moving Average

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

    Moving Average of Moving Average

    Hello all,

    I'm trying to create a custom indicator which is a moving average of a moving average. I've developed this is TD Ameritrade but cannot figure how to do it in NT. I would like to be able to change the values of both EMA's and will eventually use it in a strategy as entry and exit points. Would also like it to plot on the charts as well. I've played with the custom indicator builder but not sure how to actually code the OnBarChange event.

    How do I code this? My preference is a EMA(4,3) which is a 3 day EMA on the 4 day EMA. Hope this makes sense.

    Any help is greatly appreciated.

    #2
    Hello blconnell,

    Code:
    Print( EMA(EMA(4), 3)[0] );
    The EMA(4) is used as the input series parameter for EMA(<Series>double input, int Period)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello NinjaTrader_ChelseaB

      Thanks for your input, it was very helpful but I cannot figure out how to get the EMA values to plot on the chart. Here's what I have so far.

      EMA1 = 4;
      EMA2 = 3;
      AddPlot(new Stroke(Brushes.Blue), PlotStyle.Bar, "pEMA1");
      AddPlot(new Stroke(Brushes.Red), PlotStyle.Bar, "pEMA2");
      }
      else if (State == State.Configure)
      {
      }
      }

      protected override void OnBarUpdate()
      {
      value[0] = EMA(4) ;
      value[1] = ( EMA(EMA(4), 3)[0] );
      }

      What am I doing wrong?

      Thanks again for your help,
      Bryan

      Comment


        #4
        Hello Bryan,

        Values[0][0] = EMA(4)[0];
        Values[1][0] = EMA(EMA(4), 3)[0];
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank you so much NinjaTrader_ChelseaB , that of course worked. You make it looks so easy.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          43 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          26 views
          0 likes
          Last Post PaulMohn  
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          163 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          98 views
          1 like
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          158 views
          2 likes
          Last Post CaptainJack  
          Working...
          X