Category Oscilators  Published on 26/12/2019

Pring's Special K

Description

Follow my cTrader Telegram group at https://t.me/cTraderCommunity; everyone can talk about cTrader indicators and algorithm without restrictions, though it is not allowed to spam commercial indicators to sell them. There's also a Discord Server now @ https://discord.gg/5GAPMtp and an Instagram page https://www.instagram.com/ctrader_community/

This is Martin Pring's Special K, a timing indicator made of 12 different price ROCs, every one with a particular smoothing.

In this version, every ROCs' period is tunable, as well as every ROCs' multiplier and smoothing. There is also a setting for the final smoothing of the result, the signal line period and every smoothing has a parameter for the type of moving average to use.


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

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class SpecialK : Indicator
    {
        [Parameter("Final Smoothing", Group = "General", DefaultValue = 10)]
        public int FinalSmoothingPeriod { get; set; }
        [Parameter("Smoothing Type", Group = "General", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType FinalSmoothingType { get; set; }
        [Parameter("Signal", Group = "General", DefaultValue = 10)]
        public int SignalPeriod { get; set; }
        [Parameter("Signal Type", Group = "General", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType SignalType { get; set; }
        [Parameter("Source", Group = "General")]
        public DataSeries Source { get; set; }

        [Parameter("ROC 1", Group = "ROCs Periods", DefaultValue = 10)]
        public int ROC1 { get; set; }
        [Parameter("ROC 2", Group = "ROCs Periods", DefaultValue = 15)]
        public int ROC2 { get; set; }
        [Parameter("ROC 3", Group = "ROCs Periods", DefaultValue = 20)]
        public int ROC3 { get; set; }
        [Parameter("ROC 4", Group = "ROCs Periods", DefaultValue = 30)]
        public int ROC4 { get; set; }
        [Parameter("ROC 5", Group = "ROCs Periods", DefaultValue = 40)]
        public int ROC5 { get; set; }
        [Parameter("ROC 6", Group = "ROCs Periods", DefaultValue = 65)]
        public int ROC6 { get; set; }
        [Parameter("ROC 7", Group = "ROCs Periods", DefaultValue = 75)]
        public int ROC7 { get; set; }
        [Parameter("ROC 8", Group = "ROCs Periods", DefaultValue = 100)]
        public int ROC8 { get; set; }
        [Parameter("ROC 9", Group = "ROCs Periods", DefaultValue = 195)]
        public int ROC9 { get; set; }
        [Parameter("ROC 10", Group = "ROCs Periods", DefaultValue = 265)]
        public int ROC10 { get; set; }
        [Parameter("ROC 11", Group = "ROCs Periods", DefaultValue = 390)]
        public int ROC11 { get; set; }
        [Parameter("ROC 12", Group = "ROCs Periods", DefaultValue = 530)]
        public int ROC12 { get; set; }

        [Parameter("ROC 1", Group = "ROCs Multipliers", DefaultValue = 1)]
        public double ROC1m { get; set; }
        [Parameter("ROC 2", Group = "ROCs Multipliers", DefaultValue = 2)]
        public double ROC2m { get; set; }
        [Parameter("ROC 3", Group = "ROCs Multipliers", DefaultValue = 3)]
        public double ROC3m { get; set; }
        [Parameter("ROC 4", Group = "ROCs Multipliers", DefaultValue = 4)]
        public double ROC4m { get; set; }
        [Parameter("ROC 5", Group = "ROCs Multipliers", DefaultValue = 1)]
        public double ROC5m { get; set; }
        [Parameter("ROC 6", Group = "ROCs Multipliers", DefaultValue = 2)]
        public double ROC6m { get; set; }
        [Parameter("ROC 7", Group = "ROCs Multipliers", DefaultValue = 3)]
        public double ROC7m { get; set; }
        [Parameter("ROC 8", Group = "ROCs Multipliers", DefaultValue = 4)]
        public double ROC8m { get; set; }
        [Parameter("ROC 9", Group = "ROCs Multipliers", DefaultValue = 1)]
        public double ROC9m { get; set; }
        [Parameter("ROC 10", Group = "ROCs Multipliers", DefaultValue = 2)]
        public double ROC10m { get; set; }
        [Parameter("ROC 11", Group = "ROCs Multipliers", DefaultValue = 3)]
        public double ROC11m { get; set; }
        [Parameter("ROC 12", Group = "ROCs Multipliers", DefaultValue = 4)]
        public double ROC12m { get; set; }

        [Parameter("ROC 1", Group = "ROCs Smoothings", DefaultValue = 10)]
        public int ROC1s { get; set; }
        [Parameter("ROC 2", Group = "ROCs Smoothings", DefaultValue = 10)]
        public int ROC2s { get; set; }
        [Parameter("ROC 3", Group = "ROCs Smoothings", DefaultValue = 10)]
        public int ROC3s { get; set; }
        [Parameter("ROC 4", Group = "ROCs Smoothings", DefaultValue = 15)]
        public int ROC4s { get; set; }
        [Parameter("ROC 5", Group = "ROCs Smoothings", DefaultValue = 50)]
        public int ROC5s { get; set; }
        [Parameter("ROC 6", Group = "ROCs Smoothings", DefaultValue = 65)]
        public int ROC6s { get; set; }
        [Parameter("ROC 7", Group = "ROCs Smoothings", DefaultValue = 75)]
        public int ROC7s { get; set; }
        [Parameter("ROC 8", Group = "ROCs Smoothings", DefaultValue = 100)]
        public int ROC8s { get; set; }
        [Parameter("ROC 9", Group = "ROCs Smoothings", DefaultValue = 130)]
        public int ROC9s { get; set; }
        [Parameter("ROC 10", Group = "ROCs Smoothings", DefaultValue = 130)]
        public int ROC10s { get; set; }
        [Parameter("ROC 11", Group = "ROCs Smoothings", DefaultValue = 130)]
        public int ROC11s { get; set; }
        [Parameter("ROC 12", Group = "ROCs Smoothings", DefaultValue = 195)]
        public int ROC12s { get; set; }
        [Parameter("Type", Group = "ROCs Smoothings", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType SmoothingType { get; set; }

        private PriceROC Roc1, Roc2, Roc3, Roc4, Roc5, Roc6, Roc7, Roc8, Roc9, Roc10,
        Roc11, Roc12;

        private MovingAverage Ma1, Ma2, Ma3, Ma4, Ma5, Ma6, Ma7, Ma8, Ma9, Ma10,
        Ma11, Ma12;

        private MovingAverage Smooth, Sign;

        private IndicatorDataSeries Temp;

        [Output("Main", LineColor = "Cyan")]
        public IndicatorDataSeries Result { get; set; }
        [Output("Signal", LineColor = "Red")]
        public IndicatorDataSeries Signal { get; set; }

        protected override void Initialize()
        {
            IndicatorArea.DrawHorizontalLine("0", 0, Color.Gray);
            Temp = CreateDataSeries();

            Roc1 = Indicators.PriceROC(Source, ROC1);
            Roc2 = Indicators.PriceROC(Source, ROC2);
            Roc3 = Indicators.PriceROC(Source, ROC3);
            Roc4 = Indicators.PriceROC(Source, ROC4);
            Roc5 = Indicators.PriceROC(Source, ROC5);
            Roc6 = Indicators.PriceROC(Source, ROC6);
            Roc7 = Indicators.PriceROC(Source, ROC7);
            Roc8 = Indicators.PriceROC(Source, ROC8);
            Roc9 = Indicators.PriceROC(Source, ROC9);
            Roc10 = Indicators.PriceROC(Source, ROC10);
            Roc11 = Indicators.PriceROC(Source, ROC11);
            Roc12 = Indicators.PriceROC(Source, ROC12);

            Ma1 = Indicators.MovingAverage(Roc1.Result, ROC1s, SmoothingType);
            Ma2 = Indicators.MovingAverage(Roc2.Result, ROC2s, SmoothingType);
            Ma3 = Indicators.MovingAverage(Roc3.Result, ROC3s, SmoothingType);
            Ma4 = Indicators.MovingAverage(Roc4.Result, ROC4s, SmoothingType);
            Ma5 = Indicators.MovingAverage(Roc5.Result, ROC5s, SmoothingType);
            Ma6 = Indicators.MovingAverage(Roc6.Result, ROC6s, SmoothingType);
            Ma7 = Indicators.MovingAverage(Roc7.Result, ROC7s, SmoothingType);
            Ma8 = Indicators.MovingAverage(Roc8.Result, ROC8s, SmoothingType);
            Ma9 = Indicators.MovingAverage(Roc9.Result, ROC9s, SmoothingType);
            Ma10 = Indicators.MovingAverage(Roc10.Result, ROC10s, SmoothingType);
            Ma11 = Indicators.MovingAverage(Roc11.Result, ROC11s, SmoothingType);
            Ma12 = Indicators.MovingAverage(Roc12.Result, ROC12s, SmoothingType);

            Smooth = Indicators.MovingAverage(Temp, FinalSmoothingPeriod, FinalSmoothingType);
            Sign = Indicators.MovingAverage(Smooth.Result, SignalPeriod, SignalType);
        }

        public override void Calculate(int index)
        {
            Temp[index] = Ma1.Result[index] * ROC1m + Ma2.Result[index] * ROC2m + Ma3.Result[index] * ROC3m + Ma4.Result[index] * ROC4m + Ma5.Result[index] * ROC5m + Ma6.Result[index] * ROC6m + Ma7.Result[index] * ROC7m + Ma8.Result[index] * ROC8m + Ma9.Result[index] * ROC9m + Ma10.Result[index] * ROC10m + Ma11.Result[index] * ROC11m + Ma12.Result[index] * ROC12m;
            Result[index] = Smooth.Result[index];
            Signal[index] = Sign.Result[index];
        }
    }
}


CY
cysecsbin.01

Joined on 10.11.2018 Blocked

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Pring's Special K.algo
  • Rating: 0
  • Installs: 1383
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
No comments found.