Relative Strength Multichart of up to 10 tickers.afl
上传用户:shiqiang
上传日期:2009-06-12
资源大小:1289k
文件大小:6k
源码类别:

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    Relative Strength Multichart of up to 10 tickers
  4. //  Author/Uploader: Frederick M Miller 
  5. //  E-mail:          
  6. //  Date/Time Added: 2004-02-09 23:46:38
  7. //  Origin:          Modified Frederick Miller 1/9/04 Modified K Close 8/2/02 support code from Thomas Zmuck/Anthony Faragasso
  8. //  Keywords:        
  9. //  Level:           medium
  10. //  Flags:           indicator
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=335
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=335
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  A modified indicator to function like the FastTrack total return charts
  17. //  normalizing up to 10 tickers for relative strength comparison. This
  18. //  indicator supports the date pole and date markers.
  19. //
  20. //  Tickers are loaded using Parameters or [CNTRL]R
  21. //
  22. //  Colors are selected for a black screen, but are easily modified in the
  23. //  code.
  24. //
  25. //------------------------------------------------------------------------------
  26. // Multi - Charts in the FastTrack Total Return Format
  27. // Normalized to left edge with right axis indicating %return of screen
  28. // Bracketed values indicate returns from left screen to pole OR
  29. // between Date markers if in place
  30. // Use <Cntr>R to set ticker symbols
  31. // left click to set pole, double left click to set marker 
  32. // Colors may be changed below:
  33. // Modified Frederick Miller (rick300m@eartlink.net) 2/9/04
  34. // Modified K Close 8/2/02  */
  35. /* support code from Thomas Zmuck/Anthony Faragasso  */
  36. Cl0=colorLightOrange;
  37. Cl1=colorPink;
  38. Cl2=colorOrange;
  39. Cl3=colorGreen ;
  40. Cl4=colorTurquoise;
  41. Cl5=colorLime;
  42. Cl6=colorBlueGrey;
  43. Cl7=colorYellow;
  44. Cl8=colorBrightGreen;
  45. Cl9=colorRed;
  46. //Set Variables
  47. barvisible = Status("barvisible");
  48. FVB = barvisible AND NOT Ref( barvisible, -1 );
  49. CVB = ValueWhen(  FVB,C) ;
  50. Leftbar=ValueWhen(Ref(barvisible,-1)==0 AND barvisible,DateTime() );
  51. Rightbar=LastValue(DateTime() );
  52. DateSpan = EndValue(BarIndex()) - BeginValue(BarIndex());
  53. Range = DateSpan ;
  54. StartDate = BeginValue(BarIndex());
  55. EndDate = EndValue(BarIndex());
  56. //Select Tickers
  57. Fn0=ParamStr( "Fund0", "$INDU");
  58. Fn1=ParamStr( "Fund1", "DJSEU");
  59. Fn2=ParamStr( "Fund2", "DJW-X");
  60. Fn3=ParamStr( "Fund3", "OTC-C");
  61. Fn4=ParamStr( "Fund4", "RUT-I");
  62. Fn5=ParamStr( "Fund5", "STBI-");
  63. Fn6=ParamStr( "Fund6", "PSE-X");
  64. Fn7=ParamStr( "Fund7", "");
  65. Fn8=ParamStr( "Fund8", "");
  66. Fn9=ParamStr( "Fund9", "");
  67. //Normalized to left edge
  68. Fa0=Prec(100*(Foreign(Fn0,"C")/ValueWhen(FVB,Foreign(Fn0,"C"))-1),2.2);
  69. Fa1=Prec(100*(Foreign(Fn1,"C")/ValueWhen(FVB,Foreign(Fn1,"C"))-1),2.2);
  70. Fa2=Prec(100*(Foreign(Fn2,"C")/ValueWhen(FVB,Foreign(Fn2,"C"))-1),2.2);
  71. Fa3=Prec(100*(Foreign(Fn3,"C")/ValueWhen(FVB,Foreign(Fn3,"C"))-1),2.2);
  72. Fa4=Prec(100*(Foreign(Fn4,"C")/ValueWhen(FVB,Foreign(Fn4,"C"))-1),2.2);
  73. Fa5=Prec(100*(Foreign(Fn5,"C")/ValueWhen(FVB,Foreign(Fn5,"C"))-1),2.2);
  74. Fa6=Prec(100*(Foreign(Fn6,"C")/ValueWhen(FVB,Foreign(Fn6,"C"))-1),2.2);
  75. Fa7=Prec(100*(Foreign(Fn7,"C")/ValueWhen(FVB,Foreign(Fn7,"C"))-1),2.2);
  76. Fa8=Prec(100*(Foreign(Fn8,"C")/ValueWhen(FVB,Foreign(Fn8,"C"))-1),2.2);
  77. Fa9=Prec(100*(Foreign(Fn9,"C")/ValueWhen(FVB,Foreign(Fn9,"C"))-1),2.2);
  78. //Plot Normalized Graphs
  79. Plot(Fa0,Fn0,Cl0,4);
  80. Plot(Fa1,Fn1,Cl1,4);
  81. Plot(Fa2,Fn2,Cl2,4);
  82. Plot(Fa3,Fn3,Cl3,4);
  83. Plot(Fa4,Fn4,Cl4,4);
  84. Plot(Fa5,Fn5,Cl5,4);
  85. Plot(Fa6,Fn6,Cl6,4);
  86. Plot(Fa7,Fn7,Cl7,4);
  87. Plot(Fa8,Fn8,Cl8,4);
  88. Plot(Fa9,Fn9,Cl9,4);
  89. Plot(0,"",colorDarkBlue,styleNoLine+styleDots);
  90. //Calculate % Change between markers
  91. Fv0=IIf(startdate==0,Fa0,100*(EndValue(Foreign(Fn0,"C")-BeginValue(Foreign(Fn0,"C"))))/BeginValue(Foreign(Fn0,"C")));
  92. Fv9=IIf(startdate==0,Fa9,100*(EndValue(Foreign(Fn9,"C")-BeginValue(Foreign(Fn9,"C"))))/BeginValue(Foreign(Fn9,"C")));
  93. Fv8=IIf(startdate==0,Fa8,100*(EndValue(Foreign(Fn8,"C")-BeginValue(Foreign(Fn8,"C"))))/BeginValue(Foreign(Fn8,"C")));
  94. Fv7=IIf(startdate==0,Fa7,100*(EndValue(Foreign(Fn7,"C")-BeginValue(Foreign(Fn7,"C"))))/BeginValue(Foreign(Fn7,"C")));
  95. Fv6=IIf(startdate==0,Fa6,100*(EndValue(Foreign(Fn6,"C")-BeginValue(Foreign(Fn6,"C"))))/BeginValue(Foreign(Fn6,"C")));
  96. Fv5=IIf(startdate==0,Fa5,100*(EndValue(Foreign(Fn5,"C")-BeginValue(Foreign(Fn5,"C"))))/BeginValue(Foreign(Fn5,"C")));
  97. Fv4=IIf(startdate==0,Fa4,100*(EndValue(Foreign(Fn4,"C")-BeginValue(Foreign(Fn4,"C"))))/BeginValue(Foreign(Fn4,"C")));
  98. Fv3=IIf(startdate==0,Fa3,100*(EndValue(Foreign(Fn3,"C")-BeginValue(Foreign(Fn3,"C"))))/BeginValue(Foreign(Fn3,"C")));
  99. Fv2=IIf(startdate==0,Fa2,100*(EndValue(Foreign(Fn2,"C")-BeginValue(Foreign(Fn2,"C"))))/BeginValue(Foreign(Fn2,"C")));
  100. Fv1=IIf(startdate==0,Fa1,100*(EndValue(Foreign(Fn1,"C")-BeginValue(Foreign(Fn1,"C"))))/BeginValue(Foreign(Fn1,"C")));
  101. Title=
  102. // Left Bar Date
  103. WriteIf(startdate==0, WriteVal(leftbar,formatDateTime),WriteVal(BeginValue(DateTime()),formatDateTime))+
  104. //Right Bar Date
  105. WriteIf(EndValue(DateTime() )==rightbar, "              Normalized Return Chart                  "+Date(),
  106. "                       "+WriteVal(Range,1)+" days                       "+WriteVal(EndValue(Month()),1.0) +"/" + WriteVal(EndValue(Day()),1.0) + "/20" + StrRight( WriteVal(EndValue(Year()),1.0),2))
  107. //List of Funds
  108. +" n"+EncodeColor(Cl0)+Fn0+ WriteIf(IsTrue(fa0)," ["+WriteVal(fv0,1.2)+ "]  ","") +EncodeColor(Cl1)+Fn1+WriteIf(IsTrue(fa1)," ["+WriteVal(fv1,1.2)+"]  ","")+EncodeColor(Cl2)+Fn2 + WriteIf(IsTrue(fa2)," ["+WriteVal(fv2,1.2)+"]  ","")+"n"+EncodeColor(Cl3)+fn3 + WriteIf(IsTrue(fa3)," ["+WriteVal(fv3,1.2)+"]  ","")+EncodeColor(Cl4)+Fn4 + WriteIf(IsTrue(fa4)," ["+WriteVal(fv4,1.2)+"]  ","")+EncodeColor(Cl5)+Fn5 + WriteIf(IsTrue(fa5)," ["+WriteVal(fv5,1.2)+"]  ","")+"n"+EncodeColor(Cl6)+Fn6 + WriteIf(IsTrue(fa6)," ["+WriteVal(fv6,1.2)+"]  ","")+EncodeColor(Cl7)+Fn7 + WriteIf(IsTrue(fa7)," ["+WriteVal(fv7,1.2)+"]  ","")+EncodeColor(Cl8)+Fn8 + WriteIf(IsTrue(fa8)," ["+WriteVal(fv8,1.2)+"]  ","")+EncodeColor(Cl9)+Fn9 + WriteIf(IsTrue(fa9)," ["+WriteVal(fv9,1.2)+"]  ","");