Description
Often used for breakout trading to avoid fake breakouts. I couldn't find a VWMA for Ctrader so programmed one and am sharing it with the community. There is lots of information about this indicator on-line.
I'll try to respond to any comments. Also please share any good strategies you have using this indicator.
Donations welcome to:
BTC: 33gjtYhKVqFxmcbcko63WnwiVJvew3PauQ
ETH: 0xb54dF35117D94a43Ca25A3A348Ac20DF7F667F7b
LTC: M8YRuyH5USv2MvJyyF55U5ik1yMfm6TtMH
Cheers,
David Wilson-Parr
// -------------------------------------------------------------------------------------------------
//
// VWAP (Volume Weighted Moving Average) by Zaknafein Z
//
// Donations welcome to:
//
// BTC: 33gjtYhKVqFxmcbcko63WnwiVJvew3PauQ
// ETH: 0xb54dF35117D94a43Ca25A3A348Ac20DF7F667F7b
// LTC: M8YRuyH5USv2MvJyyF55U5ik1yMfm6TtMH
//
// v1.0 Inital version 04/05/18
// -------------------------------------------------------------------------------------------------
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AutoRescale = false, AccessRights = AccessRights.None)]
public class VWMA : Indicator
{
[Parameter("Source")]
public DataSeries Source { get; set; }
[Parameter(DefaultValue = 14)]
public int Periods { get; set; }
[Output("Main", Color = Colors.Aqua)]
public IndicatorDataSeries Result { get; set; }
public override void Calculate(int index)
{
double sum = 0.0;
double totvol = 0.0;
for (int i = index - Periods + 1; i <= index; i++)
{
sum += (Source[i] * MarketSeries.TickVolume[i]);
totvol += MarketSeries.TickVolume[i];
}
Result[index] = sum / totvol;
}
}
}
CT
ctid418503
Joined on 04.05.2018
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: VWMA.algo
- Rating: 5
- Installs: 4219
- Modified: 13/10/2021 09:54
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.
SA
Doesnt work. Gives the same result as a simple moving average
The volume weighted moving average (VWMA) is similar to the simple moving average; however, the VWMA places more emphasis on the volume recorded for each period. A period is defined as the time interval preferred by the respective trader (i.e, 5, 15, 30).
Therefore, if you place a 20-period simple moving average (SMA) on your chart and at the same time, a 20-period volume weighted moving average, you will see that they pretty much follow the same trajectory. However, on further review, you will notice the averages do not mirror each other exactly.
The reason for this discrepancy, as we previously stated is the VWMA emphasizes volume, while the SMA only factors the average of the closing price per period.
## Updated to sort out obsolete attributes ##
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AutoRescale = false, AccessRights = AccessRights.None)]
public class VWMA : Indicator
{
[Parameter("Source")]
public DataSeries Source { get; set; }
[Parameter(DefaultValue = 14)]
public int Periods { get; set; }
[Output("Main", LineColor = "Aqua")] // Updated
public IndicatorDataSeries Result { get; set; }
public override void Calculate(int index)
{
double sum = 0.0;
double totvol = 0.0;
for (int i = index - Periods + 1; i <= index; i++)
{
sum += (Source[i] * Bars.TickVolumes[i]); // Updated
totvol += Bars.TickVolumes[i]; // Updated
}
Result[index] = sum / totvol;
}
}
}