Description
Directional Volatility Effect indicator. The indicator displays two volatility effect zones; bullish (green shadow) and bearish (red shadow).
To find original version please click here
using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo
{
[Levels(0)]
[Cloud("DirectionalVolatility Bullish", "Trigger Up", FirstColor = "Green", SecondColor = "Transparent", Opacity = 0.1)]
[Cloud("DirectionalVolatility Bearish", "Trigger Down", FirstColor = "Red", SecondColor = "Transparent", Opacity = 0.1)]
[Indicator(IsOverlay = false, AutoRescale = false, AccessRights = AccessRights.None)]
public class mDirectionalVolatilityvEffect : Indicator
{
[Parameter("Periods (14)", DefaultValue = 14)]
public int inpPeriods { get; set; }
[Parameter("Deviation (3.0)", DefaultValue = 3.0)]
public double inpDeviation { get; set; }
[Parameter("Trigger in Procent (0.618)", DefaultValue = 0.618, MinValue = 0.1, MaxValue = 1.0)]
public double inpTriggerProcent { get; set; }
[Output("DirectionalVolatility Bullish", LineColor = "Green", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
public IndicatorDataSeries outDirectionalVolatilityBullish { get; set; }
[Output("DirectionalVolatility Bearish", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
public IndicatorDataSeries outDirectionalVolatilityBearish { get; set; }
[Output("Trigger Up", LineColor = "FF65FE66", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
public IndicatorDataSeries outTriggerUp { get; set; }
[Output("Trigger Down", LineColor = "FFFF999A", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
public IndicatorDataSeries outTriggerDn { get; set; }
private IndicatorDataSeries _pricelong, _priceshort, _limitup, _limitdn, _triggerup, _triggerdn;
private MovingAverage _malong, _mashort;
private StandardDeviation _stddevmalong, _stddevmashort;
protected override void Initialize()
{
_pricelong = CreateDataSeries();
_priceshort = CreateDataSeries();
_malong = Indicators.MovingAverage(_pricelong, inpPeriods, MovingAverageType.Exponential);
_mashort = Indicators.MovingAverage(_priceshort, inpPeriods, MovingAverageType.Exponential);
_stddevmalong = Indicators.StandardDeviation(_malong.Result, inpPeriods, MovingAverageType.Simple);
_stddevmashort = Indicators.StandardDeviation(_mashort.Result, inpPeriods, MovingAverageType.Simple);
_limitup = CreateDataSeries();
_limitdn = CreateDataSeries();
_triggerup = CreateDataSeries();
_triggerdn = CreateDataSeries();
}
public override void Calculate(int i)
{
_pricelong[i] = i>1 ? Bars.HighPrices[i] - Bars.ClosePrices[i-1] : Bars.HighPrices[i] - Bars.ClosePrices[i];
_priceshort[i] = i>1 ? Bars.ClosePrices[i-1] - Bars.LowPrices[i] : Bars.ClosePrices[i] - Bars.LowPrices[i];
_limitup[i] = (_malong.Result[i] + inpDeviation * _stddevmalong.Result[i]) / Symbol.TickSize;
_limitdn[i] = (_mashort.Result[i] + inpDeviation * _stddevmashort.Result[i]) / Symbol.TickSize;
_triggerup[i] = i>1 && _limitup[i] > _limitdn[i] ? Math.Max(_triggerup[i-1], (_limitup[i] + _limitdn[i]) / 2) : _limitup[i];
_triggerdn[i] = i>1 && _limitdn[i] > _limitup[i] ? Math.Max(_triggerdn[i-1], (_limitup[i] + _limitdn[i]) / 2) : _limitdn[i];
outDirectionalVolatilityBullish[i] = _limitup[i];
outDirectionalVolatilityBearish[i] = _limitdn[i];
outTriggerUp[i] = _triggerup[i];
outTriggerDn[i] = _triggerdn[i];
}
}
}
mfejza
Joined on 25.01.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: mDirectionalVolatilityvEffect.algo
- Rating: 5
- Installs: 716
- Modified: 25/01/2023 21:49
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.