RSI Divergence.afl
上传用户:shiqiang
上传日期:2009-06-12
资源大小:1289k
文件大小:2k
源码类别:

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    RSI Divergence
  4. //  Author/Uploader: Aron Pipa 
  5. //  E-mail:          
  6. //  Date/Time Added: 2006-03-19 22:00:02
  7. //  Origin:          
  8. //  Keywords:        
  9. //  Level:           medium
  10. //  Flags:           indicator
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=603
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=603
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  + scanner
  17. //
  18. //------------------------------------------------------------------------------
  19. /*---------------------------------------------------
  20. RSI Divergence
  21. Aron Pipa, March, 20 , 2006
  22. --------------------------------------------------------*/
  23. GraphXSpace=7;
  24. n=Param("% Reverse ",20,0,100,1);
  25. Buy=Sell=0;
  26. Var = Zig(RSI(), n); 
  27. t= Trough(RSI(), n, 1); 
  28. p= Peak(RSI(), n, 1); 
  29. x[0] =Var[0];
  30. price[0] = C[0];
  31. j=0;
  32. // bearish divergence
  33. for ( i=0; i<BarCount; i++) 
  34. {
  35. if(Var[i] == p[i])
  36. {
  37. j++;
  38. x[j] =Var[i];
  39. price[j] =C[i];
  40. if(x[j] <x[j-1] && price[j-1]< price[j]) 
  41. Sell[i] =1;
  42. }
  43. }
  44. // bullish divergence
  45. for ( i=0; i<BarCount; i++) 
  46. {
  47. if(Var[i] == t[i])
  48. {
  49. j++;
  50. x[j] =Var[i];
  51. price[j] =C[i];
  52. if(x[j] >x[j-1] && price[j]<price[j-1]) 
  53. Buy[i] =1;
  54. }
  55. }
  56. Plot(Var, "", 39); 
  57. PlotShapes ( IIf(Sell, shapeSmallCircle, shapeNone), colorRed, 0 , Var,0);
  58. PlotShapes( IIf(Buy, shapeSmallCircle, shapeNone),  colorBrightGreen, 0, Var,0);
  59. Title ="RSI Divergence" ;