Description
Ehlers Super Passband Filter Indicator
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Levels(0)]
[Cloud("outSPF", "outZone", FirstColor = "Green", SecondColor = "Red" , Opacity = 0.1 )]
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class mEhlersSuperPassbandFilter : Indicator
{
[Parameter("Period LP (40)", DefaultValue = 40)]
public int inpLPPeriod { get; set; }
[Parameter("Period HP (60)", DefaultValue = 60)]
public int inpHPPeriod { get; set; }
[Output("outSPF", LineColor = "Black", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
public IndicatorDataSeries outSPF { get; set; }
[Output("outRMBp", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
public IndicatorDataSeries outRMBp { get; set; }
[Output("outRMBn", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
public IndicatorDataSeries outRMBn { get; set; }
[Output("outZone", LineColor = "Transparent", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
public IndicatorDataSeries outZone { get; set; }
private IndicatorDataSeries _price, _rms, _pb;
private double a1, a2, rms;
protected override void Initialize()
{
_price = CreateDataSeries();
_rms = CreateDataSeries();
_pb = CreateDataSeries();
a1 = (double)(5.0 / (double)inpLPPeriod);
a2 = (double)(5.0 / (double)inpHPPeriod);
}
public override void Calculate(int i)
{
_price[i] = (Bars.HighPrices[i] + Bars.LowPrices[i]) / 2;
_pb[i] = (i > 3 ? (a1 - a2) * _price[i] + (a2 * (1 - a1) - a1 * (1 - a2)) * _price[i - 1] + ((1 - a1) + (1 - a2)) * _pb[i - 1] - (1 - a1) * (1 - a2) * _pb[i - 2] : (a1 - a2) * _price[i]);
rms = 0.0;
for (int j = 0; j <= 49; j++)
if (!double.IsNaN(_pb[i - j]))
rms += _pb[i - j] * _pb[i - j];
_rms[i] = Math.Sqrt(rms / 50.0);
outSPF[i] = _pb[i];
outRMBp[i] = _rms[i];
outRMBn[i] = -_rms[i];
outZone[i] = _pb[i];
if(_pb[i]>_rms[i])
outZone[i] = _rms[i];
if(_pb[i]<-_rms[i])
outZone[i] = -_rms[i];
}
}
}
mfejza
Joined on 25.01.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: mEhlersSuperPassbandFilter.algo
- Rating: 5
- Installs: 893
- Modified: 10/10/2022 21:10
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.