Adding moving average to Tick Volume
            
                 19 Aug 2020, 18:39
            
                    
Hi guys
I am wanting to add the moving average indicator to my tick volume indicator which calculates the average tick volume price.
Is this possible? My code is below:
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class TickVolumeMM : Indicator
    {
        [Output("UpVolume", Color = Colors.Green, PlotType = PlotType.Histogram, Thickness = 1)]
        public IndicatorDataSeries UpVolume { get; set; }
        [Output("DownVolume", Color = Colors.Red, PlotType = PlotType.Histogram, Thickness = 1)]
        public IndicatorDataSeries DownVolume { get; set; }
        protected override void Initialize()
        {
            // Initialize and create nested indicators
        }
        public override void Calculate(int index)
        {
            UpVolume[index] = MarketSeries.TickVolume[index];
            if (UpVolume[index] < UpVolume[index - 1])
                DownVolume[index] = UpVolume[index];
            else
                DownVolume[index] = 0;
        }
    }
}
I would love some help on the code or if someone could send me in the right direction.
I look forward to hearing from you guys
Sam
Replies
                     PanagiotisCharalampous
                     20 Aug 2020, 08:06
                                    
Hi Sam,
See an example below
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class TickVolumeTheMinimalTrader : Indicator
    {
        [Output("UpVolume", LineColor = "Green", PlotType = PlotType.Histogram, Thickness = 4)]
        public IndicatorDataSeries UpVolume { get; set; }
        [Output("DownVolume", LineColor = "Red", PlotType = PlotType.Histogram, Thickness = 4)]
        public IndicatorDataSeries DownVolume { get; set; }
        [Output("MA", LineColor = "Blue", PlotType = PlotType.Line, Thickness = 4)]
        public IndicatorDataSeries MA { get; set; }
        [Parameter(DefaultValue = 10)]
        public int Periods { get; set; }
        private MovingAverage volumeMA;
        protected override void Initialize()
        {
            // Initialize and create nested indicators    
            volumeMA = Indicators.MovingAverage(Bars.TickVolumes, Periods, MovingAverageType.Simple);
        }
        public override void Calculate(int index)
        {
            UpVolume[index] = Bars.TickVolumes[index];
            if (UpVolume[index] < UpVolume[index - 1])
                DownVolume[index] = UpVolume[index];
            else
                DownVolume[index] = 0;
            MA[index] = volumeMA.Result[index];
        }
    }
}
Best Regards,
Panagiotis
@PanagiotisCharalampous
                     samuelbreezey
                     20 Aug 2020, 10:49
                                    
RE:
PanagiotisCharalampous said:
Hi Sam,
See an example below
using System; using cAlgo.API; using cAlgo.API.Indicators; namespace cAlgo.Indicators { [Indicator(IsOverlay = false, AccessRights = AccessRights.None)] public class TickVolumeTheMinimalTrader : Indicator { [Output("UpVolume", LineColor = "Green", PlotType = PlotType.Histogram, Thickness = 4)] public IndicatorDataSeries UpVolume { get; set; } [Output("DownVolume", LineColor = "Red", PlotType = PlotType.Histogram, Thickness = 4)] public IndicatorDataSeries DownVolume { get; set; } [Output("MA", LineColor = "Blue", PlotType = PlotType.Line, Thickness = 4)] public IndicatorDataSeries MA { get; set; } [Parameter(DefaultValue = 10)] public int Periods { get; set; } private MovingAverage volumeMA; protected override void Initialize() { // Initialize and create nested indicators volumeMA = Indicators.MovingAverage(Bars.TickVolumes, Periods, MovingAverageType.Simple); } public override void Calculate(int index) { UpVolume[index] = Bars.TickVolumes[index]; if (UpVolume[index] < UpVolume[index - 1]) DownVolume[index] = UpVolume[index]; else DownVolume[index] = 0; MA[index] = volumeMA.Result[index]; } } }Best Regards,
Panagiotis
Thank you Panagiotis,
Is there a way to show the indicator on the actual chart?
Sam
@samuelbreezey
                     ctid5083541
                     16 Mar 2023, 21:03
                                    
RE: RE:Is there a way to show the indicator on the actual chart?
samuelbreezey said:
PanagiotisCharalampous said:
Hi Sam,
See an example below
using System; using cAlgo.API; using cAlgo.API.Indicators; namespace cAlgo.Indicators { [Indicator(IsOverlay = false, AccessRights = AccessRights.None)] public class TickVolumeTheMinimalTrader : Indicator { [Output("UpVolume", LineColor = "Green", PlotType = PlotType.Histogram, Thickness = 4)] public IndicatorDataSeries UpVolume { get; set; } [Output("DownVolume", LineColor = "Red", PlotType = PlotType.Histogram, Thickness = 4)] public IndicatorDataSeries DownVolume { get; set; } [Output("MA", LineColor = "Blue", PlotType = PlotType.Line, Thickness = 4)] public IndicatorDataSeries MA { get; set; } [Parameter(DefaultValue = 10)] public int Periods { get; set; } private MovingAverage volumeMA; protected override void Initialize() { // Initialize and create nested indicators volumeMA = Indicators.MovingAverage(Bars.TickVolumes, Periods, MovingAverageType.Simple); } public override void Calculate(int index) { UpVolume[index] = Bars.TickVolumes[index]; if (UpVolume[index] < UpVolume[index - 1]) DownVolume[index] = UpVolume[index]; else DownVolume[index] = 0; MA[index] = volumeMA.Result[index]; } } }Best Regards,
Panagiotis
Thank you Panagiotis,
Is there a way to show the indicator on the actual chart?
Sam
It works if you have the indicator on the "Target Framework: .NET Framework 4.x".
@ctid5083541

samuelbreezey
20 Aug 2020, 00:57
RE:
samuelbreezey said:
Just need the calculation...
Have added the MA:
@samuelbreezey