ZScore of Time Segmented Volume ind. free

by mfejza in category Oscilator at 23/01/2023
Description

ZScore of Time Segmented Volume indicator.

Get Time Segmented Volume indicator from here.

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 System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Indicators
{
    [Levels(-2.0, 0, 2.0)]
    [Indicator(IsOverlay = false, AutoRescale = false, AccessRights = AccessRights.None)]
    public class mZScore : Indicator
    {
        [Parameter("TSV Main Periods (13)", DefaultValue = 13)]
        public int inpPeriodsMain { get; set; }
        [Parameter("TSV Smooth Periods (7)", DefaultValue = 7)]
        public int inpPeriodsSmooth { get; set; }
        [Parameter("ZScore Periods (20)", DefaultValue = 20)]
        public int inpPeriodsZScore { get; set; }
        [Parameter("e Zscore Smooth Type (sma)", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType inpSmoothTypeZScore { get; set; }

        [Output("ZScore of Time Segmented Volume", LineColor = "Black", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outZScoreTSV { get; set; }
        
        private IndicatorDataSeries _delta, _segment;
        private MovingAverage _smooth;
        private StandardDeviation _stddev;


        protected override void Initialize()
        {
            _delta = CreateDataSeries();
            _segment = CreateDataSeries();
            _smooth = Indicators.MovingAverage(_segment, inpPeriodsZScore, inpSmoothTypeZScore);
            _stddev = Indicators.StandardDeviation(_segment, inpPeriodsZScore, inpSmoothTypeZScore);
        }

        public override void Calculate(int i)
        {
            _delta[i] = i>1 && Bars.ClosePrices[i] != Bars.ClosePrices[i-1] ? (Bars.ClosePrices[i] - Bars.ClosePrices[i-1]) * Bars.TickVolumes[i] : 0;
            _segment[i] = _delta.Sum(inpPeriodsMain);
            
            outZScoreTSV[i] = (_segment[i] - _smooth.Result[i]) / _stddev.Result[i];
        }
    }
}
Comments

bob.hess944 - January 25, 2023 @ 16:43

If you interested creative Lego creations or you collect own favorite Lego series, welcome to our Lego fan blog where you find latest news on Lego and more.

0