KF - TEMA - DEMA - v3 free

by gmkenneyy in category Trend at 05/07/2022
Description

This is a far better version than the one i uploaded prior to this. 

PLEASE USE THIS ONE INSTEAD.

 

Most of us use moving average cross-overs to enter / exit trades.

This composite indicator that i created combines the best two of the Moving Average types as cross-over pairs

It lets you place a moving average of a higher timeframe onto the current chart. 

YOU WONT BE DISSAPPOiNTED!!!

 

Please feel free to reshape all my uploaded tools and PLEASE share the code. Thanks!!!

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
´╗┐using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo
{
    public enum TimeFrameE
    {
        Current_Chart,
        M1,
        M2,
        M3,
        M4,
        M5,
        M6,
        M7,
        M8,
        M9,
        M10,
        M15,
        M20,
        M30,
        M45,

        H1,
        H2,
        H3,
        H4,
        H6,
        H8,
        H12,

        D1,
        D2,
        D3,

        W1,

        MN1
    }
    
    public enum DSTypeE
    {
        OpenPrices,
        ClosePrices,
        HighPrices,
        LowPrices,
        MedianPrices,
        TypicalPrices,
        WeightedPrices
    }    

    [Indicator(IsOverlay = true, AutoRescale = false, AccessRights = AccessRights.None)]
    public class KF_Mtf_TemaDema_v3 : Indicator
    {
        [Parameter("Tema_Period", DefaultValue = 14, Group = "Tema")]
        public int Tema_Period { get; set; }

        [Parameter("Tema_TimeFrame", DefaultValue = TimeFrameE.Current_Chart, Group = "Tema")]
        public TimeFrameE Tema_TimeFrame { get; set; }

        [Parameter("Tema_DsType", DefaultValue = DSTypeE.ClosePrices)]
        public DSTypeE Tema_DsType { get; set; }



        [Parameter("Dema_Period", DefaultValue = 14, Group = "Dema")]
        public int Dema_Period { get; set; }

        [Parameter("Dema_TimeFrame", DefaultValue = TimeFrameE.Current_Chart, Group = "Dema")]
        public TimeFrameE Dema_TimeFrame { get; set; }

        [Parameter("Dema_DsType", DefaultValue = DSTypeE.ClosePrices)]
        public DSTypeE Dema_DsType { get; set; }



        [Output("TEMA", LineColor = "Teal", Thickness = 2)]
        public IndicatorDataSeries TEMA { get; set; }

        [Output("DEMA", LineColor = "Yellow", Thickness = 2)]
        public IndicatorDataSeries DEMA { get; set; }


        private ExponentialMovingAverage tEMA1, tEMA2, tEMA3;
        private ExponentialMovingAverage dEMA1, dEMA2;

        private Bars temaBars, demaBars;

        private TimeFrame ToTimeFrame(TimeFrameE tfe)
        {
            TimeFrame tmp = Chart.TimeFrame;

            switch (tfe)
            {
                case TimeFrameE.Current_Chart:
                    tmp = Chart.TimeFrame;
                    break;
                case TimeFrameE.D1:
                    tmp = TimeFrame.Daily;
                    break;
                case TimeFrameE.D2:
                    tmp = TimeFrame.Day2;
                    break;
                case TimeFrameE.D3:
                    tmp = TimeFrame.Day3;
                    break;
                case TimeFrameE.H1:
                    tmp = TimeFrame.Hour;
                    break;
                case TimeFrameE.H12:
                    tmp = TimeFrame.Hour12;
                    break;
                case TimeFrameE.H2:
                    tmp = TimeFrame.Hour2;
                    break;
                case TimeFrameE.H3:
                    tmp = TimeFrame.Hour3;
                    break;
                case TimeFrameE.H4:
                    tmp = TimeFrame.Hour4;
                    break;
                case TimeFrameE.H6:
                    tmp = TimeFrame.Hour6;
                    break;
                case TimeFrameE.H8:
                    tmp = TimeFrame.Hour8;
                    break;
                case TimeFrameE.M1:
                    tmp = TimeFrame.Minute;
                    break;
                case TimeFrameE.M10:
                    tmp = TimeFrame.Minute10;
                    break;
                case TimeFrameE.M15:
                    tmp = TimeFrame.Minute15;
                    break;
                case TimeFrameE.M2:
                    tmp = TimeFrame.Minute2;
                    break;
                case TimeFrameE.M20:
                    tmp = TimeFrame.Minute20;
                    break;
                case TimeFrameE.M3:
                    tmp = TimeFrame.Minute3;
                    break;
                case TimeFrameE.M30:
                    tmp = TimeFrame.Minute30;
                    break;
                case TimeFrameE.M4:
                    tmp = TimeFrame.Minute4;
                    break;
                case TimeFrameE.M45:
                    tmp = TimeFrame.Minute45;
                    break;
                case TimeFrameE.M5:
                    tmp = TimeFrame.Minute5;
                    break;
                case TimeFrameE.M6:
                    tmp = TimeFrame.Minute6;
                    break;
                case TimeFrameE.M7:
                    tmp = TimeFrame.Minute7;
                    break;
                case TimeFrameE.M8:
                    tmp = TimeFrame.Minute8;
                    break;
                case TimeFrameE.M9:
                    tmp = TimeFrame.Minute9;
                    break;
                case TimeFrameE.MN1:
                    tmp = TimeFrame.Monthly;
                    break;
                case TimeFrameE.W1:
                    tmp = TimeFrame.Weekly;
                    break;
            }

            return tmp;
            ;
        }
        
        protected DataSeries GetDS(Bars bars, DSTypeE rqdDS)
        {
            switch (rqdDS)
            {
                case DSTypeE.OpenPrices: return bars.OpenPrices;
                case DSTypeE.HighPrices: return bars.HighPrices;                    
                case DSTypeE.LowPrices: return bars.LowPrices;
                case DSTypeE.MedianPrices: return bars.MedianPrices;
                case DSTypeE.TypicalPrices: return bars.TypicalPrices;
                case DSTypeE.WeightedPrices: return bars.WeightedPrices;

                default: return bars.ClosePrices;
            }
        }        

        protected override void Initialize()
        {
            var temaTF = ToTimeFrame(Tema_TimeFrame);
            var demaTF = ToTimeFrame(Dema_TimeFrame);

            temaBars = temaTF == Chart.TimeFrame ? Bars : MarketData.GetBars(temaTF);
            demaBars = demaTF == Chart.TimeFrame ? Bars : MarketData.GetBars(demaTF);

            while (temaBars.LoadMoreHistory() > 0) { };
            while (demaBars.LoadMoreHistory() > 0) { };

            tEMA1 = Indicators.ExponentialMovingAverage(GetDS(temaBars, Tema_DsType), Tema_Period);
            tEMA2 = Indicators.ExponentialMovingAverage(tEMA1.Result, Tema_Period);
            tEMA3 = Indicators.ExponentialMovingAverage(tEMA2.Result, Tema_Period);

            dEMA1 = Indicators.ExponentialMovingAverage(GetDS(demaBars, Dema_DsType), Dema_Period);
            dEMA2 = Indicators.ExponentialMovingAverage(dEMA1.Result, Dema_Period);
        }

        public override void Calculate(int index)
        {
            var temaIdx = temaBars.OpenTimes.GetIndexByExactTime(Bars.OpenTimes[index]);
            temaIdx = temaIdx == -1 ? temaBars.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]) : temaIdx;

            var demaIdx = demaBars.OpenTimes.GetIndexByExactTime(Bars.OpenTimes[index]);
            demaIdx = demaIdx == -1 ? demaBars.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]) : demaIdx;

            if (temaIdx != -1)
                TEMA[index] = (3 * tEMA1.Result[temaIdx]) - (3 * tEMA2.Result[temaIdx]) + tEMA3.Result[temaIdx];

            if (demaIdx != -1)
                DEMA[index] = (2 * dEMA1.Result[demaIdx]) - dEMA2.Result[demaIdx];
        }
    }
}
Comments

brooks4553 - July 17, 2022 @ 03:15

Reviewing websites may be helpful for anybody interested in playing casino games online. The most visited sites (like New Jercey PlayCasinosNJ reviews) provide a plethora of data that may be used to help you choose an appropriate online casino. However, you should be aware that some of these sites are just advertisements for the casinos they review. It might be difficult to discern the real from the fake on certain websites due to their high level of polish and plenty of positive material. There is a happy medium between information provision and business objectives on most of these sites.

lemieuxhelmsis65 - July 22, 2022 @ 10:37

This is a combination of Stochastic Indicator and ADX component of the DMS system.

 

Pressure Pros

gmkenneyy - July 31, 2022 @ 22:47

@lemieuxhelmsis65

Are you sure about that? - Stochastic is an oscillator, so is the DMS. Tema-Dema is not

lawrencecaroll64 - August 11, 2022 @ 00:29

Reviewing websites may be helpful for anybody interested in playing casino games online. The most visited sites (like New Jersey PlayCasinosNJ reviews) provide a plethora of data that may be used to help you choose an appropriate online casino. However, you should be aware that some of these sites are just advertisements for the casinos they review. It might be difficult to discern the real from the fake on certain websites due to their high level of polish and plenty of positive material. There is a happy medium between information provision and business objectives on most of these sites.

junealexis001 - September 12, 2022 @ 12:06

Awesome  site i love it keep posting more!   https://fencecompanymiamifl.com

yangruflo - September 26, 2022 @ 13:57

Cool! We probably should take notes how things got this way.

service team

yangruflo - October 17, 2022 @ 13:48

Where have left off? I'm sure many beginners on this field will relate to this coding.

Tree removal services

0