Why is this? Is there a possible fix?
Many thanks.
protected override void Initialize ()
{
Add (new Line (Color.DarkGray, 0, "ZeroLine"));
Add (new Plot (Color.Orange, PlotStyle.Line, "SmoothedAdaptiveMomentum"));
CalculateOnBarClose = true;
Overlay = false;
PriceTypeSupported = true;
}
/// </summary>
protected override void OnStartUp()
{
_ht = HilbertTransform2 (Input, Alpha);
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate ()
{
double period = _ht.Period [0];
if (period >= CurrentBar)
return;
double value = Input [0] - Input [(int) Math.Floor (period)];
double a1 = Math.Exp (-Math.PI / Cutoff);
double b1 = 2 * a1 * Math.Cos (1.738 * Math.PI / Cutoff);
double c1 = a1 * a1;
double coeff2 = b1 + c1;
double coeff3 = -c1 * (1 + b1);
double coeff4 = c1 * c1;
double coeff1 = 1 - coeff2 - coeff3 - coeff4;
if (CurrentBar < 4)
Value.Set (value);
else
Value.Set (coeff1 * value + coeff2 * Value [1] + coeff3 * Value [2] + coeff4 * Value [3]);
}
Comment