2015 de paylaşılan filtreleri hatırlatalım, emeği geçenlere teşekkürler.
Math.Cos içeren her filtre candır 
Low Pass Filter
PHP Code:
/*
* SharpDevelop tarafından düzenlendi.
* Kullanıcı: Lyrklaunavan
* Tarih: 18.3.2015
* Zaman: 18:04
* Low Pass Filter
*/
var V = Sistem.GrafikVerileri ;
var C = Sistem.GrafikFiyatOku(V, "Kapanis") ;
var H = Sistem.GrafikFiyatOku(V, "Yuksek") ;
var L = Sistem.GrafikFiyatOku(V, "Dusuk") ;
var O = Sistem.GrafikFiyatOku(V, "Acilis") ;
int order = 3; // 2 ya da 3 olmali
int FilterPeriod = 35; //kafaniza gore degistirebilirsiniz
int PreSmooth = 5; //kafaniza gore degistirebilirsiniz
double a=0;
double b=0;
double c=0;
double pi = Math.Round(Math.PI,6);
double k1=0;
double k2=0;
double k3=0;
double k4=0;
double k5=0;
double k6=0;
var Smoother = Sistem.Liste(V.Count,0);
var Filter = Sistem.Liste(V.Count,0);
var sma1 = Sistem.MA(C, "Simple", PreSmooth);
var sma2 = Sistem.MA(Smoother, "Simple", FilterPeriod);
switch (order)
{
case 1:
break;
case 2:
a = Math.Round(Math.Exp(-Math.Sqrt(2) * pi / FilterPeriod),6);
b = Math.Round(2 * a * Math.Cos(Math.Sqrt(2) * pi / FilterPeriod),6);
k1=a*a; k2=(1 - b + a * a);
break;
case 3:
a = Math.Round(Math.Exp(-pi / FilterPeriod),6);
b = Math.Round(2 * a * Math.Cos(Math.Sqrt(3) * pi / FilterPeriod),6);
c = Math.Round(Math.Exp(-2 * pi / FilterPeriod),6);
k3=(b + c); k4=Math.Round((c + b * c),6);k5=Math.Round(c * c,6);k6=Math.Round(((1 - b + c) * (1 - c)),6);
break;
}
for (int i = 3; i < V.Count; i++)
{
Smoother[i]=sma1[i];
switch (order)
{
case 1: Filter[i]=sma2[i]; break;
case 2: Filter[i]=(float)(b*Filter[i-1] - k1*Filter[i-2] + k2*Smoother[i]); break;
case 3: Filter[i]=(float)(k3*Filter[i-1] - k4*Filter[i-2] + k5*Filter[i-3]+ k6*Smoother[i]); break;
}
}
Sistem.Cizgiler[0].Deger = Filter;
Unscented Kalman Filter
PHP Code:
int Period = 16;
int Phase = 0;
var Input = Sistem.GrafikFiyatSec("Kapanis");
double _beta;
double _expFactor;
double _lengthParam;
double _windowLength = 0.5 * (Period - 1);
double _permissivity = 0.01 * Phase + 1.5;
double _sigma;
int _longAvgWindow = 65;
int _stdDevLength = 20;
var _hInterval = new List<double>(new double[Input.Count]);
var _lInterval = new List<double>(new double[Input.Count]);
var _vx = new List<double>(new double[Input.Count]);
var _avgVx = new List<double>(new double[Input.Count]);
var _vxCum = new List<double>(new double[Input.Count]);
var bank0 = new List<double>(new double[Input.Count]);
var bank1 = new List<double>(new double[Input.Count]);
var bank2 = new List<double>(new double[Input.Count]);
var bank3 = new List<double>(new double[Input.Count]);
var bank4 = new List<double>(new double[Input.Count]);
var kalman = Sistem.Liste(0);
var SMA = Sistem.MA(Input, "Simple", 1);
for (int i = 1; i < Input.Count; i++)
{
_windowLength = 0.5 * (Period - 1);
_lengthParam = Math.Log(Math.Sqrt(_windowLength)) / Math.Log(2.0) + 2;
if (_lengthParam < 0) _lengthParam = 0;
_expFactor = _lengthParam - 2;
if (_expFactor < 0.5) _expFactor = 0.5;
_sigma = Math.Sqrt(_windowLength) * _lengthParam;
_beta = _sigma / (_sigma + 1);
var price = SMA[i];
if (i == 1 || i == 0)
{
_hInterval[i] = price;
_lInterval[i] = price;
}
double uDelta = price - _hInterval[i - 1];
double lDelta = price - _lInterval[i - 1];
double uAbs = Math.Abs(uDelta);
double lAbs = Math.Abs(lDelta);
if (uAbs > lAbs) _vx[i] = uAbs;
else if (uAbs < lAbs) _vx[i] = lAbs;
else if (uAbs == lAbs) _vx[i] = 0;
_vxCum[i] = (i < 10) ? 0 : _vxCum[i] = _vxCum[i - 1] + 0.1 * (_vx[i] - _vx[i - 10]);
double matop = 0.0;
for (int j = i - _longAvgWindow + 1; j <= i; j++)
matop += _vxCum[i];
var SMA2 = matop / _longAvgWindow;
_avgVx[i] = (i <= _longAvgWindow + 1) ? _avgVx[i - 1] + 2.0 * (_vxCum[i] - _avgVx[i - 1]) / (_longAvgWindow + 1) : SMA2;
double vxCoeff = 0d;
if (_avgVx[i] > 0) vxCoeff = _vx[i] / _avgVx[i];
if (vxCoeff > Math.Pow(_lengthParam, 1.0 / _expFactor)) vxCoeff = Math.Pow(_lengthParam, 1.0 / _expFactor);
if (vxCoeff < 1) vxCoeff = 1.0;
double vExp = Math.Pow(vxCoeff, _expFactor);
double kV = Math.Pow(_beta, Math.Sqrt(vExp));
double gamma = 0.45 * (Period - 1) / (0.45 * (Period - 1) + 2);
double alpha = Math.Pow(gamma, vExp);
_hInterval[i] = (uDelta > 0) ? price : _hInterval[i] = price - kV * uDelta;
_lInterval[i] = (lDelta < 0) ? price : _lInterval[i] = price - kV * lDelta;
if (i == 2)
{
bank4[i] = price;
bank0[i] = price;
bank2[i] = price;
}
else if (i > 2)
{
bank0[i] = (1 - alpha) * price + alpha * bank0[i - 1];
bank1[i] = (price - bank0[i]) * (1 - gamma) + gamma * bank1[i - 1];
bank2[i] = bank0[i] + _permissivity * bank1[i];
bank3[i] = (bank2[i] - bank4[i - 1]) * Math.Pow((1 - alpha), 2) + Math.Pow(alpha, 2) * bank3[i - 1];
bank4[i] = bank4[i - 1] + bank3[i];
}
kalman[i] = (float)bank4[i];
}
Sistem.Cizgiler[0].Deger =kalman;//panel1
3 Pole Super Smoother
PHP Code:
/*
* SharpDevelop tarafından düzenlendi.
* Kullanıcı: Lyrklaunavan
* Tarih: 25.3.2015
* Zaman: 21:36
* 3 Pole Super Smoother
* From 'Cybernetic Analysis for Stocks and Futures' by John Ehlers
*/
var V = Sistem.GrafikVerileri ;
var C = Sistem.GrafikFiyatOku(V, "Kapanis" ) ;
var H = Sistem.GrafikFiyatOku(V, "Yuksek" ) ;
var L = Sistem.GrafikFiyatOku(V, "Dusuk" ) ;
var O = Sistem.GrafikFiyatOku(V, "Acilis" ) ;
int period = 15;
float a1 = (float)Math.Exp(-3.14159/period);
float b1 = 2*a1*(float)Math.Cos(1.738*3.14159 /period);
float c1=a1*a1;
float coef2=b1+c1;
float coef3=-(c1+b1*c1);
float coef4=c1*c1;
float coef1=1-coef2-coef3-coef4;
var SS3Pole=Sistem.Liste(V.Count,0);
for(int j=4; j<V.Count; j++){
SS3Pole[j] = coef1*C[j]+coef2*SS3Pole[j-1]+coef3*SS3Pole[j-2]+coef4*SS3Pole[j-3];
}
Sistem.Cizgiler[0].Deger = SS3Pole;
2 Pole Super Smoother
PHP Code:
/*
* SharpDevelop tarafından düzenlendi.
* Kullanıcı: Lyrklaunavan
* Tarih: 25.3.2015
* Zaman: 21:36
* 2 Pole Super Smoother
* From 'Cybernetic Analysis for Stocks and Futures' by John Ehlers
*/
var V = Sistem.GrafikVerileri ;
var C = Sistem.GrafikFiyatOku(V, "Kapanis" ) ;
var H = Sistem.GrafikFiyatOku(V, "Yuksek" ) ;
var L = Sistem.GrafikFiyatOku(V, "Dusuk" ) ;
var O = Sistem.GrafikFiyatOku(V, "Acilis" ) ;
int period = 15;
float a1 = (float)Math.Exp(-1.414*3.14159/period);
float b1 = 2*a1*(float)Math.Cos(1.414*3.14159 /period);
float coef2=b1;
float coef3=-a1*a1;
float coef1=1-coef2-coef3;
var SS2Pole=Sistem.Liste(V.Count,0);
for(int j=3; j<V.Count; j++){
SS2Pole[j] = coef1*C[j]+coef2*SS2Pole[j-1]+coef3*SS2Pole[j-2];
}
Sistem.Cizgiler[0].Deger = SS2Pole;
3 Pole Butterworth filter
PHP Code:
/*
* SharpDevelop tarafından düzenlendi.
* Kullanıcı: Lyrklaunavan
* Tarih: 25.3.2015
* Zaman: 21:36
* 3 Pole Butterworth Filter
* From 'Cybernetic Analysis for Stocks and Futures' by John Ehlers
*/
var V = Sistem.GrafikVerileri ;
var C = Sistem.GrafikFiyatOku(V, "Kapanis" ) ;
var H = Sistem.GrafikFiyatOku(V, "Yuksek" ) ;
var L = Sistem.GrafikFiyatOku(V, "Dusuk" ) ;
var O = Sistem.GrafikFiyatOku(V, "Acilis" ) ;
int period = 15;
float a1 = (float)Math.Exp(-3.14159/period);
float b1 = 2*a1*(float)Math.Cos(1.738*3.14159 /period);
float c1=a1*a1;
float coef2=b1+c1;
float coef3=-(c1+b1*c1);
float coef4=c1*c1;
float coef1=(1-b1+c1)*(1-c1)/8;
var Butter3Pole=Sistem.Liste(V.Count,0);
for(int j=4; j<V.Count; j++){
Butter3Pole[j] = coef1*(C[j]+3*C[j-1]+3*C[j-2]+C[j-3])+coef2*Butter3Pole[j-1]+coef3*Butter3Pole[j-2]+coef4*Butter3Pole[j-3];
}
Sistem.Cizgiler[0].Deger = Butter3Pole;
2 Pole Butterworth Filter
PHP Code:
/*
* SharpDevelop tarafından düzenlendi.
* Kullanıcı: Lyrklaunavan
* Tarih: 25.3.2015
* Zaman: 21:36
* 2 Pole Butterworth Filter
* From 'Cybernetic Analysis for Stocks and Futures' by John Ehlers
*/
var V = Sistem.GrafikVerileri ;
var C = Sistem.GrafikFiyatOku(V, "Kapanis" ) ;
var H = Sistem.GrafikFiyatOku(V, "Yuksek" ) ;
var L = Sistem.GrafikFiyatOku(V, "Dusuk" ) ;
var O = Sistem.GrafikFiyatOku(V, "Acilis" ) ;
int period = 15;
float a1 = (float)Math.Exp(-1.414 * 3.14159 / period);
float b1 = 2 * a1 * (float)Math.Cos(1.414 * 3.14159 / period);
float coef2 = b1;
float coef3 = -a1 * a1;
float coef1 = (1 - b1 + a1 * a1) / 4;
var Butter=Sistem.Liste(V.Count,0);
for(int j=3; j<V.Count; j++){
Butter[j]=coef1 * (C[j] + 2 * C[j-1] + C[j-2]) + coef2 * Butter[j-1] + coef3 * Butter[j-2];
}
Sistem.Cizgiler[0].Deger = Butter;
Yer İmleri