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
Joined on 25.01.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: mVWAPleadlag.algo
- Rating: 5
- Installs: 1061
- Modified: 10/10/2022 20:36
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
No comments found.