En el número de agosto Ehler de la revista Stocks and Commodities Ehler ha publicado un nuevo indicador que parece muy interesante, el Voss predictive Filter. Ya está en muchas otras plataformas. ¿Sería posible programarlo para ProRealTime?
Este es el código de esaylenguaje que da el autor
Inputs:
Period(20),
Predict(3);
Vars:
Order(0),
F1(0), G1(0), S1(0), Bandwidth(.25),
count(0),
SumC(0),
Filt(0),
Voss(0);
If CurrentBar = 1 Then Begin
Order = 3*Predict;
F1 = Cosine(360 / Period);
G1 = Cosine(Bandwidth*360 / Period);
S1 = 1 / G1 - SquareRoot( 1 / (G1*G1) - 1);
End;
//Band Limit the input data with a wide band BandPass Filter
Filt = .5*(1 - S1)*(Close - Close[2]) + F1*(1 + S1)*Filt[1] - S1*Filt[2];
If CurrentBar <= 5 Then Filt = 0;
//Compute Voss predictor
SumC = 0;
For count = 0 to Order - 1 Begin
SumC = SumC + ((count + 1) / Order)*Voss[Order - count];
End;
Voss = ((3 + Order) / 2)*Filt - SumC;
Plot1(Filt);
Plot2(Voss);
Y esta es la versión de tradingview
// A Peek Into the Future
// John F. Ehlers
// TASC Aug 2019
// Created by e2e4mfck for tradingview.com
//@version=4
title = "Voss Predictive Filter"
shorttitle = "VPF"
version = ""
study (title = title + version, shorttitle = "VPF", overlay = false)
// - - - - - Inputs - - - - - //
Source = input(close, type = input.source)
Period = input(20, type = input.integer)
Predict = input(3, type = input.integer)
Bandwidth = input(0.25, type = input.float)
// - - - - - Function - - - - - //
f_VossFilt (_period, _predict, _bandwidth, _source) =>
float _filt = 0, float _sumC = 0, float _voss = 0
_PI = 2 * asin(1)
_order = 3 * _predict
_f1 = cos(2 * _PI / _period)
_g1 = cos(_bandwidth * 2 * _PI / _period)
_s1 = 1 / _g1 - sqrt(1 / (_g1 * _g1) - 1)
_s2 = 1 + _s1
_s3 = 1 - _s1
_x1 = _source - _source[2]
_x2 = (3 + _order) / 2
for _i = 0 to (_order - 1)
_sumC := _sumC + ((_i + 1) / _order) * _voss[_order - _i]
if bar_index <= _order
_filt := 0
_voss := 0
else
_filt := 0.5 * _s3 * _x1 + _f1 * _s2 * _filt[1] - _s1 * _filt[2]
_voss := _x2 * _filt - _sumC
[_voss, _filt]
// - - - - - Declaration - - - - - //
[Voss, Filt] = f_VossFilt(Period, Predict, Bandwidth, Source)
// - - - - - Plot - - - - - //
plot(Filt, title = "Filter", style = plot.style_line, color = color.red, linewidth = 2)
plot(Voss, title = "Voss", style = plot.style_line, color = color.blue, linewidth = 2)
hline(0.0, title = "Zero", linestyle = hline.style_dashed, color = color.black, linewidth = 1)
Muchas gracias y saludos.