Category Oscilators  Published on 24/03/2023

Volume Spread Pressure indicator

Description

Another sentiment confirmation indicator, using price spread and volume.


using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Levels(0)]
    [Indicator(AccessRights = AccessRights.None)]
    public class mVolumeSpreadPressure : Indicator
    {
        [Parameter("Volume Smooth Period (5)", DefaultValue = 5)]
        public int inpPeriodVolumeSmooth { get; set; }

        [Output("Volume Spread Pressure", LineColor = "Gray", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outVSP { get; set; }
        [Output("Strong Bullish", PlotType = PlotType.Histogram, LineColor = "ForestGreen", Thickness = 3)]
        public IndicatorDataSeries outStrongBullish { get; set; }
        [Output("Weak Bullish", PlotType = PlotType.Histogram, LineColor = "LawnGreen", Thickness = 3)]
        public IndicatorDataSeries outWeakBullish { get; set; }
        [Output("Strong Bearish", PlotType = PlotType.Histogram, LineColor = "Red", Thickness = 3)]
        public IndicatorDataSeries outStrongBearish { get; set; }
        [Output("Weak Bearish", PlotType = PlotType.Histogram, LineColor = "DarkSalmon", Thickness = 3)]
        public IndicatorDataSeries outWeakBearish { get; set; }
        
        private IndicatorDataSeries _delta;
        private MovingAverage _volavg;

        protected override void Initialize()
        {
            _delta = CreateDataSeries();
            _volavg = Indicators.MovingAverage(Bars.TickVolumes, inpPeriodVolumeSmooth, MovingAverageType.Simple);
        }

        public override void Calculate(int i)
        {
            _delta[i] = Bars.ClosePrices[i] - Bars.ClosePrices[i-1];
            outStrongBullish[i] = _delta[i] > 0 && _volavg.Result[i] > _volavg.Result[i-1] ? _delta[i] : 0;
            outWeakBullish[i] = _delta[i] > 0 && _volavg.Result[i] < _volavg.Result[i-1] ? _delta[i] : 0;
            outStrongBearish[i] = _delta[i] < 0 && _volavg.Result[i] > _volavg.Result[i-1] ? _delta[i] : 0;
            outWeakBearish[i] = _delta[i] < 0 && _volavg.Result[i] < _volavg.Result[i-1] ? _delta[i] : 0;
            
            outVSP[i] = _delta[i];
        }
    }
}

mfejza's avatar
mfejza

Joined on 25.01.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: mVolumeSpreadPressure.algo
  • Rating: 5
  • Installs: 790
  • Modified: 24/03/2023 12:00
Comments
Log in to add a comment.
No comments found.