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

Moving Average of a Indicator

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

    Moving Average of a Indicator

    Hi,

    I am sorry to bother you all with such a silly question.

    I am trying to plot the moving average of CCI in the CCI window, In Metatrader4 I just drag and drop the MA into the CCI window and it works.

    Is there anyway I can do this in NT6 ?

    Thanks
    Ian

    #2
    Hi buderim,

    You can do this in NT6 by programming a very simple custom indicator. What you want to do in the custom indicator is call the CCI indicator within the SMA indicator. This can be done with the following code:
    Code:
    double smaCCI = SMA(CCI(14), 20)[0];
    Please see attached sample for further reference on how to actually plot the values.

    To install the indicator:
    1) Download file
    2) Open NinjaTrader
    3) File->Utilities->Import NinjaScript
    4) Select file
    Attached Files
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hi Josh,

      Thanks for that ,I didnt realise it was that simple !!

      I will have a look at it.

      Many Thanks
      Ian

      Comment


        #4
        Here's one I wrote a while back that has two plots... CCI and CCI with HMA averaging. This could easily be adjusted to do SMA averaging if you want an indicator with both plots. I liked the HMA better because it has less lag than an SMA.
        Attached Files

        Comment


          #5
          Thanks KBJ,

          I will try this version as well.

          Ian

          Comment


            #6
            Wilders MA of an indicator

            Can anyone help me with this? The SMA file works great, but I find it is too slow for good signals, and the Hull MA is too fast. I would like to use a Wilders MA of the CCI, which should end up somewhere between the 2. Thanks in advance for any help you can offer
            DT



            Originally posted by Josh View Post
            Hi buderim,

            You can do this in NT6 by programming a very simple custom indicator. What you want to do in the custom indicator is call the CCI indicator within the SMA indicator. This can be done with the following code:
            Code:
            double smaCCI = SMA(CCI(14), 20)[0];
            Please see attached sample for further reference on how to actually plot the values.

            To install the indicator:
            1) Download file
            2) Open NinjaTrader
            3) File->Utilities->Import NinjaScript
            4) Select file

            Comment


              #7
              If you post the code or reference documentation, someone may be kind enough to contribute.
              RayNinjaTrader Customer Service

              Comment


                #8
                From what I've found on the web, the Wilder MA is calculated by:

                WilderMA = EMA(2*WilderPeriod-1);

                So, to do a WilderMA on a CCI(14), you have:

                int WilderPeriod = 10;
                double WilderMAonCCI = EMA(CCI(14),(2*WilderPeriod-1))[0];

                Ben

                Comment


                  #9
                  cci crossing ma

                  hello
                  How do you have condition builder to look for condition when the cci cross above or below the MA,
                  Thanks,
                  Last edited by kian1; 02-04-2008, 10:09 AM.

                  Comment


                    #10
                    This might help...

                    RayNinjaTrader Customer Service

                    Comment


                      #11
                      ema ploted on cci

                      I have the ema ploted on cci and i liket to be able to pon point when the cci crossed above or below its EMA that is ploted.
                      ///<summary>
                      /// This method is used to configure the indicator and is called once before any bar data is loaded.
                      ///</summary>
                      protectedoverridevoid Initialize()
                      {
                      Add(
                      new Plot(Color.YellowGreen, "CCI"));
                      Add(
                      new Plot(Color.DarkViolet, "SmoothingPeriod"));
                      Add(
                      new Plot(new Pen(Color.Orange, 3), "CCI"));
                      Add(
                      new Plot(new Pen(Color.Green, 3), "CCI_with_EMA_averaging"));
                      Add(
                      new Line(Color.DarkGray, 200, "Level 2"));
                      Add(
                      new Line(Color.DarkGray, 100, "Level 1"));
                      Add(
                      new Line(Color.DarkGray, 0, "Zero line"));
                      Add(
                      new Line(Color.DarkGray, -100, "Level -1"));
                      Add(
                      new Line(Color.DarkGray, -200, "Level -2"));
                      }
                      ///<summary>
                      /// Calculates the indicator value(s) at the current index.
                      ///</summary>
                      protectedoverridevoid OnBarUpdate()
                      {
                      if (CurrentBar == 0)
                      {
                      Values[
                      0].Set( 0 );
                      Values[
                      1].Set( 0 );
                      }
                      Values[
                      0].Set( CCI(CCIPeriod)[0] );
                      Values[
                      1].Set( EMA(Values[0], SmoothingPeriod )[0] );
                      }
                      #region Properties
                      ///<summary>
                      ///</summary>
                      [Description("Numbers of bars used for CCi calculations")]
                      [Category(
                      "Parameters")]
                      publicint CCIPeriod
                      {
                      get { return CCIperiod; }
                      set { CCIperiod = Math.Max(1, value); }
                      }
                      [Description(
                      "Numbers of bars used for EMA smoothing")]
                      [Category(
                      "Parameters")]
                      publicint SmoothingPeriod
                      {
                      get { return smoothingPeriod; }
                      set { smoothingPeriod = Math.Max(1, value); }
                      }
                      #endregion
                      }
                      }

                      I have the above fomula but it does not plot the CCI and EMA(smoothing) seperatlely when i want to write cross over conditions. in the condition winodw..any idea

                      Comment


                        #12
                        Can you clarify -

                        Do you want to know...

                        - How to create a condition in the condition builder that checks for a cross condition of CCI over an EMA of CCI

                        or

                        - How to do this programatically? If the latter -

                        if (CrossAbove(CCI(14), EMA(CCI(14), 14), 1))
                        // Do something....
                        RayNinjaTrader Customer Service

                        Comment


                          #13
                          Yes, that is correct
                          when building a condition using the wizard ,, if the indicator has more then one LINE then it it will have a section for Plot drop down with names of the line that you want tested for example:
                          macd indicator has
                          plot drop down with MACD,AVE, and DIFF to test against each other.
                          I want to have the CCI test when it crosses above or below cci EMA avrage. I tried to paste this
                          if (CrossAbove(CCI(14), EMA(CCI(14), 14), 1))
                          in the condition builder it it will not paste.
                          what is worng with the programing i sent you earlier it will not show the +plot in the wizard condition builder..
                          Thanks much...

                          Comment


                            #14
                            In the Condition Builder ....

                            - On left side, select CCI indicator
                            - In middle select "CrossAbove"
                            - On right side select EMA and in the right lower section, click to the right of "Input series" and press the "..." button that shows up, then select CCI
                            RayNinjaTrader Customer Service

                            Comment


                              #15
                              Thanks,
                              But what you are suggesting will not plot the ema ON cci,
                              I did what you said and the ema is ploted on the price chart Not cci
                              I have attached the pics
                              I am very surprised that this feature is not in the chart package wizard
                              we should be able to plot indicator on indicator very easily.
                              with out being a programmer.
                              in the attached pic the bottom indicator is the cci with ema plotted but when i want to
                              have the condition cci crossing its own ema i can Not do it in the condition builder b/c the the plot is not there,as i metioned in the MACD example yesterday..
                              If I send you the programing code on the bottom indicator that has ema ploted on cci could anyone tell why it will not allow me to build cross over conditions?
                              Thanks,
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by kujista, Today, 05:44 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post kujista
                              by kujista
                               
                              Started by ZenCortexCLICK, Today, 04:58 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post ZenCortexCLICK  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              172 responses
                              2,281 views
                              0 likes
                              Last Post sidlercom80  
                              Started by Irukandji, Yesterday, 02:53 AM
                              2 responses
                              18 views
                              0 likes
                              Last Post Irukandji  
                              Started by adeelshahzad, Today, 03:54 AM
                              0 responses
                              8 views
                              0 likes
                              Last Post adeelshahzad  
                              Working...
                              X