Category Oscilators  Published on 16/06/2021

Klinger Volume Oscillator

Description

The Klinger oscillator was developed by Stephen Klinger to determine the long-term trend of money flow while remaining sensitive enough to detect short-term fluctuations. The indicator compares the volume flowing through securities with the security's price movements and then converts the result into an oscillator.

 


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 KlingerVolumeOscillator : Indicator
    {
        [Parameter("Fast Length", DefaultValue = 34.0)]
        public int fastLength { get; set; }
        [Parameter("Slow Length", DefaultValue = 55.0)]
        public int slowLength { get; set; }
        [Parameter("KVO Type", DefaultValue = MovingAverageType.Exponential)]
        public MovingAverageType kvoType { get; set; }

        [Parameter("Signal Smooth Type", DefaultValue = MovingAverageType.Exponential)]
        public MovingAverageType signalType { get; set; }
        [Parameter("Signal Smooth Length", DefaultValue = 13.0)]
        public int signalLength { get; set; }




        [Output("KVO", Color = Colors.LightGreen)]
        public IndicatorDataSeries kvo { get; set; }
        [Output("Signal", Color = Colors.Red)]
        public IndicatorDataSeries signal { get; set; }

        private IndicatorDataSeries vf, mom, trend, dm, cm;
        private MovingAverage fastMa, slowMa;
        private MovingAverage signalMA;
        // private Bars.TickVolumes volume;


        protected override void Initialize()
        {
            vf = CreateDataSeries();
            mom = CreateDataSeries();
            trend = CreateDataSeries();
            dm = CreateDataSeries();
            cm = CreateDataSeries();
            fastMa = Indicators.MovingAverage(vf, fastLength, kvoType);
            slowMa = Indicators.MovingAverage(vf, slowLength, kvoType);
            signalMA = Indicators.MovingAverage(kvo, signalLength, signalType);



        }

        public override void Calculate(int index)
        {
            mom[index] = Bars.TypicalPrices[index] - Bars.TypicalPrices[index - 1];
            trend[index] = 0;

            if (double.IsNaN(trend[index - 1]))
            {
                trend[index] = 0;

            }
            else
            {
                trend[index] = mom[index] > 0 ? 1 : mom[index] < 0 ? -1 : trend[index - 1];

            }

            dm[index] = Bars.HighPrices[index] - Bars.LowPrices[index];

            cm[index] = 0;

            cm[index] = double.IsNaN(cm[index - 1]) ? 0 : (trend[index] == trend[index - 1] ? cm[index - 1] + dm[index] : dm[index] + dm[index - 1]);
            double volume = Bars.TickVolumes[index];
            cm[index] = double.IsNaN(cm[index - 1]) ? 0 : (trend[index] == trend[index - 1] ? cm[index - 1] + dm[index] : dm[index] + dm[index - 1]);
            vf[index] = cm[index] != 0 ? 100 * volume * trend[index] * Math.Abs(2 * dm[index] / cm[index] - 1) : 0;

            kvo[index] = fastMa.Result[index] - slowMa.Result[index];

            signal[index] = signalMA.Result[index];



        }



    }
}


KA
kaneida84

Joined on 25.04.2021

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Klinger Volume Oscillator.algo
  • Rating: 0
  • Installs: 1686
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
LU
lukcybella147 · 2 years ago

I am very happy to be here and read the information you share in the article, the information is very good and useful, I will continue to follow and learn more 2048 cupcakes  fnaf 2