Category Trend  Published on 09/01/2022

Elder Impulse System with ATR Bands

Description

This is the cTrader version of an indicator found on TradingView with some minor changes (up and down bars have slightly different colors):


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

namespace cAlgo
{
    [Cloud("Upper ATR Band 3", "Upper ATR Band 2", Opacity = 0.2, FirstColor = "FFFE0000")]
    [Cloud("Lower ATR Band 3", "Lower ATR Band 2", Opacity = 0.2, SecondColor = "FFFE0000")]
    [Cloud("Upper ATR Band 2", "Upper ATR Band 1", Opacity = 0.2, FirstColor = "FFFFC000")]
    [Cloud("Lower ATR Band 2", "Lower ATR Band 1", Opacity = 0.2, SecondColor = "FFFFC000")]
    [Cloud("Upper ATR Band 1", "Lower ATR Band 1", Opacity = 0.2, FirstColor = "FF737373")]
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class ElderImpulseSystem : Indicator
    {
        [Parameter("Short-Term EMA", DefaultValue = 13)]
        public int EMA_St { get; set; }

        [Parameter("Long-Term EMA (not considered for coloring)", DefaultValue = 65)]
        public int EMA_Lt { get; set; }

        [Parameter("Slow MACD", DefaultValue = 26)]
        public int MACD_Slow { get; set; }

        [Parameter("Fast MACD", DefaultValue = 12)]
        public int MACD_Fast { get; set; }

        [Parameter("Signal MACD", DefaultValue = 9)]
        public int MACD_Signal { get; set; }

        [Parameter("Lookback", DefaultValue = 1)]
        public int Lookback { get; set; }

        [Parameter("ATR Period", DefaultValue = 10)]
        public int ATRPeriod { get; set; }

        [Parameter("ATR Band 1", DefaultValue = 1.0)]
        public double ATRBand1 { get; set; }

        [Parameter("ATR Band 2", DefaultValue = 2.0)]
        public double ATRBand2 { get; set; }

        [Parameter("ATR Band 3", DefaultValue = 3.0)]
        public double ATRBand3 { get; set; }

        [Parameter("Show ATR Bands", DefaultValue = true)]
        public bool ShowATRBands { get; set; }

        [Parameter("Recolor Bars", DefaultValue = true)]
        public bool RecolorBars { get; set; }



        [Output("Fast EMA", LineColor = "Cyan", PlotType = PlotType.Line, Thickness = 2)]
        public IndicatorDataSeries FastEMA { get; set; }

        [Output("Slow EMA", LineColor = "White", PlotType = PlotType.Line, Thickness = 2)]
        public IndicatorDataSeries SlowEMA { get; set; }

        [Output("Upper ATR Band 1", LineColor = "Transparent")]
        public IndicatorDataSeries UpperATRBand1 { get; set; }

        [Output("Upper ATR Band 2", LineColor = "Transparent")]
        public IndicatorDataSeries UpperATRBand2 { get; set; }

        [Output("Upper ATR Band 3", LineColor = "Transparent")]
        public IndicatorDataSeries UpperATRBand3 { get; set; }

        [Output("Lower ATR Band 1", LineColor = "Transparent")]
        public IndicatorDataSeries LowerATRBand1 { get; set; }

        [Output("Lower ATR Band 2", LineColor = "Transparent")]
        public IndicatorDataSeries LowerATRBand2 { get; set; }

        [Output("Lower ATR Band 3", LineColor = "Transparent")]
        public IndicatorDataSeries LowerATRBand3 { get; set; }



        public int dir = 0;
        private ExponentialMovingAverage emaFast, emaSlow;
        private MacdCrossOver macd;
        private AverageTrueRange atr;



        protected override void Initialize()
        {
            emaFast = Indicators.ExponentialMovingAverage(Bars.ClosePrices, EMA_St);
            emaSlow = Indicators.ExponentialMovingAverage(Bars.ClosePrices, EMA_Lt);
            macd = Indicators.MacdCrossOver(MACD_Slow, MACD_Fast, MACD_Signal);
            atr = Indicators.AverageTrueRange(ATRPeriod, MovingAverageType.WilderSmoothing);
        }

        public override void Calculate(int index)
        {
            double fast = emaFast.Result[index];
            double slow = emaSlow.Result[index];
            double atrValue = atr.Result[index];

            FastEMA[index] = fast;
            SlowEMA[index] = slow;

            if (ShowATRBands)
            {
                UpperATRBand1[index] = fast + ATRBand1 * atrValue;
                UpperATRBand2[index] = fast + ATRBand2 * atrValue;
                UpperATRBand3[index] = fast + ATRBand3 * atrValue;

                LowerATRBand1[index] = fast - ATRBand1 * atrValue;
                LowerATRBand2[index] = fast - ATRBand2 * atrValue;
                LowerATRBand3[index] = fast - ATRBand3 * atrValue;
            }

            dir = 0;

            if (fast > emaFast.Result[index - Lookback] && macd.Histogram[index] > macd.Histogram[index - Lookback])
                dir = 1;

            if (fast < emaFast.Result[index - Lookback] && macd.Histogram[index] < macd.Histogram[index - Lookback])
                dir = -1;

            if (RecolorBars)
            {
                bool up = Bars.ClosePrices[index] > Bars.OpenPrices[index];

                Color color = dir == 1 ? (up ? Color.LimeGreen : Color.DarkGreen) : dir == -1 ? (up ? Color.Tomato : Color.Crimson) : (up ? Color.LightBlue : Color.Blue);
                Chart.SetBarColor(index, color);
            }
        }
    }
}


CW
cW22Trader

Joined on 16.03.2021

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Elder Impulse System.algo
  • Rating: 0
  • Installs: 1741
Comments
Log in to add a comment.
PR
Privalov.Ivan · 3 months ago

That is a great and informative indicator. it took me a bit to get used to it and the re-coloured bars and I started to enjoy it. One thing I am still guessing is the difference between the blue and the white bars.

It would also be wonderful if we would be able to choose the colours for the re-coloured bars.

Thank you a lot!

HA
harvyblake8899 · 1 year ago

Content is definitely well written and all the suggestions are formulated in an experienced fashion. 

john wick
WICK JOHN
discovery guide
Charles Themas
Charles Themas
Ethen Lewis
Joerg Wick
Luces Willam

QA
qatarairwaysflightsuk · 1 year ago

Lot of cheers for a pretty good piece of related information from a specialist blog owner with gratifying article. I truly took pleasure in while perusing those impressive particulars in this kind of short article.

Qatar Airways Ticket Price
Qatar Flight Ticket Price
Book Qatar Flights
Qatar Airways Cheap flights
Qatar Airways Offers

MA
mariummarium822 · 1 year ago

I have gained a lot of knowledge from your articles, and it has had a big influence on my life. I appreciate all you do.

 

https://wick-john.blogspot.com/
https://wickjohn7.wordpress.com/
https://wickjohn.weebly.com
https://wickjohn1.wixsite.com/mysite

AH
ah0719919 · 1 year ago

This post suffices to make somebody realize this impressive thing. I am sure everybody will like this world-class blog post.

https://cheeringtrips.blogspot.com/
https://cheapestumrahinuk.blogspot.com/
https://ourtraveldestiny.blogspot.com/
https://sidetrackedmagazine.blogspot.com/
https://goingawesomeplaces.blogspot.com/

MO
moeed.weprintboxes · 1 year ago

Looking ahead to such sort of composition in the coming future as it is really useful and educational.

Nelson Baker
Mitchell Carter
Harris Wright
Garcia Thompson
Campbell Roberts
Custom Boxes Hub
My Custom Boxes

MO
moeed.weprintboxes · 1 year ago

I am considerably joyful to come by these sort of messages. I am talking about it with my associates as they are even seeking this sort of instructive messages.

James David
Jon Adam
Jack Bushell
Elvin Happs
Hamlen Forkan

AD
adnankanggrewal123 · 1 year ago

I am truly more than happy to happen by these variety of blogs.

Adam Steven
Jack Bravo
Bret Bartholat
Marlin Stitson
Nicole Gale