VWAP free

by lp_tp in category Trend at 09/02/2020
Description

// -------------------------------------------------------------------------------------------------

//

//    VWAP (Volume Weighted Average Price) = Cumulative(Typical Price x Volume) / Cumulative(Volume)

//    by Zaknafein Z

//

//    Donations welcome to:

//   

//    BTC: 33gjtYhKVqFxmcbcko63WnwiVJvew3PauQ

//    ETH: 0xb54dF35117D94a43Ca25A3A348Ac20DF7F667F7b

//    LTC: M8YRuyH5USv2MvJyyF55U5ik1yMfm6TtMH

//

//    v1.0 Inital version 04/05/18

// -------------------------------------------------------------------------------------------------

 

usingSystem;

usingcAlgo.API;

usingcAlgo.API.Internals;

usingcAlgo.API.Indicators;

usingcAlgo.Indicators;

 

namespacecAlgo

{

    [Indicator(IsOverlay = true, TimeZone = TimeZones.EasternStandardTime, AutoRescale = false, AccessRights = AccessRights.None)]

    publicclassVWAP : Indicator

    {

        [Parameter(DefaultValue = 0)]

        publicintPeriods { get; set; }

 

        [Parameter("One day only?", DefaultValue = false)]

        publicboolOdo { get; set; }

 

        [Output("Main", Color = Colors.DarkOrchid)]

        publicIndicatorDataSeries Result { get; set; }

 

        publicoverridevoidCalculate(intindex)

        {

            intii = index;

            doubleCumTypPrice = 0;

            doubleCumVol = 0;

 

            if(Periods == 0)

            {

                while(MarketSeries.OpenTime[ii] >= (Odo == false? MarketSeries.OpenTime[ii].Date : DateTime.Now.Date) && ii != 0)

                {

                    CumTypPrice += MarketSeries.Typical[ii] * MarketSeries.TickVolume[ii];

                    CumVol += MarketSeries.TickVolume[ii];

                    ii--;

                    if(MarketSeries.OpenTime[ii].Hour == 0 && MarketSeries.OpenTime[ii].Minute == 0)

                        break;

                }

            }

            else

            {

                for(; ii >= MarketSeries.OpenTime.Count - Periods; ii--)

                {

                    CumTypPrice += MarketSeries.Typical[ii] * MarketSeries.TickVolume[ii];

                    CumVol += MarketSeries.TickVolume[ii];

                }

            }

 

            Result[index] = CumTypPrice / CumVol;

 

        }

 

        protectedoverridevoidInitialize()

        {

            Print("VWAP indicator started...");

        }

    }

}

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 cAlgo.API;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class Blank : Indicator
    {
        protected override void Initialize()
        {
            ChartObjects.DrawText("AlgoDeveloper", "Please download this indicator from AlgoDeveloper.com", StaticPosition.Center, Colors.Red);
        }

        public override void Calculate(int index)
        {
        }
    }
}
Comments
0