VWAP SMA delta indicator free

by mfejza in category Oscilator at 14/03/2023
Description

This custom indicator represent the difference between Continual VWAP and SMA in same bars period calculations.
There is a strategy to use the difference as indication of trade zones, and this indicator produse those trade zones; indicator positive values indicate trading Long, and negative values trading Short. In this strategy as close confirmation indicator is used SMA (simple moving average) to identify average momentum price position. In another words SMA Long confirmation is when price above the SMA, and via versa.
As additional help to identify zones into chart, bars are colored, based on zones.

VWAP Continual custom indicator you can find here

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
{
    [Levels(0)]
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class mVWAPvsSMA : Indicator
    {
        [Parameter("Periods (10)", DefaultValue = 10)]
        public int inpPeriods { get; set; }
        [Parameter("Show Bars Color (yes)", DefaultValue = true)]
        public bool inpShowBarsColors { get; set; }
 
        [Output("Delta of VWAPc vs SMA", LineColor = "Black", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outVWAPcSMA { get; set; }

        private MovingAverage _sma; 
        private IndicatorDataSeries _vwap, _result;

 
        protected override void Initialize()
        {
            _sma = Indicators.MovingAverage(Bars.ClosePrices, inpPeriods, MovingAverageType.Simple);
            _vwap = CreateDataSeries();
            _result = CreateDataSeries();
        }
 
        public override void Calculate(int i)
        {
            _vwap[i] = ((Bars.TypicalPrices.Sum(inpPeriods) * Bars.TickVolumes.Sum(inpPeriods)) / Bars.TickVolumes.Sum(inpPeriods)) / inpPeriods;
            _result[i] = _sma.Result[i] - _vwap[i];

            outVWAPcSMA[i] = _result[i];

            if(inpShowBarsColors == true)
            {
                if(Bars.OpenPrices[i] < Bars.ClosePrices[i])
                    Chart.SetBarColor(i, Color.LawnGreen);
                else
                    Chart.SetBarColor(i, Color.Orange);
                
                if(Bars.ClosePrices[i] > _sma.Result[i] && _result[i] > 0)
                    Chart.SetBarColor(i, Color.Green);
                if(Bars.ClosePrices[i] < _sma.Result[i] && _result[i] < 0)
                    Chart.SetBarColor(i, Color.Red);
            }
        }
    }
}
Comments

gmkenneyy - March 20, 2023 @ 22:12

Hello,

Thanks for uploading this interesting indicator

Something i saw on the 1st line of the OnCalculate event

((Bars.TypicalPrices.Sum(Periods) * Bars.TickVolumes.Sum(Periods)) / Bars.TickVolumes.Sum(Periods)) / Periods;

is the same as 

Bars.TypicalPrices.Sum(Periods) / Periods; 

0