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

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    SectorRSI
  4. //  Author/Uploader: goldfreaz 
  5. //  E-mail:          goldfreaz@thelion.com
  6. //  Date/Time Added: 2002-05-04 14:45:07
  7. //  Origin:          some stuff from Dimitris
  8. //  Keywords:        
  9. //  Level:           semi-advanced
  10. //  Flags:           system
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=187
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=187
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  Scan looks for stocks that have low RSI but turning up. Also, checks for
  17. //  composite to be in agreement. Run in the scan mode to establish composite.
  18. //  Then run in the backtest mode to find the winners. Paste all the winner
  19. //  from the results into their own separate group. Repeat the above on this
  20. //  elite group...model is set up for swing trading with a maximum hold of five
  21. //  days.
  22. //
  23. //------------------------------------------------------------------------------
  24. /* SectorRSI swing system
  25. ** goldfreaz - 5 May 2002
  26. */
  27. //myobj = CreateObject("MyAFLObject.Class1");
  28. PositionSize=4000;
  29. // Mean RSI
  30. Nrsi=14;//Optimize("Nrsi",11,14,19,1);
  31. rr=13;//Optimize("rr",15,12,15,1);
  32. ss=2;//Optimize("ss",3,2,3,1);
  33. Wfactor=1;//Optimize("Wf",0.8,0.8,1.3,0.1);
  34. slpTsiD=6;//Optimize("slpTsiD",6,5,8,1);
  35. MeanRSI = Foreign("~SUMRSI","O",1) / Foreign("~SUMRSI","V",1);
  36. rrsi=RSI(Nrsi);
  37. ROCmean=ROC(EMA(meanrsi,4),2);
  38. ROCrsi=ROC(EMA(rrsi,4),2);
  39. both=Wfactor*ROCmean+ROCrsi;
  40. Tsi=50 * ( EMA( EMA( both ,rr ) ,ss) / EMA( EMA( abs( both ),rr ), ss) );
  41. TsiBase=MA(Tsi,slpTsiD);
  42. Nx=1.77;//Optimize("Nx",5,1.6,1.9,.05);
  43. CurveTsi=Tsi-1.5*Ref(Tsi,-1)+.5*Ref(Tsi,-3);
  44. //CurveTsi=myobj.Curvature( Tsi, 3, Nx );
  45. //CurveTsi=myobj.ECurve( Tsi, Nx );
  46. wait=8;//Optimize("Wait",8,6,9,1);
  47. profitfactor=2.6;//Optimize("Pf",2.6,2.3,2.8,0.1);
  48. Patr=11;//Optimize("Patr",8,8,11,1);
  49. LossFactor=2.4;//Optimize("LF",1.5,1.2,2.8,0.2);
  50. PatrL=11;//Optimize("PatrL",11,10,13,1);
  51. CurveTsiCrit=3;//Optimize("CtsiC",5,2.7,3.2,.1);
  52. TsiCrit=-25;//Optimize("TsiC",-25,-26,-23,1);
  53. Buy = CurveTsi>CurveTsiCrit AND TsiBase<TsiCrit;
  54. ExRemSpan(Buy,wait);
  55. target=ProfitFactor*ATR(Patr);
  56. Loss=LossFactor*ATR(PatrL);
  57. ApplyStop(1,2,target,1);
  58. ApplyStop(2,2,Loss,0);
  59. Sell=Ref(Buy,-wait);
  60.   Filter=1;
  61.   Buy=ExRem(Buy,Sell);
  62.   Sell=ExRem(Sell,Buy);
  63. AddToComposite( Equity(1,-1), "~CompoEquity", "X",7);
  64. Rt=RSI( 9 );
  65. Rmean=IIf(Rt>=1 AND Rt<=99,Rt,0);
  66. AddToComposite(Rmean,"~SUMRSI","X",7);
  67. AddToComposite(1,"~SUMRSI","V",7);
  68. AddColumn(Buy,"Buy");
  69. AddColumn(Buy+target,"target");
  70. AddColumn(CurveTsi,"CTsi");
  71. MaxGraph=3;
  72. Graph0=MeanRSI; Graph0Color=14; Graph0Style=1;
  73. Graph1=rrsi; Graph1Color=5; Graph1Style=1;
  74. Graph2=Tsi; Graph2Color=2; Graph2Style=9;