Description
This indicator is very similar to the on-balance volume indicator.
Here is how to use this indicator:
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];
}
}
}
}
CW
cW22Trader
Joined on 16.03.2021
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: TSV.algo
- Rating: 0
- Installs: 1932
- Modified: 13/10/2021 09:54
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.
Removed unused reference to "AdaptiveLaguerreMA".