Category Other  Published on 10/12/2023

Dom x Big Volume

Description

Comparaison of Buy/Sell Big volume Entry.

Have fun, and for any collaboration, contact me !!!

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
{
    [Indicator(AccessRights = AccessRights.None)]
    public class xDomBigVolume : Indicator
    {

        [Output("Ask Entries", LineColor = "Lime", PlotType = PlotType.Points, Thickness = 5)]
        public IndicatorDataSeries AskResultRes { get; set; }
        [Output("Bid Entries", LineColor = "Red", PlotType = PlotType.Points, Thickness = 5)]
        public IndicatorDataSeries BidResultRes { get; set; }

        [Output("Ask >", LineColor = "Lime", PlotType = PlotType.Points, Thickness = 5)]
        public IndicatorDataSeries AskPlus { get; set; }
        [Output("Bid >", LineColor = "Red", PlotType = PlotType.Points, Thickness = 5)]
        public IndicatorDataSeries BidPlus { get; set; }



        private MarketDepth _marketDepth;

        private int askVolumCount = 0;
        private int bidVolumCount = 0;

        public override void Calculate(int index)
        {
        }
        protected override void Initialize()
        {
            //  Get Market Depth
            _marketDepth = MarketData.GetMarketDepth(SymbolName);
            // subscribe to event Updated
            _marketDepth.Updated += MarketDepthUpdated;
            Bars.BarOpened += Bars_BarOpened; ;
        }
        private void Bars_BarOpened(BarOpenedEventArgs obj)
        {
            askVolumCount = 0;
            bidVolumCount = 0;
        }
        void MarketDepthUpdated()
        {

            if (Chart.FindAllObjects(ChartObjectType.HorizontalLine) != null)
                Chart.RemoveAllObjects();

            var index = Bars.ClosePrices.Count - 1;

            var askVolume = 0;
            var bidVolume = 0;

            foreach (var entry in _marketDepth.AskEntries)
            {
                double dVolume = Math.Round(entry.VolumeInUnits / 1000000.0, 2);
                double entryPrice = entry.Price;
                Chart.DrawTrendLine("askNumber" + entryPrice, Bars.OpenTimes.Last(0) + (Bars.OpenTimes.Last(0) - Bars.OpenTimes.Last(((int)dVolume < 1 ? 1 : (int)dVolume) + 1)), entryPrice, Bars.OpenTimes.Last(0) + (Bars.OpenTimes.Last(0) - Bars.OpenTimes.Last(1)), entryPrice, Color.Lime, 5);

                if (askVolume < dVolume)
                    askVolume = (int)dVolume;
            }

            foreach (var entry in _marketDepth.BidEntries)
            {
                double dVolume = Math.Round(entry.VolumeInUnits / 1000000.0, 2);
                double entryPrice = entry.Price;
                Chart.DrawTrendLine("bidNumber" + entryPrice, Bars.OpenTimes.Last(0) + (Bars.OpenTimes.Last(0) - Bars.OpenTimes.Last(((int)dVolume < 1 ? 1 : (int)dVolume) + 1)), entryPrice, Bars.OpenTimes.Last(0) + (Bars.OpenTimes.Last(0) - Bars.OpenTimes.Last(1)), entryPrice, Color.Red, 5);

                if (bidVolume < dVolume)
                    bidVolume = (int)dVolume;
            }
            askVolumCount += askVolume;
            bidVolumCount += bidVolume;

            AskResultRes[index] = askVolumCount;
            BidResultRes[index] = bidVolumCount;

            AskPlus[index] = AskResultRes[index] > BidResultRes[index] ? -5 : double.NaN;
            BidPlus[index] = AskResultRes[index] < BidResultRes[index] ? -5 : double.NaN;


        }
    }
}



YE
YesOrNot

Joined on 10.10.2022 Blocked

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: [x]Dom Big Volume.algo
  • Rating: 5
  • Installs: 502
  • Modified: 10/12/2023 20:33
Comments
Log in to add a comment.
VE
VEI5S6C4OUNT0 · 11 months ago

Very interesting here's something you may like…

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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, AutoRescale = false, AccessRights = AccessRights.None)]
    public class UpDownTick : Indicator
    {
        [Output("Up Volume", LineColor = "AAFFFF00", PlotType = PlotType.Histogram, Thickness = 3)]
        public IndicatorDataSeries UpVolume { get; set; }

        [Output("Down Volume", LineColor = "FFAA00FF", PlotType = PlotType.Histogram, Thickness = 1)]
        public IndicatorDataSeries DownVolume { get; set; }
        
        public override void Calculate(int index)
        
        {
            
            if (Bars.ClosePrices[index] >= Bars.OpenPrices[index])
            {
                UpVolume[index] = Bars.TickVolumes[index] ;
            }
            if (Bars.ClosePrices[index] <= Bars.OpenPrices[index])
            {
                DownVolume[index] = Bars.TickVolumes[index] ;
            }
        }
    }
}