Category Other  Published on 21/08/2024

Volume Pulse V3.3

Description

Special Announcement: A Major Project is Underway - cTrader Strategy Tester

We are excited to announce the launch of a groundbreaking project set to transform the way you trade: the cTrader Strategy Tester. This new tool is designed to provide traders with in-depth analysis of various strategies, allowing you to assess their performance, advantages, and disadvantages—all based on reliable and accurate data.

We are actively seeking developers, backtesters, and strategy creators to join this exciting journey. You have the opportunity to contribute to an innovative project that could revolutionize your trading experience.

Why Join the cTrader Strategy Tester Project?

  • Master Your Strategies: Test and compare different trading strategies before using them in real-market conditions.
  • Identify Pros and Cons: Gain detailed insights into the strengths and weaknesses of each strategy.
  • Optimize Your Decisions: Leverage accurate data to maximize your chances of success when making market decisions.

Get Involved Now!

If you're passionate about trading and want to develop, test, or create new trading strategies, join us now. Together, we will build a powerful tool that will give you the edge you need.

Be part of the future of trading with the cTrader Strategy Tester!

Click here (Telegram) to participate in this exceptional project or here (Github) to see all you need to know about this exceptional project



Introducing the VolumePulseV3.3 Indicator for cTrader

We are excited to present the VolumePulseV3.3 indicator, a tool designed to enhance your trading experience on the cTrader platform. This indicator is built to help traders analyze market movements by focusing on volume data, offering a clearer view of potential price changes. Below, we explain the main features and functionality of the indicator in a simple way.

What is the VolumePulseV3.3 Indicator?

The VolumePulseV3.3 indicator is a technical analysis tool that examines trading volumes to identify shifts in market trends. By comparing the volume of trades, the indicator helps you determine whether buying or selling pressure is increasing, providing insight into potential price movements.

Key Features

Calculation Sources:

  • The indicator can calculate data using either tick data (each individual trade) or bar data (grouped trades over a certain period).
  • Tick: Provides a very detailed view, considering every trade.
  • Bars: Averages out data over set timeframes, such as minutes, to give a broader perspective.

Calculation Types:

  • Delta Volume: Measures the difference in volume between buying and selling.
  • Delta Volume X Amplitude: Considers both the volume and the price movement, giving a more weighted analysis.

Smoothing Settings:

  • Period: You can set how many data points the indicator should consider for smoothing out the results, helping to reduce noise.
  • MA Type (Moving Average Type): Choose the type of moving average (e.g., Exponential) used to smooth the data.

Display Options:

  • The indicator allows for a variety of display options, showing results directly on your trading chart. You can customize how the results are visualized, including the thickness of candles, color schemes, and more.

How Does It Work?

When activated, the indicator processes data based on your chosen settings. It calculates the volume differences and smooths the data using the specified moving average. The results are then displayed on your chart, providing a visual representation of volume shifts in the market.

For instance, if you choose to display results as candles, the indicator will adjust the candle thickness based on the intensity of volume changes. Colors are used to distinguish between upward (buying) and downward (selling) pressure, giving you an instant understanding of market dynamics.

Why Use VolumePulseV3.3?

This indicator is particularly useful for traders who want to:

  • Gain deeper insights into market volume and price movements.
  • Identify potential turning points in the market by observing shifts in buying and selling pressure.
  • Customize their trading view to better fit their strategy and preferences.

The VolumePulseV3.3 is a powerful tool that adds another layer of analysis to your trading, making it easier to spot opportunities and risks.


We hope this introduction helps you understand the purpose and functionality of the VolumePulseV3.3 indicator. We encourage you to try it out on the cTrader platform and see how it can enhance your trading strategy!

 

Enjoy for Free =) 
Previous account here : https://ctrader.com/users/profile/70920
Contact telegram :  https://t.me/nimi012 


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 VolumePulse33 : Indicator
    {
        [Parameter("Calculation Sources", DefaultValue = EnumSourceBars.Bars, Group = "Base Setting")]
        public EnumSourceBars SourceBars { get; set; }
        public enum EnumSourceBars
        {
            Tick,
            Bars,
        }
        [Parameter("Timeframe Sources Bars", DefaultValue = "Minute", Group = "Base Setting")]
        public TimeFrame TimeframeSourceBars { get; set; }

        [Parameter("Calculation Type", DefaultValue = EnumCalculationType.Delta_Volume, Group = "Base Setting")]
        public EnumCalculationType CalculationType { get; set; }
        public enum EnumCalculationType
        {
            Delta_Volume,
            Delta_Volume_X_Amplitude
        }

        [Parameter("Period", DefaultValue = 13, Group = "Smooting Setting (Cumulative Delta Volume)")]
        public int Period { get; set; }
        [Parameter("Ma Type", DefaultValue = MovingAverageType.Exponential, Group = "Smooting Setting (Cumulative Delta Volume)")]
        public MovingAverageType MaType { get; set; }

        [Parameter("Draw Result On Chart", DefaultValue = EnumDrawResultOnChart.Candle_And_Volume_Result, Group = "Displaying the results")]
        public EnumDrawResultOnChart DrawResultOnChart { get; set; }
        public enum EnumDrawResultOnChart
        {
            None,
            Candle,
            Volume_Result,
            Max_Volume_Result,
            Candle_And_Volume_Result,
            Candle_And_Max_Volume_Result,
        }


        [Parameter("Thickness Candle", DefaultValue = 5, Group = "Displaying the results")]
        public int ThicknessCandle { get; set; }
        [Parameter("Distance Result", DefaultValue = 1, Group = "Displaying the results")]
        public double DistanceResult { get; set; }
        [Parameter("Intensity", DefaultValue = 30, Group = "Displaying the results")]
        public double Intensity { get; set; }
        [Parameter("Bull Candle", DefaultValue = "Lime", Group = "Displaying the results")]
        public Color ColorUp { get; set; }
        [Parameter("Bear Candle", DefaultValue = "Red", Group = "Displaying the results")]
        public Color ColorDown { get; set; }

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

        private MovingAverage smoothvolumPlus, smoothvolumMinus;
        private IndicatorDataSeries resvolumPlus, resolumMinus, normalizeBars;
        private AverageTrueRange atr;

        private Ticks tick;
        private Bars barsTick, barsSource;

        private double barCount;
        private int pct = 0;

        protected override void Initialize()
        {
            Print("Loading Source History : Statring");
            if (!IsBacktesting)
            {
                if (SourceBars == EnumSourceBars.Tick)
                {
                    tick = MarketData.GetTicks();
                    barsTick = MarketData.GetBars(TimeFrame.Tick);
                    while (barsTick.OpenTimes[0] > Bars.OpenTimes[0])
                        barsTick.LoadMoreHistory();
                }
                else if (SourceBars == EnumSourceBars.Bars)
                {
                    barsSource = MarketData.GetBars(TimeframeSourceBars);
                    while (barsSource.OpenTimes[0] > Bars.OpenTimes[0])
                        barsSource.LoadMoreHistory();
                }
            }
            Print("Loading Source History : Completed");

            resvolumPlus = CreateDataSeries();
            resolumMinus = CreateDataSeries();
            normalizeBars = CreateDataSeries();

            smoothvolumPlus = Indicators.MovingAverage(resvolumPlus, Period, MaType);
            smoothvolumMinus = Indicators.MovingAverage(resolumMinus, Period, MaType);
            atr = Indicators.AverageTrueRange(5, MovingAverageType.Simple);
            barCount = Bars.Count;

        }

        public override void Calculate(int index)
        {
            if (index < Math.Max(Period, 13))
                return;

            if (SourceBars == EnumSourceBars.Bars && Chart.TimeFrame == TimeframeSourceBars)
            {
                IndicatorArea.DrawStaticText("VolumeUptxt", "You cannot use Timeframe  (" + Chart.TimeFrame + ") and Calculation Sources (" + SourceBars + " " + TimeframeSourceBars + ") For the calculation of volume\nObserve a higher chart or change Calculation Sources.", VerticalAlignment.Center, HorizontalAlignment.Center, Color.Orange);
                return;
            }


            double deltaVolumePlus = 0.0;
            double deltaVolumeMin = 0.0;

            var CurrentTimeBar = Bars.OpenTimes[index];
            var PreviousTimeBar = Bars.OpenTimes[index - 1];

            if (SourceBars == EnumSourceBars.Tick)
            {
                int indexTick = GetIndexByDateTicks(Bars.OpenTimes.Last(0));
                int ticksvVolume = Chart.TimeFrame.Name.Contains("Renk") || Chart.TimeFrame.Name.Contains("Rang") ? (int)GetVolume(PreviousTimeBar, CurrentTimeBar) : (int)Bars.TickVolumes[index];
                //Print(ticksvVolume);
                for (int i = 0; i < ticksvVolume; i++)
                {
                    if (CalculationType == EnumCalculationType.Delta_Volume)
                    {
                        if (tick[indexTick - i].Ask > tick[indexTick - (i + 1)].Ask)
                            deltaVolumePlus++;
                        if (tick[indexTick - i].Ask < tick[indexTick - (i + 1)].Ask)
                            deltaVolumeMin++;
                        if (tick[indexTick - i].Bid > tick[indexTick - (i + 1)].Bid)
                            deltaVolumePlus++;
                        if (tick[indexTick - i].Bid < tick[indexTick - (i + 1)].Bid)
                            deltaVolumeMin++;
                    }
                    else
                    {
                        if (tick[indexTick - i].Ask > tick[indexTick - (i + 1)].Ask)
                            deltaVolumePlus += 1 * (tick[indexTick - i].Ask - tick[indexTick - (i + 1)].Ask);
                        if (tick[indexTick - i].Ask < tick[indexTick - (i + 1)].Ask)
                            deltaVolumeMin += 1 * tick[indexTick - (i + 1)].Ask - (tick[indexTick - i].Ask);
                        if (tick[indexTick - i].Bid > tick[indexTick - (i + 1)].Bid)
                            deltaVolumePlus += 1 * (tick[indexTick - i].Bid - tick[indexTick - (i + 1)].Bid);
                        if (tick[indexTick - i].Bid < tick[indexTick - (i + 1)].Bid)
                            deltaVolumeMin += 1 * (tick[indexTick - (i + 1)].Bid - tick[indexTick - i].Bid);
                    }
                }
                resvolumPlus[index] = deltaVolumePlus / ticksvVolume;
                resolumMinus[index] = deltaVolumeMin / ticksvVolume;
            }
            else
            {
                int indexBars = GetIndexByDateBars(Bars.OpenTimes.Last(0));
                normalizeBars[index] = GetNumberBars(PreviousTimeBar, CurrentTimeBar);
                double numberBars = Chart.TimeFrame.Name.Contains("Renk") || Chart.TimeFrame.Name.Contains("Rang") ? (int)GetVolume(PreviousTimeBar, CurrentTimeBar) : normalizeBars.Maximum(13); ;
                double weigted = 0.0;
                double resToSum = 0.0;
                //Print(numberBars);

                for (int i = 0; i < numberBars; i++)
                {
                    if (CalculationType == EnumCalculationType.Delta_Volume)
                    {
                        weigted += barsSource[indexBars - i].TickVolume;
                        resToSum = double.IsNaN(barsSource[indexBars - i].TickVolume) ? Bars[indexBars].TickVolume : barsSource[indexBars - i].TickVolume;

                        if (barsSource[indexBars - i].High > barsSource[indexBars - (i + 1)].High)
                            deltaVolumePlus += 1 * resToSum;
                        if (barsSource[indexBars - i].High < barsSource[indexBars - (i + 1)].High)
                            deltaVolumeMin += 1 * resToSum;
                        if (barsSource[indexBars - i].Low > barsSource[indexBars - (i + 1)].Low)
                            deltaVolumePlus += 1 * resToSum;
                        if (barsSource[indexBars - i].Low < barsSource[indexBars - (i + 1)].Low)
                            deltaVolumeMin += 1 * resToSum;
                    }
                    else
                    {
                        weigted += barsSource[indexBars - i].TickVolume * (barsSource[indexBars - i].High - barsSource[indexBars - i].Low);
                        resToSum = double.IsNaN(barsSource[indexBars - i].TickVolume * (barsSource[indexBars - i].High - barsSource[indexBars - i].Low)) ? 1 : barsSource[indexBars - i].TickVolume * (barsSource[indexBars - i].High - barsSource[indexBars - i].Low);

                        if (barsSource[indexBars - i].High > barsSource[indexBars - (i + 1)].High)
                            deltaVolumePlus += 1 * resToSum;
                        if (barsSource[indexBars - i].High < barsSource[indexBars - (i + 1)].High)
                            deltaVolumeMin += 1 * resToSum;
                        if (barsSource[indexBars - i].Low > barsSource[indexBars - (i + 1)].Low)
                            deltaVolumePlus += 1 * resToSum;
                        if (barsSource[indexBars - i].Low < barsSource[indexBars - (i + 1)].Low)
                            deltaVolumeMin += 1 * resToSum;
                    }
                }
                resvolumPlus[index] = deltaVolumePlus / weigted;
                resolumMinus[index] = deltaVolumeMin / weigted;
                // Print(Bars.OpenTimes.Last(0).ToLocalTime() + "   " + (barsSource[indexBars].High) + "  " + indexBars + "   numberBars    " + numberBars + "   " + resvolumPlus[index] + "     " + deltaVolumePlus + "        " + weigted);


            }

            ResultUp[index] = smoothvolumPlus.Result[index] / (smoothvolumMinus.Result[index] + smoothvolumPlus.Result[index]) * 100;
            ResultDown[index] = smoothvolumMinus.Result[index] / (smoothvolumMinus.Result[index] + smoothvolumPlus.Result[index]) * 100;

            if (DrawResultOnChart != EnumDrawResultOnChart.None)
            {
                double opacityUp = (Intensity * (ResultUp[index] - 50)) >= 50 ? (int)Math.Round(Intensity * (ResultUp[index] - 50)) : 50;
                double opacityDown = (Intensity * (ResultDown[index] - 50)) >= 50 ? (int)Math.Round(Intensity * (ResultDown[index] - 50)) : 50;

                Color colorUp = Color.FromArgb((int)Math.Round(opacityUp), ColorUp);
                Color colorDown = Color.FromArgb((int)Math.Round(opacityDown), ColorDown);

                DisplayCustomChart(index, colorUp, colorDown, ResultUp, ResultDown);

            }
            double loadPct = index / barCount * 100;

            if (pct < loadPct + 0.1 && pct < 105)
            {
                Print("Loading Calculation : " + loadPct.ToString("F0") + " %");
                pct += 10;
            }
        }

        private void TextVolume(string name, string removeName, string text, int x, double y, Color color)
        {
            if (Chart.FindObject(removeName) != null)
                Chart.RemoveObject(removeName);
            if (Chart.FindObject(name) != null)
                Chart.RemoveObject(name);

            var drawText = Chart.DrawText(name, text, x, y, color);
            drawText.HorizontalAlignment = HorizontalAlignment.Center;
            drawText.VerticalAlignment = VerticalAlignment.Bottom;

        }
        private void BarVolume(string name, string removeName, int x1, double y1, int x2, double y2, Color color, int thickness)
        {
            Chart.SetBarFillColor(x1, Color.Transparent);
            Chart.SetBarOutlineColor(x1, color);
            if (Chart.FindObject(name) != null)
                Chart.RemoveObject(name);
            if (Chart.FindObject(removeName) != null)
                Chart.RemoveObject(removeName);
            Chart.DrawTrendLine(name, x1, y1, x2, y2, color, thickness);
        }

        private void DisplayCustomChart(int index, Color colorUp, Color colorDown, DataSeries resultUp, DataSeries resultDown)
        {
            switch (DrawResultOnChart)
            {
                case (EnumDrawResultOnChart.Candle):
                    {

                        if (Bars.ClosePrices[index] > Bars.OpenPrices[index])
                        {
                            BarVolume("VolumeUp" + index, "VolumeDown" + index, index, (Bars.ClosePrices[index] - Bars.OpenPrices[index]) * (resultUp[index] / 100) + Bars.OpenPrices[index], index, Bars.OpenPrices[index], colorUp, ThicknessCandle);
                        }
                        else if (Bars.ClosePrices[index] < Bars.OpenPrices[index])
                        {
                            BarVolume("VolumeDown" + index, "VolumeUp" + index, index, Bars.OpenPrices[index] - (Bars.OpenPrices[index] - Bars.ClosePrices[index]) * (resultDown[index] / 100), index, Bars.OpenPrices[index], colorDown, ThicknessCandle);
                        }
                        else if (Bars.ClosePrices[index] == Bars.OpenPrices[index])
                        {
                            if (resultDown[index] < resultUp[index])
                                BarVolume("VolumeUp" + index, "VolumeDown" + index, index, (Bars.ClosePrices[index] - Bars.OpenPrices[index]) * (resultUp[index] / 100) + Bars.OpenPrices[index], index, Bars.OpenPrices[index], colorUp, ThicknessCandle);
                            else if (resultDown[index] > resultUp[index])
                                BarVolume("VolumeDown" + index, "VolumeUp" + index, index, Bars.OpenPrices[index] - (Bars.OpenPrices[index] - Bars.ClosePrices[index]) * (resultDown[index] / 100), index, Bars.OpenPrices[index], colorDown, ThicknessCandle);
                            else
                                BarVolume("VolumeUp" + index, "VolumeDown" + index, index, (Bars.ClosePrices[index] - Bars.OpenPrices[index]) * (resultUp[index] / 100) + Bars.OpenPrices[index], index, Bars.OpenPrices[index], Color.Gray, ThicknessCandle);
                        }
                    }
                    break;
                case (EnumDrawResultOnChart.Volume_Result):
                    {
                        if (Bars.ClosePrices[index] > Bars.OpenPrices[index])
                        {
                            TextVolume("VolumeUptxt" + index, "VolumeDowntxt" + index, (resultUp[index]).ToString("F0"), index, Bars.LowPrices[index] - (atr.Result[index] * DistanceResult), colorUp);
                        }
                        else if (Bars.ClosePrices[index] < Bars.OpenPrices[index])
                        {
                            TextVolume("VolumeDowntxt" + index, "VolumeUptxt" + index, (resultDown[index]).ToString("F0"), index, Bars.HighPrices[index] + (atr.Result[index] * DistanceResult), colorDown);
                        }
                        else if (Bars.ClosePrices[index] == Bars.OpenPrices[index])
                        {
                            if (resultDown[index] < resultUp[index])
                                TextVolume("VolumeUptxt" + index, "VolumeDowntxt" + index, (resultUp[index]).ToString("F0"), index, Bars.LowPrices[index] - (atr.Result[index] * DistanceResult), colorUp);
                            else if (resultDown[index] > resultUp[index])
                                TextVolume("VolumeDowntxt" + index, "VolumeUptxt" + index, (resultDown[index]).ToString("F0"), index, Bars.HighPrices[index] + (atr.Result[index] * DistanceResult), colorDown);
                            else
                                TextVolume("VolumeUptxt" + index, "VolumeDowntxt" + index, (resultUp[index]).ToString("F0"), index, Bars.LowPrices[index] - (atr.Result[index] * DistanceResult), colorUp);
                        }
                    }
                    break;
                case (EnumDrawResultOnChart.Max_Volume_Result):
                    {
                        if (resultDown[index] < resultUp[index])
                            TextVolume("VolumeUptxt" + index, "VolumeDowntxt" + index, (resultUp[index]).ToString("F0"), index, Bars.LowPrices[index] - (atr.Result[index] * DistanceResult), colorUp);
                        else if (resultDown[index] > resultUp[index])
                            TextVolume("VolumeDowntxt" + index, "VolumeUptxt" + index, (resultDown[index]).ToString("F0"), index, Bars.HighPrices[index] + (atr.Result[index] * DistanceResult), colorDown);
                        else
                            TextVolume("VolumeUptxt" + index, "VolumeDowntxt" + index, (resultUp[index]).ToString("F0"), index, Bars.LowPrices[index] - (atr.Result[index] * DistanceResult), Color.Gray);
                    }
                    break;
                case (EnumDrawResultOnChart.Candle_And_Volume_Result):
                    {
                        //Print(Bars.OpenTimes.Last(0).ToLocalTime() + "   " + ((Bars.ClosePrices[index] - Bars.OpenPrices[index]) * (resultUp[index] / 100) + Bars.OpenPrices[index]) + "  " + resultUp[index]);
                        if (Bars.ClosePrices[index] > Bars.OpenPrices[index])
                        {
                            TextVolume("VolumeUptxt" + index, "VolumeDowntxt" + index, (resultUp[index]).ToString("F0"), index, Bars.LowPrices[index] - (atr.Result[index] * DistanceResult), colorUp);
                            BarVolume("VolumeUp" + index, "VolumeDown" + index, index, (Bars.ClosePrices[index] - Bars.OpenPrices[index]) * (resultUp[index] / 100) + Bars.OpenPrices[index], index, Bars.OpenPrices[index], colorUp, ThicknessCandle);
                        }
                        else if (Bars.ClosePrices[index] < Bars.OpenPrices[index])
                        {
                            TextVolume("VolumeDowntxt" + index, "VolumeUptxt" + index, (resultDown[index]).ToString("F0"), index, Bars.HighPrices[index] + (atr.Result[index] * DistanceResult), colorDown);
                            BarVolume("VolumeDown" + index, "VolumeUp" + index, index, Bars.OpenPrices[index] - (Bars.OpenPrices[index] - Bars.ClosePrices[index]) * (resultDown[index] / 100), index, Bars.OpenPrices[index], colorDown, ThicknessCandle);
                        }
                        else if (Bars.ClosePrices[index] == Bars.OpenPrices[index])
                        {
                            if (resultDown[index] < resultUp[index])
                                TextVolume("VolumeUptxt" + index, "VolumeDowntxt" + index, (resultUp[index]).ToString("F0"), index, Bars.LowPrices[index] - (atr.Result[index] * DistanceResult), colorUp);
                            else if (resultDown[index] > resultUp[index])
                                TextVolume("VolumeDowntxt" + index, "VolumeUptxt" + index, (resultDown[index]).ToString("F0"), index, Bars.HighPrices[index] + (atr.Result[index] * DistanceResult), colorDown);
                            else
                                TextVolume("VolumeUptxt" + index, "VolumeDowntxt" + index, (resultUp[index]).ToString("F0"), index, Bars.LowPrices[index] - (atr.Result[index] * DistanceResult), Color.Gray);
                        }
                    }
                    break;
                case (EnumDrawResultOnChart.Candle_And_Max_Volume_Result):
                    {
                        if (resultDown[index] < resultUp[index])
                        {
                            BarVolume("VolumeUp" + index, "VolumeDown" + index, index, (Bars.ClosePrices[index] - Bars.OpenPrices[index]) * (resultUp[index] / 100) + Bars.OpenPrices[index], index, Bars.OpenPrices[index], colorUp, ThicknessCandle);
                            TextVolume("VolumeUptxt" + index, "VolumeDowntxt" + index, (resultUp[index]).ToString("F0"), index, Bars.LowPrices[index] - (atr.Result[index] * DistanceResult), colorUp);
                        }
                        else if (resultDown[index] > resultUp[index])
                        {
                            BarVolume("VolumeDown" + index, "VolumeUp" + index, index, Bars.OpenPrices[index] - (Bars.OpenPrices[index] - Bars.ClosePrices[index]) * (resultDown[index] / 100), index, Bars.OpenPrices[index], colorDown, ThicknessCandle);
                            TextVolume("VolumeDowntxt" + index, "VolumeUptxt" + index, (resultDown[index]).ToString("F0"), index, Bars.HighPrices[index] + (atr.Result[index] * DistanceResult), colorDown);
                        }
                        else
                        {
                            BarVolume("VolumeUp" + index, "VolumeDown" + index, index, (Bars.ClosePrices[index] - Bars.OpenPrices[index]) * (resultUp[index] / 100) + Bars.OpenPrices[index], index, Bars.OpenPrices[index], colorUp, ThicknessCandle);
                            TextVolume("VolumeUptxt" + index, "VolumeDowntxt" + index, (resultUp[index]).ToString("F0"), index, Bars.LowPrices[index] - (atr.Result[index] * DistanceResult), Color.Gray);
                        }
                    }
                    break;
            }
        }
        private int GetVolume(DateTime startTime, DateTime endTime)
        {
            int volume = 0;
            for (int tickIndex = 0; tickIndex < barsTick.Count; tickIndex++)
            {
                Bar tickBar = barsTick[tickIndex];

                if (tickBar.OpenTime < startTime || tickBar.OpenTime > endTime)
                {
                    if (tickBar.OpenTime > endTime)
                        break;
                    else
                        continue;
                }

                volume += 1;
            }

            return volume - 1;
        }
        private int GetNumberBars(DateTime startTime, DateTime endTime)
        {
            int bars = 0;
            for (int barsIndex = 0; barsIndex < barsSource.Count; barsIndex++)
            {
                Bar Bar = barsSource[barsIndex];

                if (Bar.OpenTime < startTime || Bar.OpenTime > endTime)
                {
                    if (Bar.OpenTime > endTime)
                        break;
                    else
                        continue;
                }

                bars += 1;
            }

            return bars - 1;
        }
        private int GetIndexByDateTicks(DateTime date)
        {
            var bars = MarketData.GetBars(TimeFrame.Tick);
            for (var i = bars.OpenTimes.Count - 1; i >= 0; i--)
            {
                if (bars.OpenTimes[i] <= date)
                {
                    return i;
                }
            }
            return -1;
        }

        private int GetIndexByDateBars(DateTime date)
        {
            var bars = MarketData.GetBars(TimeframeSourceBars);
            for (var i = bars.OpenTimes.Count - 1; i >= 0; i--)
            {
                if (bars.OpenTimes[i] <= date)
                {
                    return i;
                }
            }
            return -1;
        }
    }
}



YE
YesOrNot2

Joined on 17.05.2024

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Volume Pulse V3.3.algo
  • Rating: 5
  • Installs: 687
  • Modified: 21/08/2024 04:25
Comments
Log in to add a comment.
No comments found.