前言:
目前姐妹们对“把一些算法封装到dll中的方法”大致比较重视,兄弟们都想要学习一些“把一些算法封装到dll中的方法”的相关资讯。那么小编也在网上搜集了一些对于“把一些算法封装到dll中的方法””的相关文章,希望各位老铁们能喜欢,你们快快来学习一下吧!约翰·埃勒斯(John Ehlers)利用数字信号处理方面的专业,探讨了价格与成交量之间的关联性,并尝试通过这些关系来预测市场动向。该滤波器基于航天模拟滤波器,旨在降低价格数据中的噪声。Ehlers 高通滤波器可消除周期长于特定值的波分量。
埃勒斯运用高通滤波对价格和成交量数据进行处理,以提取出关键的数据波长。他认为,通过这种方法得到的埃勒斯Ehlers循环,能够根据价格成交量图中的曲线运动——包括其曲率和旋转方向——来预测市场未来的看涨或看跌趋势。
我们日常使用的EMA函数或者MA函数均属于一阶数字低通滤波器,详细算法详见下图所示:
那么,在一个高通滤波器中,对离散信号的处理将明显优于低通滤波。
根据高通滤波的算法,我们可以对市场走势进行Highpass Filter。在广发金融工程此前发明的LLT算法就属于高通滤波算法的其中一种。
如果想要在通达信中使用该函数,就要利用C#语言创建通达信dll,以下是通达信高通滤波算法的源代码:
namespace NinjaTrader.NinjaScript.Indicators.AUN_Indi.Ehlers{ public class EhlersHighPassLowPassRoofingFilter : Indicator { private Series<double> hb; private int MINBAR = 5; private double a1, a2, c1, c2, c3; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"The HighPass-LowPass Roofing Filter: John Ehlers, Cycle Analytics For Traders, pg.78"; Name = "EhlersHighPassLowPassRoofingFilter"; Calculate = Calculate.OnBarClose; IsOverlay = false; DisplayInDataBox = true; DrawOnPricePanel = true; DrawHorizontalGridLines = true; DrawVerticalGridLines = true; PaintPriceMarkers = true; ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right; //Disable this property if your indicator requires custom values that cumulate with each new market data event. //See Help Guide for additional information. IsSuspendedWhileInactive = true; HPLength = 48; SSFLength = 10; ColorD = Brushes.Red; ColorU = Brushes.LimeGreen; AddPlot(Brushes.ForestGreen, "Rb"); } else if (State == State.Configure) { double twoPiPrd = 2 * Math.PI / HPLength; double alpha1 = (Math.Cos(twoPiPrd) + Math.Sin(twoPiPrd) - 1) / Math.Cos(twoPiPrd); double alpha2 = Math.Exp(-Math.Sqrt(2) * Math.PI / SSFLength); double beta = 2 * alpha2 * Math.Cos(Math.Sqrt(2) * Math.PI / SSFLength); c2 = beta; c3 = -Math.Pow(alpha2, 2); c1 = 1 - c2 - c3; a1 = 1 - alpha1 / 2; a2 = 1 - alpha1; } else if (State == State.DataLoaded) { hb = new Series<double>(this); } } protected override void OnBarUpdate() { if (CurrentBar <= MINBAR) return; hb[0] = a1 * (Close[0] - Close[1]) + a2 * hb[1]; Rb[0] = c1 * (hb[0] + hb[1]) / 2 + c2 * Rb[1] + c3 * Rb[2]; if (Rb[0] < 0) PlotBrushes[0][0] = ColorD; else if (Rb[0] > 0) PlotBrushes[0][0] = ColorU; } #region Properties [NinjaScriptProperty] [Range(1, int.MaxValue)] [Display(Name="HPLength", Order=1, GroupName="Parameters")] public int HPLength { get; set; } [NinjaScriptProperty] [Range(1, int.MaxValue)] [Display(Name="SSFLength", Order=2, GroupName="Parameters")] public int SSFLength { get; set; } [Browsable(false)] [XmlIgnore] public Series<double> Rb { get { return Values[0]; } } [NinjaScriptProperty] [XmlIgnore] [Display(Name="ColorD", Description="Color for bear", Order=2, GroupName="Parameters")] public Brush ColorD { get; set; } [Browsable(false)] public string ColorDSerializable { get { return Serialize.BrushToString(ColorD); } set { ColorD = Serialize.StringToBrush(value); } } [NinjaScriptProperty] [XmlIgnore] [Display(Name="ColorU", Description="Color for bool", Order=3, GroupName="Parameters")] public Brush ColorU { get; set; } [Browsable(false)] public string ColorUSerializable { get { return Serialize.BrushToString(ColorU); } set { ColorU = Serialize.StringToBrush(value); } } #endregion }}
本文所采用的正是巴特沃斯滤波器
源代码:
var UltimateSmoother (var *Data, int Length){ var f = (1.414*PI) / Length; var a1 = exp(-f); var c2 = 2*a1*cos(f); var c3 = -a1*a1; var c1 = (1+c2-c3)/4; vars US = series(*Data,4); return US[0] = (1-c1)*Data[0] + (2*c1-c2)*Data[1] - (c1+c3)*Data[2]+ c2*US[1] + c3*US[2];}
最后是通达信成果: