Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

user define the way a moving average is calculated

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

    user define the way a moving average is calculated

    I would like to be able to define how a moving average is calculated, i.e. high + low + close / 3. Please put this on your list for future developments. Thanx.

    #2
    Originally posted by ussdotsons View Post
    I would like to be able to define how a moving average is calculated, i.e. high + low + close / 3. Please put this on your list for future developments. Thanx.
    You can already do this. Just select the input series as needed.

    Comment


      #3
      Not on my charts. There are some variations, but nothing like what I want.

      Comment


        #4
        Originally posted by ussdotsons View Post
        Not on my charts. There are some variations, but nothing like what I want.
        Well, what do you want? The most common inputs are already available. If you want to drive an average calculation from a different input, that is not natively available, you create a DataSeries() and take the average as needed.

        On the other hand, are you saying that you want to be able to extend the current enum that holds the input definitions?

        Comment


          #5
          I have a feeling ussdotson is not comfortable with custom programming.

          Comment


            #6
            Originally posted by ussdotsons View Post
            Not on my charts. There are some variations, but nothing like what I want.
            I was playing about with some indicators so I thought I'd code this one up up for you. It's not difficult. I guess this is what you're looking for.

            It works!

            It's attached. When importing, it's essential to say 'no' to any request to import other files.

            This is the main body of code:

            if (CurrentBar < Period)
            return;

            double HLC3 = ( WMA(High, Period)[0] + WMA(Low, Period)[0] + WMA(Close, Period)[0] ) / 3;

            Plot0.Set( HLC3 );


            You can change the WMA to SMA or EMA or anything else just about just by over-typing and compiling (press icon or hit F5). Or right click and 'Save As...'

            Hope this helps.

            Cheers,

            Ed
            Attached Files
            Last edited by arbuthnot; 05-10-2015, 11:11 AM.

            Comment


              #7
              Originally posted by ussdotsons View Post
              Not on my charts. There are some variations, but nothing like what I want.
              You can select the Typical Price as input series.That is exactly what you have asked for.

              If you need more exotic combinations, you can easily code it yourself, see prior post.

              Comment


                #8
                Originally posted by ussdotsons View Post
                Not on my charts. There are some variations, but nothing like what I want.
                Further to my post below attaching the indicator, it occurred to me that you can achieve precisely the same thing by selecting WMA (or whatever), open the indicator box, go to 'Input Series, click on the (...) button and select 'typical', which gives you exactly what you want for any indicator at all, as 'typical' = high + low + close / 3.

                But having this indicator allows you to play around with it and maybe learn something about coding.

                On edit: Harry saw this before I did!

                Comment


                  #9
                  I was thinking something more like this.

                  His formula is in there, now he can select this as the input series in the Indicator Builder as indicated by the attachment.

                  He can change this formula and make it 'untypical'.


                  Code:
                              Plot0.Set((High[0]+Low[0]+Close[0])/3);
                  Code:
                  #region Using declarations
                  using System;
                  using System.ComponentModel;
                  using System.Diagnostics;
                  using System.Drawing;
                  using System.Drawing.Drawing2D;
                  using System.Xml.Serialization;
                  using NinjaTrader.Cbi;
                  using NinjaTrader.Data;
                  using NinjaTrader.Gui.Chart;
                  #endregion
                  
                  // This namespace holds all indicators and is required. Do not change it.
                  namespace NinjaTrader.Indicator
                  {
                      /// <summary>
                      /// Enter the description of your new custom indicator here
                      /// </summary>
                      [Description("Enter the description of your new custom indicator here")]
                      public class CustomFormula1 : Indicator
                      {
                          #region Variables
                          // Wizard generated variables
                              private int myInput0 = 1; // Default setting for MyInput0
                          // User defined variables (add any user defined variables below)
                          #endregion
                  
                          /// <summary>
                          /// This method is used to configure the indicator and is called once before any bar data is loaded.
                          /// </summary>
                          protected override void Initialize()
                          {
                              Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
                              Overlay				= true;
                  			
                  			
                          }
                  
                          /// <summary>
                          /// Called on each bar update event (incoming tick)
                          /// </summary>
                          protected override void OnBarUpdate()
                          {
                              // Use this method for calculating your indicator values. Assign a value to each
                              // plot below by replacing 'Close[0]' with your own formula.
                              Plot0.Set((High[0]+Low[0]+Close[0])/3);
                  		}
                  
                          #region Properties
                          [Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                          [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                          public DataSeries Plot0
                          {
                              get { return Values[0]; }
                          }
                  
                          [Description("")]
                          [GridCategory("Parameters")]
                          public int MyInput0
                          {
                              get { return myInput0; }
                              set { myInput0 = Math.Max(1, value); }
                          }
                          #endregion
                      }
                  }
                  
                  #region NinjaScript generated code. Neither change nor remove.
                  // This namespace holds all indicators and is required. Do not change it.
                  namespace NinjaTrader.Indicator
                  {
                      public partial class Indicator : IndicatorBase
                      {
                          private CustomFormula1[] cacheCustomFormula1 = null;
                  
                          private static CustomFormula1 checkCustomFormula1 = new CustomFormula1();
                  
                          /// <summary>
                          /// Enter the description of your new custom indicator here
                          /// </summary>
                          /// <returns></returns>
                          public CustomFormula1 CustomFormula1(int myInput0)
                          {
                              return CustomFormula1(Input, myInput0);
                          }
                  
                          /// <summary>
                          /// Enter the description of your new custom indicator here
                          /// </summary>
                          /// <returns></returns>
                          public CustomFormula1 CustomFormula1(Data.IDataSeries input, int myInput0)
                          {
                              if (cacheCustomFormula1 != null)
                                  for (int idx = 0; idx < cacheCustomFormula1.Length; idx++)
                                      if (cacheCustomFormula1[idx].MyInput0 == myInput0 && cacheCustomFormula1[idx].EqualsInput(input))
                                          return cacheCustomFormula1[idx];
                  
                              lock (checkCustomFormula1)
                              {
                                  checkCustomFormula1.MyInput0 = myInput0;
                                  myInput0 = checkCustomFormula1.MyInput0;
                  
                                  if (cacheCustomFormula1 != null)
                                      for (int idx = 0; idx < cacheCustomFormula1.Length; idx++)
                                          if (cacheCustomFormula1[idx].MyInput0 == myInput0 && cacheCustomFormula1[idx].EqualsInput(input))
                                              return cacheCustomFormula1[idx];
                  
                                  CustomFormula1 indicator = new CustomFormula1();
                                  indicator.BarsRequired = BarsRequired;
                                  indicator.CalculateOnBarClose = CalculateOnBarClose;
                  #if NT7
                                  indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                                  indicator.MaximumBarsLookBack = MaximumBarsLookBack;
                  #endif
                                  indicator.Input = input;
                                  indicator.MyInput0 = myInput0;
                                  Indicators.Add(indicator);
                                  indicator.SetUp();
                  
                                  CustomFormula1[] tmp = new CustomFormula1[cacheCustomFormula1 == null ? 1 : cacheCustomFormula1.Length + 1];
                                  if (cacheCustomFormula1 != null)
                                      cacheCustomFormula1.CopyTo(tmp, 0);
                                  tmp[tmp.Length - 1] = indicator;
                                  cacheCustomFormula1 = tmp;
                                  return indicator;
                              }
                          }
                      }
                  }
                  
                  // This namespace holds all market analyzer column definitions and is required. Do not change it.
                  namespace NinjaTrader.MarketAnalyzer
                  {
                      public partial class Column : ColumnBase
                      {
                          /// <summary>
                          /// Enter the description of your new custom indicator here
                          /// </summary>
                          /// <returns></returns>
                          [Gui.Design.WizardCondition("Indicator")]
                          public Indicator.CustomFormula1 CustomFormula1(int myInput0)
                          {
                              return _indicator.CustomFormula1(Input, myInput0);
                          }
                  
                          /// <summary>
                          /// Enter the description of your new custom indicator here
                          /// </summary>
                          /// <returns></returns>
                          public Indicator.CustomFormula1 CustomFormula1(Data.IDataSeries input, int myInput0)
                          {
                              return _indicator.CustomFormula1(input, myInput0);
                          }
                      }
                  }
                  
                  // This namespace holds all strategies and is required. Do not change it.
                  namespace NinjaTrader.Strategy
                  {
                      public partial class Strategy : StrategyBase
                      {
                          /// <summary>
                          /// Enter the description of your new custom indicator here
                          /// </summary>
                          /// <returns></returns>
                          [Gui.Design.WizardCondition("Indicator")]
                          public Indicator.CustomFormula1 CustomFormula1(int myInput0)
                          {
                              return _indicator.CustomFormula1(Input, myInput0);
                          }
                  
                          /// <summary>
                          /// Enter the description of your new custom indicator here
                          /// </summary>
                          /// <returns></returns>
                          public Indicator.CustomFormula1 CustomFormula1(Data.IDataSeries input, int myInput0)
                          {
                              if (InInitialize && input == null)
                                  throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
                  
                              return _indicator.CustomFormula1(input, myInput0);
                          }
                      }
                  }
                  #endregion
                  Attached Files
                  Last edited by sledge; 05-10-2015, 11:25 AM. Reason: making it untypical

                  Comment


                    #10
                    I sincerely thank all of you for your help. I didn't know how typical was calculated.

                    You are all correct in your assessment that I am not comfortable with coding. And I truly do not want to learn how to do it. But then I didn't purchase a lifetime multi-broker license to spend my time trying to figure out how to do basic stuff that is standard on other platforms.

                    This comment is in no way a reflection on you. But it is the way I feel about it.

                    Comment


                      #11
                      Originally posted by ussdotsons View Post
                      I sincerely thank all of you for your help. I didn't know how typical was calculated.

                      You are all correct in your assessment that I am not comfortable with coding. And I truly do not want to learn how to do it. But then I didn't purchase a lifetime multi-broker license to spend my time trying to figure out how to do basic stuff that is standard on other platforms.

                      This comment is in no way a reflection on you. But it is the way I feel about it.
                      Understood. But what you just said amounts to saying the you do not know standard trader lingo. Typical price is near universally, in all packages, the designation for (H+L+C/3). That is hardly a NinjaTrader issue.

                      This Google query describes pretty much all the common ones: https://www.google.com/search?num=10....0.v02UVp7WSBY

                      Comment


                        #12
                        And you learn something new everyday. Thanx for sharing.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by junkone, Today, 11:37 AM
                        0 responses
                        6 views
                        0 likes
                        Last Post junkone
                        by junkone
                         
                        Started by quantismo, 04-17-2024, 05:13 PM
                        5 responses
                        35 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Started by proptrade13, Today, 11:06 AM
                        1 response
                        6 views
                        0 likes
                        Last Post NinjaTrader_Clayton  
                        Started by love2code2trade, 04-17-2024, 01:45 PM
                        4 responses
                        34 views
                        0 likes
                        Last Post love2code2trade  
                        Started by cls71, Today, 04:45 AM
                        2 responses
                        10 views
                        0 likes
                        Last Post eDanny
                        by eDanny
                         
                        Working...
                        X