Category Volatility  Published on 26/04/2024

Volume Pulse (Update ***)

Description

Volume Pulse is designed for the cAlgo platform and is used to analyze volume variations on a lower timeframe for financial markets. Here is a detailed description of how it works:

Configuration Settings

  • Lower Timeframe Volume Cumulation (TF): The user can configure this indicator to monitor tick volume across different timeframes. The "DefaultValue" is set to "Tick2", but the user can choose from the available timeframes on the platform.

Visual Outputs

  • Volume Delta Plus: This data series is displayed in lime green and shows the total volume of bullish price movements in the selected timeframe.
  • Volume Delta Min: Displayed in red, this series indicates the total volume of bearish price movements.
  • Histo Plus and Histo Min: These histograms display the net difference between bullish and bearish volumes. Histo Plus (green) shows the difference when the bullish volume exceeds the bearish volume, while Histo Min (red) shows the opposite.

Internal Operation

Initialization: The indicator starts by synchronizing the volume data from the lower timeframe with the main timeframe used for trading. If the indicator is not in backtesting mode, it loads more history to ensure that the data is complete.

Calculation of Volume Delta: With each new price tick in the main timeframe, the indicator identifies the corresponding index in the tick timeframe. It then tracks the ticks from the last main tick to the current tick to separately calculate bullish and bearish volumes.

  • Bullish Volume: If the tick's closing price is higher than its opening price, the volume of that tick is added to the total bullish volume.
  • Bearish Volume: If the tick's closing price is lower than its opening price, its volume is counted as bearish.

Output Updates: After calculating the bullish and bearish volumes for the current period, the indicator updates the data series to display them on the chart. It also calculates the values of the histograms by subtracting the volumes, thus providing an instant view of the dominant volume dynamics.

This indicator offers traders a granular and dynamic view of volume flows on volatile markets, enabling precise analysis of price movements in real time and helping to anticipate market reactions based on observed volume changes.

 

Update 26.04.2024 :
Line 71 → delete i++;
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
On telegram : https://t.me/nimi012 (direct messaging)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class VolumePulse : Indicator
    {
        [Parameter("Lower Timeframe Volume Cumulation", DefaultValue = "Tick2")]
        public TimeFrame TF { get; set; }

        [Output("Volume Delta Plus", LineColor = "Lime")]
        public IndicatorDataSeries VolumeDeltaPlus { get; set; }
        [Output("Volume Delta Min ", LineColor = "Red")]
        public IndicatorDataSeries VolumeDeltaMin { get; set; }

        [Output("Histo Plus", LineColor = "Lime", PlotType = PlotType.Histogram)]
        public IndicatorDataSeries HistoUp { get; set; }
        [Output("Histo Min ", LineColor = "Red", PlotType = PlotType.Histogram)]
        public IndicatorDataSeries HistoDown { get; set; }

        private Bars barsTick;
        private DateTime prevBars;

        protected override void Initialize()
        {
            barsTick = MarketData.GetBars(TF);
            if (!IsBacktesting)
            {
                while (barsTick.OpenTimes[0] > Bars.OpenTimes[0])
                    barsTick.LoadMoreHistory();
            }
            prevBars = Bars.OpenTimes.Last(0);
        }
        public override void Calculate(int index)
        {
            if (index == 0) return;

            var index1 = barsTick.OpenTimes.GetIndexByTime(Bars.OpenTimes[index]);
            if (Bars.OpenTimes.Last(0) != prevBars)
            {
                double deltaVolumePlus = 0.0;
                double deltaVolumeMin = 0.0;
                int nbBars = 0;
                DateTime BarsTick = barsTick.OpenTimes[index1];
                for (int i = 0; Bars.OpenTimes[index - 1] < BarsTick; i++)
                {
                    BarsTick = barsTick.OpenTimes[index1 - i];
                    nbBars++;
                }

                for (int i = 0; i < nbBars; i++)
                {
                    double prevClose = barsTick.OpenPrices[index1 - i];
                    double currentClose = barsTick.ClosePrices[index1 - i];
                    double volume = barsTick.TickVolumes[index1 - i];
                    if (currentClose > prevClose)
                    {
                        deltaVolumePlus += volume;
                    }
                    else if (currentClose < prevClose)
                    {
                        deltaVolumeMin += volume;
                    }
                }

                VolumeDeltaPlus[index - 1] = deltaVolumePlus;
                VolumeDeltaMin[index - 1] = deltaVolumeMin;

                HistoUp[index - 1] = VolumeDeltaPlus[index - 1] > VolumeDeltaMin[index - 1] ? deltaVolumePlus - deltaVolumeMin : double.NaN;
                HistoDown[index - 1] = VolumeDeltaPlus[index - 1] < VolumeDeltaMin[index - 1] ? deltaVolumeMin - deltaVolumePlus : double.NaN;

            }
            prevBars = Bars.OpenTimes.Last(0);
        }
    }
}




YE
YesOrNot

Joined on 10.10.2022 Blocked

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Volume Pulse.algo
  • Rating: 0
  • Installs: 119
Comments
Log in to add a comment.
No comments found.