Stock Portfolio Organizer
The ultimate porfolio management solution.
Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
WiseTrader Toolbox
#1 Selling Amibroker Plugin featuring:
Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
rtrt for NinjaTrader
Copy & Paste Friendly
Back
#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> /// Bill Williams Market Facilitation Index, taken from http://ta.mql4.com/indicators/bills/market_facilitation_index /// </summary> [Description("Bill Williams Market Facilitation Index")] public class BwMfi : Indicator { #region Variables // Wizard generated variables private double range = 1; // Default setting for Range // 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.Bar, "MFI")); CalculateOnBarClose = true; Overlay = false; PriceTypeSupported = false; } /// <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. if(Volume[0]>0) MFI.Set(Range*(High[0]-Low[0])/Volume[0]); } public override string ToString(){ return "BwMfi"; } #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 MFI { get { return Values[0]; } } [Description("")] [Category("Parameters")] public double Range { get { return range; } set { range = Math.Max(0, 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 BwMfi[] cacheBwMfi = null; private static BwMfi checkBwMfi = new BwMfi(); /// <summary> /// Bill Williams Market Facilitation Index /// </summary> /// <returns></returns> public BwMfi BwMfi(double range) { return BwMfi(Input, range); } /// <summary> /// Bill Williams Market Facilitation Index /// </summary> /// <returns></returns> public BwMfi BwMfi(Data.IDataSeries input, double range) { checkBwMfi.Range = range; range = checkBwMfi.Range; if (cacheBwMfi != null) for (int idx = 0; idx < cacheBwMfi.Length; idx++) if (Math.Abs(cacheBwMfi[idx].Range - range) <= double.Epsilon && cacheBwMfi[idx].EqualsInput(input)) return cacheBwMfi[idx]; BwMfi indicator = new BwMfi(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; indicator.Input = input; indicator.Range = range; indicator.SetUp(); BwMfi[] tmp = new BwMfi[cacheBwMfi == null ? 1 : cacheBwMfi.Length + 1]; if (cacheBwMfi != null) cacheBwMfi.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheBwMfi = tmp; Indicators.Add(indicator); 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> /// Bill Williams Market Facilitation Index /// </summary> /// <returns></returns> [Gui.Design.WizardCondition("Indicator")] public Indicator.BwMfi BwMfi(double range) { return _indicator.BwMfi(Input, range); } /// <summary> /// Bill Williams Market Facilitation Index /// </summary> /// <returns></returns> public Indicator.BwMfi BwMfi(Data.IDataSeries input, double range) { return _indicator.BwMfi(input, range); } } } // This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { public partial class Strategy : StrategyBase { /// <summary> /// Bill Williams Market Facilitation Index /// </summary> /// <returns></returns> [Gui.Design.WizardCondition("Indicator")] public Indicator.BwMfi BwMfi(double range) { return _indicator.BwMfi(Input, range); } /// <summary> /// Bill Williams Market Facilitation Index /// </summary> /// <returns></returns> public Indicator.BwMfi BwMfi(Data.IDataSeries input, double range) { 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.BwMfi(input, range); } } } #endregion