Time Segmented Volume free

by cW22Trader in category Trend at 28/07/2021
Description

This indicator is very similar to the on-balance volume indicator.

Here is how to use this indicator:

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.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class TSV : Indicator
    {
        [Parameter("Length", DefaultValue = 13)]
        public int Length { get; set; }

        [Parameter("MA Type", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType MaType { get; set; }

        [Parameter("MA Period", DefaultValue = 7)]
        public int MaPeriod { get; set; }



        [Output("MA", PlotType = PlotType.Line, LineColor = "Yellow", Thickness = 2)]
        public IndicatorDataSeries MA { get; set; }

        [Output("Result", LineColor = "Gray", PlotType = PlotType.Histogram, Thickness = 3)]
        public IndicatorDataSeries Result { get; set; }


        private MovingAverage maTimeVolume;

        private IndicatorDataSeries timeVolume;


        protected override void Initialize()
        {
            timeVolume = CreateDataSeries();

            maTimeVolume = Indicators.MovingAverage(Result, MaPeriod, MaType);
        }


        public override void Calculate(int index)
        {
            var close = Bars.ClosePrices[index];
            var closePrev = Bars.ClosePrices[index - 1];
            var volume = Bars.TickVolumes[index];

            if (index > MaPeriod)
            {
                timeVolume[index] = close > closePrev ? volume * (close - closePrev) : (close < closePrev ? volume * (close - closePrev) : 0.0);

                Result[index] = timeVolume.Sum(Length);

                MA[index] = maTimeVolume.Result[index];
            }
        }
    }
}
Comments

cW22Trader - August 06, 2021 @ 01:08

Removed unused reference to "AdaptiveLaguerreMA".

0