Compare Sectors against Tickers.afl
上传用户:shiqiang
上传日期:2009-06-12
资源大小:1289k
文件大小:3k
源码类别:

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    Compare Sectors against Tickers
  4. //  Author/Uploader: goldfreaz 
  5. //  E-mail:          goldfreaz@thelion.com
  6. //  Date/Time Added: 2002-05-09 13:44:50
  7. //  Origin:          
  8. //  Keywords:        
  9. //  Level:           advanced
  10. //  Flags:           exploration
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=188
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=188
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  Compares relative strength, StochRSI, relative volume, and RSI. Good stocks
  17. //  must be assigned to the right sectors...garbage in / garbage out. Scan the
  18. //  enclosed AFL then set up the indicators that follow.
  19. //
  20. //------------------------------------------------------------------------------
  21. /* SectorRSI swing system
  22. ** goldfreaz - 5 May 2002
  23. */
  24. /* StochRSI  */
  25. Nrsi=14;
  26. Nstoch=17;
  27. Nslow=7;
  28. rrsi=RSI( Nrsi );
  29. Stochrsi=EMA((rrsi-LLV(rrsi,Nstoch))/(HHV(rrsi,Nstoch)-LLV(rrsi,Nstoch)),Nslow);
  30. /* Relative Volume  */
  31. RelVol=EMA(V,3)/ Ref(MA(V,40),-4);
  32. /* Rate of Change  */
  33. xp=0.1*(4.0*(O+C)+H+L);
  34. Chan=EMA(ROC(xp,1),2);
  35. /* RSI  */
  36. Rt=RSI( 14 );
  37. Rmean=IIf(Rt>0.1 AND Rt<99.9,Rt,0);
  38. /*MACD BULL-BEAR*/
  39. Mid=IIf(MarketID(1)=="NYSE" OR MarketID(1)=="Nasdaq",1,0);
  40. ob=Signal(11,23,7)<MACD(11,23);
  41. AddToComposite(IIf(Mid,Ob,0.0),"~macdbullbear","H",7);
  42. AddToComposite(IIf(Mid,NOT(ob),0.0),"~macdbullbear","L",7);
  43. /*  Market Total  */
  44. AddToComposite(IIf(Mid,StochRsi,0.0),"~market","O",7);
  45. AddToComposite(IIf(Mid,Rmean,0.0),"~market","H",7);
  46. AddToComposite(IIf(Mid,Relvol,0.0),"~market","L",7);
  47. AddToComposite(IIf(Mid,Chan,0.0),"~market","C",7);
  48. AddToComposite(IIf(Mid,1,0),"~market","V",7);
  49. sectorname="Healthcare";
  50. AddToComposite(IIf(SectorID(1)==sectorname,StochRsi,0),"~Drug","O",7);
  51. AddToComposite(IIf(SectorID(1)==sectorname,Rmean,0),"~Drug","H",7);
  52. AddToComposite(IIf(SectorID(1)==sectorname,RelVol,0),"~Drug","L",7);
  53. AddToComposite(IIf(SectorID(1)==sectorname,Chan,0),"~Drug","C",7);
  54. AddToComposite(IIf(SectorID(1)==sectorname,1,0),"~Drug","V",7);
  55. sectorname="Financial";
  56. AddToComposite(IIf(SectorID(1)==sectorname,StochRsi,0),"~Bank","O",7);
  57. AddToComposite(IIf(SectorID(1)==sectorname,Rmean,0),"~Bank","H",7);
  58. AddToComposite(IIf(SectorID(1)==sectorname,RelVol,0),"~Bank","L",7);
  59. AddToComposite(IIf(SectorID(1)==sectorname,Chan,0),"~Bank","C",7);
  60. AddToComposite(IIf(SectorID(1)==sectorname,1,0),"~Bank","V",7);
  61. sectorname="Technology";
  62. AddToComposite(IIf(SectorID(1)==sectorname,StochRsi,0),"~techy","O",7);
  63. AddToComposite(IIf(SectorID(1)==sectorname,Rmean,0),"~techy","H",7);
  64. AddToComposite(IIf(SectorID(1)==sectorname,RelVol,0),"~techy","L",7);
  65. AddToComposite(IIf(SectorID(1)==sectorname,Chan,0),"~techy","C",7);
  66. AddToComposite(IIf(SectorID(1)==sectorname,1,0),"~techy","V",7);
  67. sectorname="Basic Materials";
  68. AddToComposite(IIf(SectorID(1)==sectorname,StochRsi,0),"~raw","O",7);
  69. AddToComposite(IIf(SectorID(1)==sectorname,Rmean,0),"~raw","H",7);
  70. AddToComposite(IIf(SectorID(1)==sectorname,RelVol,0),"~raw","L",7);
  71. AddToComposite(IIf(SectorID(1)==sectorname,Chan,0),"~raw","C",7);
  72. AddToComposite(IIf(SectorID(1)==sectorname,1,0),"~raw","V",7);
  73. Buy=0;