Description
Volatility Channel by Larry Williams indicator
Conditions
Long: price > (top channel + bottom channel)/2
Short: price < (top channel + bottom channel)/2
Note, increase calculation periods, to increase projection (in bars)
using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class mVolatilityChannelLWilliams : Indicator
{
[Parameter("Periods (10)", DefaultValue = 10)]
public int inpPeriods { get; set; }
[Output("Volatility Channel Top", LineColor = "Green", PlotType = PlotType.Line, Thickness = 2)]
public IndicatorDataSeries outVolatilityChannelTop { get; set; }
[Output("Volatility Channel Bottom", LineColor = "Red", PlotType = PlotType.Line, Thickness = 2)]
public IndicatorDataSeries outVolatilityChannelBottom { get; set; }
private MovingAverage _pr;
private IndicatorDataSeries _traw, _braw, _top, _bottom;
protected override void Initialize()
{
_pr = Indicators.MovingAverage(Bars.TypicalPrices, 1, MovingAverageType.Simple);
_traw = CreateDataSeries();
_braw = CreateDataSeries();
_top = CreateDataSeries();
_bottom = CreateDataSeries();
}
public override void Calculate(int i)
{
_traw[i] = 2.0 * _pr.Result[i] - Bars.HighPrices[i];
_braw[i] = 2.0 * _pr.Result[i] - Bars.LowPrices[i];
_top[i] = i>inpPeriods ? Math.Max(_traw.Maximum(inpPeriods), _traw[i]) : Bars.HighPrices[i];
_bottom[i] = i>inpPeriods ? Math.Min(_braw.Minimum(inpPeriods), _braw[i]) : Bars.LowPrices[i];
outVolatilityChannelTop[i] = _top[i];
outVolatilityChannelBottom[i] = _bottom[i];
}
}
}
mfejza
Joined on 25.01.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: mVolatilityChannelLWilliams.algo
- Rating: 5
- Installs: 734
- Modified: 05/01/2023 21:55
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.