Description
Time Segmented Volume indicator
using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo
{
[Levels(0)]
[Indicator(IsOverlay = false, AutoRescale = false, AccessRights = AccessRights.None)]
public class mTimeSegmentedVolume : Indicator
{
[Parameter("Main Periods (13)", DefaultValue = 13)]
public int inpPeriodsMain { get; set; }
[Parameter("Smooth Periods (7)", DefaultValue = 7)]
public int inpPeriodsSmooth { get; set; }
[Output("Time Segmented Volume", LineColor = "Black", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
public IndicatorDataSeries outTSV { get; set; }
[Output("Time Segmented Volume Smooth", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
public IndicatorDataSeries outTSVsmooth { get; set; }
private IndicatorDataSeries _delta, _segment;
private MovingAverage _smoothma;
protected override void Initialize()
{
_delta = CreateDataSeries();
_segment = CreateDataSeries();
_smoothma = Indicators.MovingAverage(_segment, inpPeriodsSmooth, MovingAverageType.Simple);
}
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);
outTSV[i] = _segment[i];
outTSVsmooth[i] = _smoothma.Result[i];
}
}
}
mfejza
Joined on 25.01.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: mTimeSegmentedVolume.algo
- Rating: 5
- Installs: 666
- Modified: 22/01/2023 22:45
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.
Testando assim que tiver uma visão do indicador eu posto