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 CaptainJack, 05-29-2026, 05:09 AM
          0 responses
          210 views
          0 likes
          Last Post CaptainJack  
          Started by CaptainJack, 05-29-2026, 12:02 AM
          0 responses
          120 views
          0 likes
          Last Post CaptainJack  
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          145 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          227 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          188 views
          0 likes
          Last Post CarlTrading  
          Working...
          X