Application of Ehler filter.afl
上传用户:shiqiang
上传日期:2009-06-12
资源大小:1289k
文件大小:1k
源码类别:

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    Application of Ehler filter
  4. //  Author/Uploader: goldfreaz 
  5. //  E-mail:          
  6. //  Date/Time Added: 2004-01-05 12:58:20
  7. //  Origin:          
  8. //  Keywords:        Ehler, FIR
  9. //  Level:           semi-advanced
  10. //  Flags:           indicator
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=320
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=320
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  Ehler filter using volume, momentum, rate of momentum for weighting.
  17. //
  18. //------------------------------------------------------------------------------
  19. // ehler filter based on acclerartion and speed
  20. // x - input
  21. // n - length of FIR
  22. // w - exponential weight of passed acceleration and speed 
  23. // f - weighting factor between acceleration and speed
  24. function Ehler1( x, V, n, w,f)
  25. {y=x;
  26. // acceleration + speed
  27. a = x-2*Ref(x,-1) + Ref(x,-2);
  28. s = f*(x-Ref(x,-1));
  29. q=AMA(V*(abs(a)+abs(s))/x,w);
  30. for( i = n-1; i < BarCount; i++ )
  31.  {
  32.    sy=0;sw=0;  
  33.  for (j=i-n+1; j<i+1; j++)
  34.   {sy = sy + q[j]*x[j]; 
  35.    sw = sw + q[j];
  36.   }
  37.  y[i]=sy/sw;
  38.  }
  39. return y;
  40. }
  41. w=Param("w",0.62,0.05,0.99,0.01);
  42. n=Param("n",8,1,42,1);
  43. f=Param("f",-0.3,-10,10,0.1);
  44. f=10^f;
  45. eh=Ehler1(C,V,n,w,f);
  46. Plot( Close, "Price", colorBlack, styleCandle );
  47. Plot( eh, "Ehler", colorBlack ); 
  48. Plot( MA(C,n), "MA", colorBlue );