Category Oscilators  Published on 10/10/2022

VWAP Lead/Lag Indicator

Description

This indicator derived from VWAP leading and lagging components.

Long trades zone is defined when indicator is above the zero, Short trades zone is defined when indicator is below the zero.

 



using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
  
namespace cAlgo
{
    [Levels(0)]
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class mVWAPleadlag : Indicator
    {
        [Parameter("Periods (10)", DefaultValue = 10)]
        public int inpPeriods { get; set; }
  
        [Output("VWAP Lead/Lag", LineColor = "Black", LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outVWAPll { get; set; }

        private IndicatorDataSeries _vwapmul, _vwapclose, _mul, _lead, _lag;

  
        protected override void Initialize()
        {
            _vwapmul = CreateDataSeries();
            _vwapclose = CreateDataSeries();
            _mul = CreateDataSeries();
            _lead = CreateDataSeries();
            _lag = CreateDataSeries();
        }
  
        public override void Calculate(int i)
        {
            _mul[i] = Bars.ClosePrices[i] * Bars.ClosePrices[i];
            _vwapmul[i] = ((_mul.Sum(inpPeriods) * Bars.TickVolumes.Sum(inpPeriods)) / Bars.TickVolumes.Sum(inpPeriods)) / inpPeriods;
            _vwapclose[i] = ((Bars.ClosePrices.Sum(inpPeriods) * Bars.TickVolumes.Sum(inpPeriods)) / Bars.TickVolumes.Sum(inpPeriods)) / inpPeriods;
            _lead[i] = _vwapmul[i] / _vwapclose[i];
            _lag[i] = ((Bars.TypicalPrices.Sum(inpPeriods) * Bars.TickVolumes.Sum(inpPeriods)) / Bars.TickVolumes.Sum(inpPeriods)) / inpPeriods;
            
            outVWAPll[i] =  _lead[i] - _lag[i];
        }
    }
}

mfejza's avatar
mfejza

Joined on 25.01.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: mVWAPleadlag.algo
  • Rating: 5
  • Installs: 1019
  • Modified: 10/10/2022 20:36
Comments
Log in to add a comment.
No comments found.