/// <summary>
		/// Initializes a new instance of the <see cref="MovingAverageConvergenceDivergenceSignal"/>.
		/// </summary>
		/// <param name="macd">Convergence/divergence of moving averages.</param>
		/// <param name="signalMa">Signalling Voving Average.</param>
		public MovingAverageConvergenceDivergenceSignal(MovingAverageConvergenceDivergence macd, ExponentialMovingAverage signalMa)
			: base(macd, signalMa)
		{
			Macd = macd;
			SignalMa = signalMa;
			Mode = ComplexIndicatorModes.Sequence;
		}
Exemple #2
0
		protected override void Initialize()
		{
			ema5 = Robot.Indicators.ExponentialMovingAverage(Robot.MarketSeries.Close, 5);
			sma8 = Robot.Indicators.SimpleMovingAverage(Robot.MarketSeries.Open, 8);
			ema21 = Robot.Indicators.ExponentialMovingAverage(Robot.MarketSeries.Close, 21);
			ema55 = Robot.Indicators.ExponentialMovingAverage(Robot.MarketSeries.Close, 55);
		}
Exemple #3
0
 protected override void Initialize()
 {
     diff = CreateDataSeries();
     ema1 = Indicators.ExponentialMovingAverage(MarketSeries.Close, (int)(Period / 2));
     ema2 = Indicators.ExponentialMovingAverage(MarketSeries.Close, Period);
     ema3 = Indicators.ExponentialMovingAverage(diff, (int)(Math.Sqrt(Period)));
 }
Exemple #4
0
        protected override void Initialize()
        {
            iSeries1 = CreateDataSeries();
            iSeries4 = CreateDataSeries();

            _sma = Indicators.SimpleMovingAverage(MarketSeries.Close, Len1);
            _sma2 = Indicators.SimpleMovingAverage(_sma.Result, Len1);
            _sma3 = Indicators.SimpleMovingAverage(_sma2.Result, Len1);
            _sma4 = Indicators.SimpleMovingAverage(_sma3.Result, Len1);
            _sma5 = Indicators.SimpleMovingAverage(_sma4.Result, Len1);
            _sma6 = Indicators.SimpleMovingAverage(_sma5.Result, Len1);
            _sma7 = Indicators.SimpleMovingAverage(_sma6.Result, Len1);
            _sma8 = Indicators.SimpleMovingAverage(_sma7.Result, Len1);
            _sma9 = Indicators.SimpleMovingAverage(_sma8.Result, Len1);
            _sma10 = Indicators.SimpleMovingAverage(_sma9.Result, Len1);

            _ema1 = Indicators.ExponentialMovingAverage(iSeries1, Len3);
            _ema2 = Indicators.ExponentialMovingAverage(_ema1.Result, Len3);

            _ema3 = Indicators.ExponentialMovingAverage(ST2, Len3);
            _ema4 = Indicators.ExponentialMovingAverage(_ema3.Result, Len3);

            _ema5 = Indicators.ExponentialMovingAverage(iSeries1, Len4);
            _ema6 = Indicators.ExponentialMovingAverage(_ema3.Result, Len4);


        }
Exemple #5
0
        protected override void Initialize()
        {
            wt = CreateDataSeries();
            lsma_ma = CreateDataSeries();
            _EMA = Indicators.ExponentialMovingAverage(wt, lsma_length);

        }
Exemple #6
0
 public MACrossEntry(int p1, int p2, int p3, int p4)
     : base()
 {
     EMA1 = new ExponentialMovingAverage(p1);
     EMA2 = new ExponentialMovingAverage(p2);
     EMA3 = new ExponentialMovingAverage(p3);
     EMA4 = new ExponentialMovingAverage(p4);
 }
Exemple #7
0
        public async Task TestEmaAsync()
        {
            var equity = await ImportEquityAsync();

            var indicator = new ExponentialMovingAverage(equity, 30);
            var result    = indicator.ComputeByIndex(equity.Count - 1).Ema;

            Assert.IsTrue(136.09m.IsApproximatelyEquals(result.Value));
        }
Exemple #8
0
        /// <summary>
        /// Viene generato all'avvio dell'indicatore, si inizializza l'indicatore
        /// </summary>
        protected override void Initialize()
        {
            // --> Stampo nei log la versione corrente
            Print("{0} : {1}", NAME, VERSION);

            _ma  = Indicators.MovingAverage(Source, MAPeriods, MaType);
            _rsi = Indicators.RelativeStrengthIndex(_ma.Result, RSIPeriods);
            _ema = Indicators.ExponentialMovingAverage(_rsi.Result, TPeriods);
        }
Exemple #9
0
 protected override void OnStart()
 {
     i_MACD_main     = Indicators.MacdHistogram(MarketSeries.Close, (int)_Period_SlowEMA, (int)_Period_FastEMA, (int)_Period_MACD_SMA);
     i_MCAD_signal   = Indicators.MacdHistogram(MarketSeries.Close, (int)_Period_SlowEMA, (int)_Period_FastEMA, (int)_Period_MACD_SMA);
     i_MA_Close      = Indicators.SimpleMovingAverage(MarketSeries.Close, 1);
     i_Parabolic_SAR = Indicators.ParabolicSAR(_Step_PrbSAR, 0.1);
     i_MA_Open       = Indicators.SimpleMovingAverage(MarketSeries.Open, 1);
     i_EMAf          = Indicators.ExponentialMovingAverage(MarketSeries.Close, (int)_Period_FastEMA);
 }
Exemple #10
0
        protected override void OnTick()
        {
            ExponentialMovingAverage EMA20 = Indicators.ExponentialMovingAverage(null, 20);

            EMA20.Calculate(0);
            int x = EMA20.Result;

            x = x;
        }
Exemple #11
0
        protected override void OnStart()
        {
            cBotLabel = "ADXR " + Symbol.Code + " " + TimeFrame.ToString();
            _adx      = Indicators.GetIndicator <ADXR>(Source, interval);
            _emaFast  = Indicators.ExponentialMovingAverage(Price, FastPeriods);

            Positions.Opened += PositionsOnOpened;
            Positions.Closed += PositionsOnClosed;
        }
Exemple #12
0
        protected override void Initialize()
        {
            // Initialize and create nested indicators
            accDist = CreateDataSeries();
            ema3    = Indicators.ExponentialMovingAverage(accDist, 3);
            ema10   = Indicators.ExponentialMovingAverage(accDist, 10);

            marketSeriesDaily = MarketData.GetSeries(TimeFrame.Daily);
        }
 protected override void OnStart()
 {
     _macd      = Indicators.MacdHistogram(LongCycle, ShortCycle, Period);
     _emaFast   = Indicators.ExponentialMovingAverage(Price, FastPeriods);
     _adx       = Indicators.GetIndicator <ADXR>(Source, interval);
     _cci       = Indicators.GetIndicator <CCI>(CCI_period);
     _heiken    = Indicators.GetIndicator <HeikenAshi2>(1);
     _emasignal = Indicators.GetIndicator <ExponentialSignal>(EMAPeriod);
 }
Exemple #14
0
 protected override void Initialize()
 {
     ema1 = Indicators.ExponentialMovingAverage(Source, Period);
     ema2 = Indicators.ExponentialMovingAverage(ema1.Result, Period);
     ema3 = Indicators.ExponentialMovingAverage(ema2.Result, Period);
     ema4 = Indicators.ExponentialMovingAverage(ema3.Result, Period);
     ema5 = Indicators.ExponentialMovingAverage(ema4.Result, Period);
     ema6 = Indicators.ExponentialMovingAverage(ema5.Result, Period);
 }
Exemple #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Trix"/> class using the specified name and period.
 /// </summary>
 /// <param name="name">The name of this indicator</param>
 /// <param name="period">The period of the indicator</param>
 public Trix(string name, int period)
     : base(name)
 {
     _period = period;
     _ema1   = new ExponentialMovingAverage(name + "_1", period);
     _ema2   = new ExponentialMovingAverage(name + "_2", period);
     _ema3   = new ExponentialMovingAverage(name + "_3", period);
     _roc    = new RateOfChangePercent(name + "_ROCP1", 1);
 }
Exemple #16
0
        public async Task TestEmaAsync()
        {
            var candles = await ImportCandlesAsync();

            var indicator = new ExponentialMovingAverage(candles, 30);
            var result    = indicator[candles.Count - 1];

            Assert.IsTrue(136.09m.IsApproximatelyEquals(result.Value));
        }
Exemple #17
0
 public void NoCountOutOfRange()
 {
     Assert.Throws <ArgumentOutOfRangeException>(delegate {
         var stats = new ExponentialMovingAverage(0);
     });
     Assert.Throws <ArgumentOutOfRangeException>(delegate {
         var stats = new ExponentialMovingAverage(0, new double[] { 0 });
     });
 }
Exemple #18
0
        public void TestInitial()
        {
            var ema = new ExponentialMovingAverage(10);

            ema.Add(3);

            Assert.That(ema.Value, Is.EqualTo(3));
            Assert.That(ema.Var, Is.EqualTo(0));
        }
Exemple #19
0
        public void TestMovingAverage()
        {
            var ema = new ExponentialMovingAverage(10);

            ema.Add(5);
            ema.Add(6);

            Assert.That(ema.Value, Is.EqualTo(5.1818).Within(0.0001f));
            Assert.That(ema.Var, Is.EqualTo(0.1487).Within(0.0001f));
        }
Exemple #20
0
        protected override void Initialize()
        {
            series1 = MarketData.GetSeries(EMATimeframe1);
            series2 = MarketData.GetSeries(EMATimeframe2);
            series3 = MarketData.GetSeries(EMATimeframe3);

            Ema1 = Indicators.ExponentialMovingAverage(series1.Close, Periods);
            Ema2 = Indicators.ExponentialMovingAverage(series2.Close, Periods);
            Ema3 = Indicators.ExponentialMovingAverage(series3.Close, Periods);
        }
Exemple #21
0
        protected override void OnStart()
        {
            dc1 = Indicators.DonchianChannel(dcPeriod1);
            dc2 = Indicators.DonchianChannel(dcPeriod2);

            ema1 = Indicators.ExponentialMovingAverage(MarketSeries.Close, emaPeriod1);
            ema2 = Indicators.ExponentialMovingAverage(MarketSeries.Close, emaPeriod2);

            atr = Indicators.AverageTrueRange(atrPeriod, MovingAverageType.Exponential);
        }
Exemple #22
0
        static void Main()
        {
            TechnicalIndicator _indicator = new ExponentialMovingAverage();

            InititalizeParameters(_indicator.GetType().ToString());

            RabbitCalculateIndicator rabbitEMAExtended = new RabbitCalculateIndicator(_exchange, _queueReceiveFrom, _queueSendTo, _indicator);

            rabbitEMAExtended.ConsumeData();
        }
Exemple #23
0
        protected override void OnStart()
        {
            i_MACD_main = Indicators.MacdHistogram(MarketSeries.Close, (int)_Period_SlowEMA, (int)_Period_FastEMA, (int)_Period_MACD_SMA);
            i_MCAD_signal = Indicators.MacdHistogram(MarketSeries.Close, (int)_Period_SlowEMA, (int)_Period_FastEMA, (int)_Period_MACD_SMA);
            i_MA_Close = Indicators.SimpleMovingAverage(MarketSeries.Close, 1);
            i_Parabolic_SAR = Indicators.ParabolicSAR(_Step_PrbSAR, 0.1);
            i_MA_Open = Indicators.SimpleMovingAverage(MarketSeries.Open, 1);
            i_EMAf = Indicators.ExponentialMovingAverage(MarketSeries.Close, (int)_Period_FastEMA);

        }
Exemple #24
0
        public void TestVar()
        {
            var ema = new ExponentialMovingAverage(10);

            ema.Add(5);
            ema.Add(6);
            ema.Add(7);

            Assert.That(ema.Var, Is.EqualTo(0.6134).Within(0.0001f));
        }
Exemple #25
0
        protected override void Initialize()
        {
            ema1 = Indicators.ExponentialMovingAverage(Source, Period);
            ema2 = Indicators.ExponentialMovingAverage(ema1.Result, Period);
            ema3 = Indicators.ExponentialMovingAverage(ema2.Result, Period);
            ema4 = Indicators.ExponentialMovingAverage(ema3.Result, Period);
            ema5 = Indicators.ExponentialMovingAverage(ema4.Result, Period);
            ema6 = Indicators.ExponentialMovingAverage(ema5.Result, Period);

        }
Exemple #26
0
        public void Example1()
        {
            var stats = new ExponentialMovingAverage();

            stats.Add(4);
            stats.Add(7);
            stats.Add(13);
            stats.Add(16);
            Assert.Equal(4, stats.Count);
            Assert.Equal(7.885800150262959, stats.Average, 15);
        }
Exemple #27
0
        protected override void Initialize()
        {
            CO_Series = CreateDataSeries();
            HL_Series = CreateDataSeries();

            EMA_CO   = Indicators.ExponentialMovingAverage(CO_Series, Interval_1);
            EMA_CO_S = Indicators.ExponentialMovingAverage(EMA_CO.Result, Interval_2);

            EMA_HL   = Indicators.ExponentialMovingAverage(HL_Series, Interval_1);
            EMA_HL_S = Indicators.ExponentialMovingAverage(EMA_HL.Result, Interval_2);
        }
        public void Calculate_YesterdayEma10AndTodayPrice10And9Days_10()
        {
            var calc         = new ExponentialMovingAverage();
            var yesterdayEma = 10;
            var today        = 10;
            var numberOfDays = 9;

            var result = calc.Calculate(yesterdayEma, today, numberOfDays);

            Assert.AreEqual(10, result);
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="MovingAverageConvergenceDivergence"/>.
		/// </summary>
		/// <param name="longMa">Long moving average.</param>
		/// <param name="shortMa">Short moving average.</param>
		public MovingAverageConvergenceDivergence(ExponentialMovingAverage longMa, ExponentialMovingAverage shortMa)
		{
			if (longMa == null)
				throw new ArgumentNullException("longMa");

			if (shortMa == null)
				throw new ArgumentNullException("shortMa");

			ShortMa = shortMa;
			LongMa = longMa;
		}
Exemple #30
0
        public void Example4()
        {
            var stats = new ExponentialMovingAverage();

            stats.Add(6);
            stats.Add(2);
            stats.Add(3);
            stats.Add(1);
            Assert.Equal(4, stats.Count);
            Assert.Equal(4.157776108189332, stats.Average, 15);
        }
        [Test] public void Example()
        {
            var ema = new ExponentialMovingAverage();
            var sum = 0;

            for (var i = 1; i <= 20; i++)
            {
                float sma = (float)(sum += i) / i;
                Debug.Log($"{i,2}: sma={sma:n2}\tema={ema.Average(i):n2}");
            }
        }
Exemple #32
0
 /// <summary>
 /// Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.
 /// </summary>
 public override void Initialize()
 {
     SetStartDate(2000, 07, 01);            //Set Start Date
     SetEndDate(2015, 10, 05);              //Set End Date
     SetCash(5200);                         //Set Strategy Cash
     // Find more symbols here: http://quantconnect.com/data
     AddSecurity(SecurityType.Equity, Symbol, Resolution.Daily);
     //AddSecurity(SecurityType.Equity, Symbol2, Resolution.Daily);
     ema = EMA(Symbol, 10, Resolution.Daily);
     SetBrokerageModel(QuantConnect.Brokerages.BrokerageName.InteractiveBrokersBrokerage);
 }
Exemple #33
0
        public void Example33()
        {
            var stats = new ExponentialMovingAverage(0.9);

            stats.Add(1000000004);
            stats.Add(1000000007);
            stats.Add(1000000013);
            stats.Add(1000000016);
            Assert.Equal(4, stats.Count);
            Assert.Equal(1000000015.637, stats.Average, 15);
        }
Exemple #34
0
        protected override void Initialize()
        {
            series1 = MarketData.GetSeries(EMATimeframe1);
            series2 = MarketData.GetSeries(EMATimeframe2);
            series3 = MarketData.GetSeries(EMATimeframe3);

            Ema1 = Indicators.ExponentialMovingAverage(series1.Close, Periods);
            Ema2 = Indicators.ExponentialMovingAverage(series2.Close, Periods);
            Ema3 = Indicators.ExponentialMovingAverage(series3.Close, Periods);

        }
        public override void Initialize()
        {
            SetStartDate(2020, 1, 1);
            SetEndDate(2020, 1, 30);
            SetCash(100000);
            SetWarmup(100);

            _spy  = AddEquity("SPY", Resolution.Minute).Symbol;
            _fast = EMA(_spy, 20);
            _slow = EMA(_spy, 40);
        }
Exemple #36
0
        public void Example22()
        {
            var stats = new ExponentialMovingAverage(0.1);

            stats.Add(100000004);
            stats.Add(100000007);
            stats.Add(100000013);
            stats.Add(100000016);
            Assert.Equal(4, stats.Count);
            Assert.Equal(100000006.253, stats.Average, 15);
        }
Exemple #37
0
        public void Example34()
        {
            var stats = new ExponentialMovingAverage(0.9);

            stats.Add(6);
            stats.Add(2);
            stats.Add(3);
            stats.Add(1);
            Assert.Equal(4, stats.Count);
            Assert.Equal(1.194, stats.Average, 15);
        }
Exemple #38
0
        public override void Initialize()
        {
            SetStartDate(2013, 10, 07);
            SetEndDate(2013, 10, 11);
            SetCash(100 * 1000);

            AddSecurity(SecurityType.Equity, "SPY");

            Fast = EMA("SPY", FastPeriod);
            Slow = EMA("SPY", SlowPeriod);
        }
        protected override void Initialize()
        {
            _dixPowerDigits = Math.Pow(10, Robot.Symbol.Digits);

            i_MACD_main   = Robot.Indicators.MacdHistogram(Robot.MarketSeries.Close, Period_SlowEMA, Period_FastEMA, Period_MACD_SMA);
            i_MCAD_signal = Robot.Indicators.MacdHistogram(Robot.MarketSeries.Close, Period_SlowEMA, Period_FastEMA, Period_MACD_SMA);
            //i_MA_Close = Robot.Indicators.SimpleMovingAverage(Robot.MarketSeries.Close, 1);
            i_Parabolic_SAR = Robot.Indicators.ParabolicSAR(Step_PrbSAR, 0.1);
            i_MA_Open       = Robot.Indicators.SimpleMovingAverage(Robot.MarketSeries.Open, 1);
            i_EMAf          = Robot.Indicators.ExponentialMovingAverage(Robot.MarketSeries.Close, Period_FastEMA);
        }
        public override void Initialize()
        {
            SetStartDate(2021, 1, 1);
            SetEndDate(2021, 1, 30);
            SetCash(100000);
            SetWarmup(100);

            _gbpjpy = AddForex("GBPJPY", Resolution.Minute, Market.Oanda).Symbol;
            _fast   = EMA(_gbpjpy, 20);
            _slow   = EMA(_gbpjpy, 40);
        }
        protected override void Initialize()
        {
            // Initialize and create nested indicators
            accDist = CreateDataSeries();
            ema3 = Indicators.ExponentialMovingAverage(accDist, 3);
            ema10 = Indicators.ExponentialMovingAverage(accDist, 10);

            marketSeriesDaily = MarketData.GetSeries(TimeFrame.Daily);



        }
Exemple #42
0
        protected override void Initialize()
        {
            _zeroLagEmaShort = CreateDataSeries();
            _zeroLagEmaLong = CreateDataSeries();

            _emaLong = Indicators.ExponentialMovingAverage(MarketSeries.Close, LongCycle);
            _emaLong2 = Indicators.ExponentialMovingAverage(_emaLong.Result, LongCycle);

            _emaShort = Indicators.ExponentialMovingAverage(MarketSeries.Close, ShortCycle);
            _emaShort2 = Indicators.ExponentialMovingAverage(_emaShort.Result, ShortCycle);

            _emaSignal = Indicators.ExponentialMovingAverage(MACD, SignalPeriods);
        }
Exemple #43
0
 protected override void Initialize()
 {
     ema1 = Indicators.ExponentialMovingAverage(MarketSeries.Close, Period1);
     ema2 = Indicators.ExponentialMovingAverage(MarketSeries.Close, Period2);
     ema3 = Indicators.ExponentialMovingAverage(MarketSeries.Close, Period3);
     ema4 = Indicators.ExponentialMovingAverage(MarketSeries.Close, Period4);
     ema5 = Indicators.ExponentialMovingAverage(MarketSeries.Close, Period5);
     ema6 = Indicators.ExponentialMovingAverage(MarketSeries.Close, Period6);
     ema7 = Indicators.ExponentialMovingAverage(MarketSeries.Close, Period7);
     ema8 = Indicators.ExponentialMovingAverage(MarketSeries.Close, Period8);
     ema9 = Indicators.ExponentialMovingAverage(MarketSeries.Close, Period9);
     ema10 = Indicators.ExponentialMovingAverage(MarketSeries.Close, Period10);
 }
Exemple #44
0
        protected override void Initialize()
        {
            _iDataSeries = CreateDataSeries();
            _emaDiffCenter = Indicators.ExponentialMovingAverage(_iDataSeries, 3);
            _emaSmoothed = Indicators.ExponentialMovingAverage(_emaDiffCenter.Result, 3);

            _iDataSeriesHighLow = CreateDataSeries();
            _emaDiffHighLow = Indicators.ExponentialMovingAverage(_iDataSeriesHighLow, 3);
            _emaDiffHighLow2 = Indicators.ExponentialMovingAverage(_emaDiffHighLow.Result, 3);

            _smi = CreateDataSeries();
            _maSmi = Indicators.MovingAverage(_smi, Period, MaType);
        }
Exemple #45
0
 //Initialize the data and resolution you require for your strategy:
 public override void Initialize()
 {
     SetStartDate(2000, 01, 01);
     SetEndDate(2004,01,01);
     SetCash(25000);
     AddSecurity(SecurityType.Equity, symbol, Resolution.Daily);
     var shortval = Config.GetInt ("EMA_VAR1",10);
     emaShort = EMA(symbol, shortval, Resolution.Daily);
     emaLong = EMA(symbol, 50, Resolution.Daily);
     for (int i = 0; i < MAXRETURNS; i++) {
         _tradeReturns.Add(0);
     }
 }
        protected override void Initialize()
        {

            _atrRsi = CreateDataSeries();
            CreateDataSeries();

            _wildersPeriod = Period * 2 - 1;
            _startBar = _wildersPeriod < SF ? SF : _wildersPeriod;

            _rsi = Indicators.RelativeStrengthIndex(MarketSeries.Close, Period);
            _emaRsi = Indicators.ExponentialMovingAverage(_rsi.Result, SF);
            _emaAtr = Indicators.ExponentialMovingAverage(_atrRsi, _wildersPeriod);
            _ema = Indicators.ExponentialMovingAverage(_emaAtr.Result, _wildersPeriod);

        }
Exemple #47
0
        protected override void Initialize()
        {
            _priceRoc1 = Indicators.PriceROC(Source, X1);
            _priceRoc2 = Indicators.PriceROC(Source, X2);
            _priceRoc3 = Indicators.PriceROC(Source, X3);
            _priceRoc4 = Indicators.PriceROC(Source, X4);

            _movingAverage1 = Indicators.MovingAverage(_priceRoc1.Result, AVG1, MAType);
            _movingAverage2 = Indicators.MovingAverage(_priceRoc2.Result, AVG2, MAType);
            _movingAverage3 = Indicators.MovingAverage(_priceRoc3.Result, AVG3, MAType);
            _movingAverage4 = Indicators.MovingAverage(_priceRoc4.Result, AVG4, MAType);

            ema = Indicators.ExponentialMovingAverage(Result, 9);

        }
Exemple #48
0
        protected override void Initialize()
        {
            unsmBuffer = new double[1];
            unsmoothed = CreateDataSeries();
            _wma = Indicators.WeightedMovingAverage(unsmoothed, SmoothingPeriod);
            _ema = Indicators.ExponentialMovingAverage(_wma.Result, TriggerPeriod);

            ol = new double[4];
            pol = new double[4];
            hl = new double[4];
            phl = new double[4];
            ll = new double[4];
            pll = new double[4];
            cl = new double[4];
            pcl = new double[4];
        }
Exemple #49
0
        protected override void Initialize()
        {
            m_shortEma1 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 3);
            m_shortEma2 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 5);
            m_shortEma3 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 8);
            m_shortEma4 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 10);
            m_shortEma5 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 12);
            m_shortEma6 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 15);

            m_longEma1 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 30);
            m_longEma2 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 35);
            m_longEma3 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 40);
            m_longEma4 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 45);
            m_longEma5 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 50);
            m_longEma6 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 60);
        }
        public override void Initialize()
        {
            SetStartDate(2015, 6, 26);
            SetEndDate(2015, 7, 2);
            SetCash(25000);

            AddSecurity(SecurityType.Equity, "SPY", Resolution.Minute);

            // define our 15 minute consolidator
            var fifteenMinuteConsolidator = new TradeBarConsolidator(TimeSpan.FromMinutes(15));

            // if we want to make decisions every 15 minutes as well, we can add an event handler
            // to the DataConsolidated event
            fifteenMinuteConsolidator.DataConsolidated += OnFiftenMinuteSPY;

            int fast = 15;
            int slow = 30;

            // define our EMA, we'll manually register this, so we aren't using the helper function 'EMA(...)'
            var fastEmaOnFifteenMinuteBars = new ExponentialMovingAverage("SPY_EMA15", fast);
            var slowEmaOnFifteenMinuteBars = new ExponentialMovingAverage("SPY_EMA30", slow);

            // we can define complex indicator's using various extension methods.
            // here I use the 'Over' extension method which performs division
            // so this will be fast/slow. This returns a new indicator that represents
            // the division operation between the two
            var ratio = fastEmaOnFifteenMinuteBars.Over(slowEmaOnFifteenMinuteBars, "SPY_Ratio_EMA");

            // now we can use the 'Of' extension method to define the ROC on the ratio
            // The 'Of' extension method allows combining multiple indicators together such
            // that the data from one gets sent into the other
            var rocpOfRatio = new RateOfChangePercent("SPY_ROCP_Ratio", fast).Of(ratio);

            // we an even define a smoothed version of this indicator
            var smoothedRocpOfRatio = new ExponentialMovingAverage("SPY_Smoothed_ROCP_Ratio", 5).Of(rocpOfRatio);

            // register our indicator and consolidator together. this will wire the consolidator up to receive
            // data for the specified symbol, and also set up the indicator to receive its data from the consolidator
            RegisterIndicator("SPY", fastEmaOnFifteenMinuteBars, fifteenMinuteConsolidator, Field.Close);
            RegisterIndicator("SPY", slowEmaOnFifteenMinuteBars, fifteenMinuteConsolidator, Field.Close);

            // register the indicator to be plotted along
            PlotIndicator("SPY", fastEmaOnFifteenMinuteBars);
            PlotIndicator("SPY", slowEmaOnFifteenMinuteBars);
            PlotIndicator("SPY_ROCP_Ratio", rocpOfRatio, smoothedRocpOfRatio);
            PlotIndicator("SPY_Ratio_EMA", ratio);
        }
        public EMAEventModelStrategy(CandleSeries series, 
            ExponentialMovingAverage filterMA, ExponentialMovingAverage longMA, ExponentialMovingAverage shortMA,
            Unit takeProfitUnit, Unit stopLossUnit)
        {
            this.FilterMA = filterMA;
            this.LongMA = longMA;
            this.ShortMA = shortMA;

            this.CandleSeries = series;

            this.TakeProfitUnit = takeProfitUnit;
            this.StopLossUnit = stopLossUnit;

            this.StopTradingUnit = this.StopLossUnit * 3;

            this.UseQuoting = true;
            this.BestPriceOffset = 5;
        }
        public override void Initialize()
        {
            SetStartDate(2013, 10, 7);
            SetEndDate(2013, 10, 11);
            SetCash(250000);

            foreach (var symbol in Symbols)
            {
                AddSecurity(SecurityType.Equity, symbol, Resolution.Second);
                // Define an Identity Indicator with the close price.
                Identity priceIdentityIndicator = new Identity(symbol + "PriceIdentityIndicator");
                RegisterIndicator(symbol, priceIdentityIndicator, Resolution.Second, Field.Close);
                // Define an EMA.
                ExponentialMovingAverage EMA = new ExponentialMovingAverage("EMA_" + symbol, 100);
                RegisterIndicator(symbol, EMA, Resolution.Minute, Field.Close);
                // Inject the Price Identity indicator and the EMA in the Strategy object.
                StrategyDict.Add(symbol, new NoStrategy(symbol, priceIdentityIndicator, EMA));

                stockLogging.Add(symbol, new StringBuilder());
            }
        }
Exemple #53
0
        protected override void Initialize()
        {
            Buffer = CreateDataSeries();

            // Moving Average Type according to input MA_Type
            switch (MAType)
            {
                case 1:
                    // Simple Moving Average
                    _sma = Indicators.SimpleMovingAverage(MAApplied, MAPeriod);
                    break;
                case 2:
                    // Exponential Moving Average
                    _ema = Indicators.ExponentialMovingAverage(MAApplied, MAPeriod);
                    break;
                case 3:
                    // Smoothed Moving Average		
                    _wsma = Indicators.GetIndicator<Wsma>(MAApplied, MAPeriod);
                    break;
                case 4:
                    // Linear Weighted Moving Average  
                    _lwma = Indicators.GetIndicator<Lwma>(MAApplied, MAPeriod);
                    break;
                case 5:
                    // Double Exponential Moving Average
                    _dema = Indicators.GetIndicator<Dema>(MAApplied, MAPeriod);
                    break;
                case 6:
                    // Triple Exponential Moving Average
                    _tema = Indicators.GetIndicator<Tema>(MAApplied, MAPeriod);
                    break;
                case 7:
                    // T3 Moving Average
                    _t3MA = Indicators.GetIndicator<T3MA>(MAApplied, MAPeriod, T3MAVolumeFactor);
                    break;
            }
        }
Exemple #54
0
 protected override void Initialize()
 {
     _trend = new bool[1];
     _ema = Indicators.ExponentialMovingAverage(Source, Period);
     _averageTrueRange = Indicators.GetIndicator<AverageTrueRange>(Period);
 }
Exemple #55
0
    public override void OnStrategyStart()
    {
        decisionUnit = new DecisionUnit();
        //so_180_a Stochastic Variables
        int so_180_a_tickPeriod = 10;
        int so_180_a_bulkPeriod = 180;
        double so_180_a_highThres = 80;
        double so_180_a_lowThres = 20;
        int so_180_a_nPeriod = 14;
        double so_180_a_smooth = 3;
        int so_180_a_mPeriod = 3;

        //so_180_b Stochastic Variables
        int so_180_b_tickPeriod = 10;
        int so_180_b_bulkPeriod = 180;
        double so_180_b_highThres = 80;
        double so_180_b_lowThres = 20;
        int so_180_b_nPeriod = 21;
        double so_180_b_smooth = 4;
        int so_180_b_mPeriod = 5;

        //so_45_a Stochastic Variables
        int so_45_a_tickPeriod = 10;
        int so_45_a_bulkPeriod = 45;
        double so_45_a_highThres = 80;
        double so_45_a_lowThres = 20;
        int so_45_a_nPeriod = 14;
        double so_45_a_smooth = 3;
        int so_45_a_mPeriod = 3;

        //so_45_b Stochastic Variables
        int so_45_b_tickPeriod = 10;
        int so_45_b_bulkPeriod = 45;
        double so_45_b_highThres = 80;
        double so_45_b_lowThres = 20;
        int so_45_b_nPeriod = 21;
        double so_45_b_smooth = 4;
        int so_45_b_mPeriod = 5;

        //ema_45 Exponential Moving Avg. Variables
        int ema_45_period = 10;
        int ema_45_bulkPeriod = 45;

        //ema_180 Exponential Moving Avg. Variables
        int ema_180_period = 10;
        int ema_180_bulkPeriod = 180;

        System.Console.WriteLine("On strategy start");
        so_180_a = new StochasticOscillator("so_180_a",
                                            so_180_a_tickPeriod,
                                            so_180_a_bulkPeriod,
                                            so_180_a_highThres,
                                            so_180_a_lowThres,
                                            so_180_a_nPeriod,
                                            so_180_a_smooth,
                                            so_180_a_mPeriod);

        so_180_b = new StochasticOscillator("so_180_b",
                                            so_180_b_tickPeriod,
                                            so_180_b_bulkPeriod,
                                            so_180_b_highThres,
                                            so_180_b_lowThres,
                                            so_180_b_nPeriod,
                                            so_180_b_smooth,
                                            so_180_b_mPeriod);

        so_45_a = new StochasticOscillator("so_45_a",
                                    so_45_a_tickPeriod,
                                    so_45_a_bulkPeriod,
                                    so_45_a_highThres,
                                    so_45_a_lowThres,
                                    so_45_a_nPeriod,
                                    so_45_a_smooth,
                                    so_45_a_mPeriod);

        so_45_b = new StochasticOscillator("so_45_b",
                                    so_45_b_tickPeriod,
                                    so_45_b_bulkPeriod,
                                    so_45_b_highThres,
                                    so_45_b_lowThres,
                                    so_45_b_nPeriod,
                                    so_45_b_smooth,
                                    so_45_b_mPeriod);

        ema_180 = new ExponentialMovingAverage("ema_180", ema_180_period, ema_180_bulkPeriod);
        ema_45 = new ExponentialMovingAverage("ema_45", ema_45_period, ema_45_bulkPeriod);
    }
Exemple #56
0
 protected override void Initialize()
 {
     _averageTrueRange = Indicators.GetIndicator<AverageTrueRange>(PeriodAtr);
     _exponentialMovingAverage = Indicators.ExponentialMovingAverage(MarketSeries.Close, PeriodEma);
 }
        protected override void Initialize()
        {

            _dixPowerDigits = Math.Pow(10, Symbol.Digits);

            i_MACD_Histogram = Indicators.MacdHistogram(MarketSeries.Close, Period_SlowEMA, Period_FastEMA, Period_MACD_SMA);
            i_MCAD_signal = Indicators.MacdHistogram(MarketSeries.Close, Period_SlowEMA, Period_FastEMA, Period_MACD_SMA);
            //	i_MA_Close = Indicators.SimpleMovingAverage(MarketSeries.Close, 1);
            i_Parabolic_SAR = Indicators.ParabolicSAR(Step_PrbSAR, 0.1);
            i_MA_Open = Indicators.SimpleMovingAverage(MarketSeries.Open, 1);
            i_EMAf = Indicators.ExponentialMovingAverage(MarketSeries.Close, Period_FastEMA);
        }
 protected override void Initialize()
 {
     _tempBuffer = CreateDataSeries();
     _ema = Indicators.ExponentialMovingAverage(_tempBuffer, Period);
 }
Exemple #59
0
        protected override void Initialize()
        {


            _ema1 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 170);
            _ema2 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 180);
            _ema3 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 190);
            _ema4 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 195);
            _ema5 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 200);

            _ema6 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 160);
            _ema7 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 150);
            _ema8 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 140);
            _ema9 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 130);
            _ema10 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 120);

            _ema11 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 110);
            _ema12 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 97);
            _ema13 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 88);
            _ema14 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 79);
            _ema15 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 70);

            _ema16 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 62);
            _ema17 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 56);
            _ema18 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 48);
            _ema19 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 42);
            _ema20 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 36);

            _ema21 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 28);
            _ema22 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 24);
            _ema23 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 22);
            _ema24 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 18);
            _ema25 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 14);

            _ema26 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 12);
            _ema27 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 10);
            _ema28 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 8);
            _ema29 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 6);
            _ema30 = Indicators.ExponentialMovingAverage(MarketSeries.Close, 4);

        }
 protected override void Initialize()
 {
     ema1 = Indicators.ExponentialMovingAverage(MarketSeries.Close, SlowPeriod);
     ema2 = Indicators.ExponentialMovingAverage(MarketSeries.Close, FastPeriod);
 }