Description
Some smoothing options, can apply on top of any series.
SourceType:
- HL2: (High + Low) / 2
- HLC3: (High + Low + Close) / 3
- Close
- Custom: selectable source.
CustomSource: the source to be used if SourceType is Custom.
SmoothFactor: factor to be used for selected SmoothType. For example, if SmoothType is WMA, SmoothFactor == 3 means WMA for 3 periods.
SmoothType: WMA, EMA, SMA, TwoPoles, Inst, Lague, None.
- WMA, EMA, SMA: Conventions Weighted/Exponetial/Simple Moving Average.
- TwoPoles: Ehlers 2 Poles smoother (see Ehlers book). SmoothFactor will be the CutOff period, e.g. if CutOff == 10, those with frequency equivalent to < 10 bars will be depressed.
- Inst: The famous Ehlers Instantaneous Trendline filter, which he claimed no lag in his book. Note the setting for SmoothFactor is using Period, not the alpha. Alpha = 2.0 / (period + 1). So a period 28 would equivalent to alpha 0.07.
- Lague: Laguerre filter (see Ehlers book). SmoothFactor is the Gamma for Laguerre filter [0 - 0.99].
The chart below shows the Inst smoother (period = 28), vs SMA (20). Note that the Inst line is still faster than the SMA event it uses data from 28 periods.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using LittleTrader;
using LittleTrader.Ehlers;
using LittleTrader.Extensions;
namespace cAlgo
{
[Indicator(AccessRights = AccessRights.None, IsOverlay = true)]
public class LT_Ind_EhlersSmoother : Indicator
{
[Parameter(DefaultValue = SourceTypes.HLC3)]
public SourceTypes SourceType { get; set; }
[Parameter()]
public DataSeries CustomSource { get; set; }
[Parameter("SmoothType", DefaultValue = SmoothTypes.TwoPoles)]
public SmoothTypes SmoothType { get; set; }
[Parameter("SmoothFactor", DefaultValue = 10.0)]
public double SmoothFactor { get; set; }
[Output("Smooth", LineColor = "Purple")]
public IndicatorDataSeries Smooth { get; set; }
EhlersSmoother _smooth;
protected override void Initialize()
{
var u = new IndUtils() { Bars = Bars, SourceType = SourceType, CustomSource = CustomSource };
_smooth = new EhlersSmoother(u.GetSource(), Smooth, SmoothFactor, SmoothType, CreateDataSeries);
}
public override void Calculate(int index)
{
_smooth.Calculate(index);
}
}
}
dhnhuy
Joined on 03.04.2023
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: LT_Ind_EhlersSmoother.algo
- Rating: 0
- Installs: 541
- Modified: 03/04/2023 07:08
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.