using System; using System.Drawing; using TradingPlatform.BusinessLayer; namespace MTF_Multi_EMA { public class MTF_Multi_EMA : Indicator { #region Global Setup // Inputs [InputParameter("Timeframe 1", 0)] private Period timeframe1 = Period.MIN1; [InputParameter("EMA 1-1 Period", 1)] private int ema11Period = 8; [InputParameter("EMA 1-2 Period", 2)] private int ema12Period = 9; [InputParameter("Timeframe 2", 3)] private Period timeframe2 = Period.MIN5; [InputParameter("EMA 2-1 Period", 4)] private int ema21Period = 8; [InputParameter("EMA 2-2 Period", 5)] private int ema22Period = 9; [InputParameter("Timeframe 3", 6)] private Period timeframe3 = Period.MIN10; [InputParameter("EMA 3-1 Period", 7)] private int ema31Period = 20; [InputParameter("EMA 3-2 Period", 8)] private int ema32Period = 21; // Indicators private Indicator ema11, ema12; private Indicator ema21, ema22; private Indicator ema31, ema32; // Historical Data private HistoricalData hdEma1, hdEma2, hdEma3; #endregion public MTF_Multi_EMA() : base() { Name = "MTF Multi EMA"; Description = "Multi-timeframe EMA"; // M1 (1 минута) → Зеленый #12b05b AddLineSeries("EMA 1-1", Color.FromArgb(0x12, 0xB0, 0x5B), 2, LineStyle.Solid); AddLineSeries("EMA 1-2", Color.FromArgb(0x12, 0xB0, 0x5B), 2, LineStyle.Solid); // M5 (5 минут) → Голубой #50b9c1 AddLineSeries("EMA 2-1", Color.FromArgb(0x50, 0xB9, 0xC1), 2, LineStyle.Solid); AddLineSeries("EMA 2-2", Color.FromArgb(0x50, 0xB9, 0xC1), 2, LineStyle.Solid); // M10 (10 минут) → Синий #2962ff AddLineSeries("EMA 3-1", Color.FromArgb(0x29, 0x62, 0xFF), 2, LineStyle.Solid); AddLineSeries("EMA 3-2", Color.FromArgb(0x29, 0x62, 0xFF), 2, LineStyle.Solid); SeparateWindow = false; // Индикатор поверх графика } protected override void OnInit() { ema11 = Core.Instance.Indicators.BuiltIn.EMA(ema11Period, PriceType.Close, IndicatorCalculationType.AllAvailableData); ema12 = Core.Instance.Indicators.BuiltIn.EMA(ema12Period, PriceType.Close, IndicatorCalculationType.AllAvailableData); ema21 = Core.Instance.Indicators.BuiltIn.EMA(ema21Period, PriceType.Close, IndicatorCalculationType.AllAvailableData); ema22 = Core.Instance.Indicators.BuiltIn.EMA(ema22Period, PriceType.Close, IndicatorCalculationType.AllAvailableData); ema31 = Core.Instance.Indicators.BuiltIn.EMA(ema31Period, PriceType.Close, IndicatorCalculationType.AllAvailableData); ema32 = Core.Instance.Indicators.BuiltIn.EMA(ema32Period, PriceType.Close, IndicatorCalculationType.AllAvailableData); hdEma1 = this.Symbol.GetHistory(timeframe1, this.Symbol.HistoryType, DateTime.UtcNow.AddDays(-30)); hdEma2 = this.Symbol.GetHistory(timeframe2, this.Symbol.HistoryType, DateTime.UtcNow.AddDays(-30)); hdEma3 = this.Symbol.GetHistory(timeframe3, this.Symbol.HistoryType, DateTime.UtcNow.AddDays(-30)); hdEma1.AddIndicator(ema11); hdEma1.AddIndicator(ema12); hdEma2.AddIndicator(ema21); hdEma2.AddIndicator(ema22); hdEma3.AddIndicator(ema31); hdEma3.AddIndicator(ema32); } protected override void OnUpdate(UpdateArgs args) { var time = this.Time(); int offset1 = (int)hdEma1.GetIndexByTime(time.Ticks); int offset2 = (int)hdEma2.GetIndexByTime(time.Ticks); int offset3 = (int)hdEma3.GetIndexByTime(time.Ticks); SetValue(ema11.GetValue(offset1), 0); SetValue(ema12.GetValue(offset1), 1); SetValue(ema21.GetValue(offset2), 2); SetValue(ema22.GetValue(offset2), 3); SetValue(ema31.GetValue(offset3), 4); SetValue(ema32.GetValue(offset3), 5); } } }