Supporting VWAP free

by andurei in category Other at 23/08/2021
Description

This indicator is a dependency for TrendTrader6

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
´╗┐using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, AutoRescale = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class VWAPs : Indicator
    {
        [Parameter("VWAP", DefaultValue = true)]
        public bool vwap { get; set; }


        [Output("Main", Color = Colors.Gray, Thickness = 2, PlotType = PlotType.DiscontinuousLine)]
        public IndicatorDataSeries Result { get; set; }

        private TypicalPrice typ;
        public IndicatorDataSeries tpv;

        public double CTPV, CV;

        protected override void Initialize()
        {
            CTPV = 0;
            CV = 0;
            typ = Indicators.TypicalPrice();
            tpv = CreateDataSeries();
        }

        public override void Calculate(int index)
        {
            tpv[index] = typ.Result[index] * MarketSeries.TickVolume[index];
            CTPV = 0;
            CV = 0;

            int per = 3;

            if (vwap)
            {
                int day = MarketSeries.OpenTime[index].Day;
                while (MarketSeries.OpenTime[index - per].Day == day)
                {
                    per++;
                    CTPV += tpv[index - per];
                    CV += MarketSeries.TickVolume[index - per];
                }
            }



            Result[index] = CTPV / CV;
        }
    }
}
Comments
0