// // #region Using declarations using System; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.ComponentModel; using System.Xml.Serialization; using NinjaTrader.Data; using NinjaTrader.Gui.Chart; #endregion // This namespace holds all indicators and is required. Do not change it. namespace NinjaTrader.Indicator { /// /// B. W. Market Facilitation Index, NT version by eDanny (www.Integrity-Traders.com). /// [Description("B.W. Market Facilitation Index, courtesy of MetaTrader, NT version by eDanny (www.Integrity-Traders.com).")] public class MarketFacilitationIndex : Indicator { #region Variables private DataSeries mfi; bool mfiUp; bool volUp; bool useOpenClose = false; #endregion /// /// This method is used to configure the indicator and is called once before any bar data is loaded. /// protected override void Initialize() { Add(new Plot(new Pen(Color.LimeGreen,3), PlotStyle.Bar, "MFIUpVUp")); //Plot0 Add(new Plot(new Pen(Color.SaddleBrown,3), PlotStyle.Bar, "MFIDnVDn")); //Plot1 Add(new Plot(new Pen(Color.Blue,3), PlotStyle.Bar, "MFIUpVDn")); //Plot2 Add(new Plot(new Pen(Color.HotPink,3), PlotStyle.Bar, "MFIDnVUp")); //Plot3 Add(new Plot(new Pen(Color.Black,2), PlotStyle.Line, "MFIline")); //Plot4 mfi = new DataSeries(this); Overlay = false; PriceTypeSupported = true; CalculateOnBarClose = false; } /// /// Called on each bar update event (incoming tick) /// protected override void OnBarUpdate() { if(CurrentBar == 0) { Values[0].Set(0); Values[1].Set(0); Values[2].Set(0); Values[3].Set(0); } else { if(!useOpenClose) mfi[0]=(High[0]-Low[0])/(Volume[0]*TickSize); else mfi[0]=(Math.Abs(Open[0]-Close[0]))/(Volume[0]*TickSize); } if (CurrentBar > 1) { if(mfi[0]>mfi[1]) mfiUp=true; if(mfi[0]Volume[1]) volUp=true; if(Volume[0] /// B.W. Market Facilitation Index, courtesy of MetaTrader, NT version by eDanny (www.Integrity-Traders.com). /// /// public MarketFacilitationIndex MarketFacilitationIndex(bool useOpenClose) { return MarketFacilitationIndex(Input, useOpenClose); } /// /// B.W. Market Facilitation Index, courtesy of MetaTrader, NT version by eDanny (www.Integrity-Traders.com). /// /// public MarketFacilitationIndex MarketFacilitationIndex(Data.IDataSeries input, bool useOpenClose) { checkMarketFacilitationIndex.UseOpenClose = useOpenClose; useOpenClose = checkMarketFacilitationIndex.UseOpenClose; if (cacheMarketFacilitationIndex != null) for (int idx = 0; idx < cacheMarketFacilitationIndex.Length; idx++) if (cacheMarketFacilitationIndex[idx].UseOpenClose == useOpenClose && cacheMarketFacilitationIndex[idx].EqualsInput(input)) return cacheMarketFacilitationIndex[idx]; MarketFacilitationIndex indicator = new MarketFacilitationIndex(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; indicator.Input = input; indicator.UseOpenClose = useOpenClose; indicator.SetUp(); MarketFacilitationIndex[] tmp = new MarketFacilitationIndex[cacheMarketFacilitationIndex == null ? 1 : cacheMarketFacilitationIndex.Length + 1]; if (cacheMarketFacilitationIndex != null) cacheMarketFacilitationIndex.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheMarketFacilitationIndex = 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 { /// /// B.W. Market Facilitation Index, courtesy of MetaTrader, NT version by eDanny (www.Integrity-Traders.com). /// /// [Gui.Design.WizardCondition("Indicator")] public Indicator.MarketFacilitationIndex MarketFacilitationIndex(bool useOpenClose) { return _indicator.MarketFacilitationIndex(Input, useOpenClose); } /// /// B.W. Market Facilitation Index, courtesy of MetaTrader, NT version by eDanny (www.Integrity-Traders.com). /// /// public Indicator.MarketFacilitationIndex MarketFacilitationIndex(Data.IDataSeries input, bool useOpenClose) { return _indicator.MarketFacilitationIndex(input, useOpenClose); } } } // This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader.Strategy { public partial class Strategy : StrategyBase { /// /// B.W. Market Facilitation Index, courtesy of MetaTrader, NT version by eDanny (www.Integrity-Traders.com). /// /// [Gui.Design.WizardCondition("Indicator")] public Indicator.MarketFacilitationIndex MarketFacilitationIndex(bool useOpenClose) { return _indicator.MarketFacilitationIndex(Input, useOpenClose); } /// /// B.W. Market Facilitation Index, courtesy of MetaTrader, NT version by eDanny (www.Integrity-Traders.com). /// /// public Indicator.MarketFacilitationIndex MarketFacilitationIndex(Data.IDataSeries input, bool useOpenClose) { 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.MarketFacilitationIndex(input, useOpenClose); } } } #endregion