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
-
-
-
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
-
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
-
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
-
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
-
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 junkone, Today, 11:37 AM
|
0 responses
6 views
0 likes
|
Last Post
by junkone
Today, 11:37 AM
|
||
Started by quantismo, 04-17-2024, 05:13 PM
|
5 responses
35 views
0 likes
|
Last Post Today, 11:32 AM | ||
Started by proptrade13, Today, 11:06 AM
|
1 response
6 views
0 likes
|
Last Post Today, 11:27 AM | ||
Started by love2code2trade, 04-17-2024, 01:45 PM
|
4 responses
34 views
0 likes
|
Last Post Yesterday, 10:31 PM | ||
Started by cls71, Today, 04:45 AM
|
2 responses
10 views
0 likes
|
Last Post
by eDanny
Today, 11:11 AM
|
Comment