Category Trend  Published on 17/06/2019

Elder Impulse

Description

Follow my cTrader Telegram group at https://t.me/cTraderCommunity; it's a new community but it will grow fast, plus everyone can talk about cTrader indicators and algorithm without restrictions, though it is not allowed to spam commercial indicators to sell them.

This is the famous Elder Impulse, drawn on chart by coloring candles. It work by giving a color signal when an EMA and a MACD move in the same direction, if they move opposite directions, the candle will be blue.

Enjoy


using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class ElderImpulse : Indicator
    {
        [Parameter(DefaultValue = 13)]
        public int EMA_Periods { get; set; }
        [Parameter(DefaultValue = 26)]
        public int MACD_Slow { get; set; }
        [Parameter(DefaultValue = 12)]
        public int MACD_Fast { get; set; }

        public int dir = 0;

        private ExponentialMovingAverage ema;
        private MacdCrossOver MACD;

        protected override void Initialize()
        {
            ema = Indicators.ExponentialMovingAverage(MarketSeries.Close, EMA_Periods);
            MACD = Indicators.MacdCrossOver(MACD_Slow, MACD_Fast, 9);
        }

        public override void Calculate(int i)
        {
            dir = 0;

            if (ema.Result[i] > ema.Result[i - 1])
                if (MACD.MACD[i] > MACD.MACD[i - 1])
                    dir = 1;

            if (ema.Result[i] < ema.Result[i - 1])
                if (MACD.MACD[i] < MACD.MACD[i - 1])
                    dir = -1;

            DrawCandles(i);
        }

        private void DrawCandles(int i)
        {
            Colors color = dir == 1 ? Colors.Green : Colors.Blue;
            color = dir == -1 ? Colors.Red : color;
            ChartObjects.DrawLine("high low" + i, i, MarketSeries.High[i], i, MarketSeries.Low[i], color);
            ChartObjects.DrawLine("open close" + i, i, MarketSeries.Close[i], i, MarketSeries.Open[i], color, 3, LineStyle.Solid);
            return;
        }
    }
}


CY
cysecsbin.01

Joined on 10.11.2018 Blocked

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Elder Impulse.algo
  • Rating: 0
  • Installs: 2281
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
No comments found.