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 Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          670 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          379 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          111 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          575 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          582 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X