Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
user define the way a moving average is calculated
Collapse
X
-
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.Tags: None
-
-
-
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.Originally posted by ussdotsons View PostNot on my charts. There are some variations, but nothing like what I want.
On the other hand, are you saying that you want to be able to extend the current enum that holds the input definitions?
Comment
-
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.Originally posted by ussdotsons View PostNot on my charts. There are some variations, but nothing like what I want.
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,
EdAttached FilesLast edited by arbuthnot; 05-10-2015, 11:11 AM.
Comment
-
You can select the Typical Price as input series.That is exactly what you have asked for.Originally posted by ussdotsons View PostNot on my charts. There are some variations, but nothing like what I want.
If you need more exotic combinations, you can easily code it yourself, see prior post.
Comment
-
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.Originally posted by ussdotsons View PostNot on my charts. There are some variations, but nothing like what I want.
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
-
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
Comment
-
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
-
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.Originally posted by ussdotsons View PostI 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.
This Google query describes pretty much all the common ones: https://www.google.com/search?num=10....0.v02UVp7WSBY
Comment
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
77 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
45 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
27 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
32 views
0 likes
|
Last Post
|
||
|
Started by Mindset, 02-28-2026, 06:16 AM
|
0 responses
63 views
0 likes
|
Last Post
by Mindset
02-28-2026, 06:16 AM
|

Comment