Description
ZScore of Time Segmented Volume indicator.
Get Time Segmented Volume indicator from here.
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];
}
}
}
mfejza
Joined on 25.01.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: mZScoreTSV.algo
- Rating: 5
- Installs: 659
- Modified: 22/01/2023 23:00
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
No comments found.