The Mean RSIt (variations).afl
上传用户:shiqiang
上传日期:2009-06-12
资源大小:1289k
文件大小:7k
源码类别:

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    The Mean RSIt (variations)
  4. //  Author/Uploader: Dimitris Tsokakis 
  5. //  E-mail:          
  6. //  Date/Time Added: 2002-03-14 07:36:32
  7. //  Origin:          
  8. //  Keywords:        
  9. //  Level:           advanced
  10. //  Flags:           indicator
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=172
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=172
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  Variations of the Mean RSIt used in trading systems design.
  17. //
  18. //  Paste the formula in Automatic Analysis window, select All stocks (or a
  19. //  sector or a group or a watch list), all quotations and scan.
  20. //
  21. //  Select View->Refresh All and then Save.
  22. //
  23. //  Data should be clean and without missing dates (holes).
  24. //
  25. //  To check this, explore the database with the code
  26. //
  27. //  Filter=1;
  28. //
  29. //  Numcolumns=1;
  30. //
  31. //  Column0=Lastvalue(Cum(1));
  32. //
  33. //  for the n=1 last quotation.
  34. //
  35. //  If you do not miss some data, the numbers in the result list should be
  36. //  equal.
  37. //
  38. //------------------------------------------------------------------------------
  39. /*MEAN RSIT ~10 TO ~40*/
  40. Var3=MA(MACD(),10);
  41. Up=IIf(Var3>Ref(Var3,-1),abs(Var3-Ref(Var3,-1)),0);
  42. Dn=IIf(Var3<Ref(Var3,-1),abs(Var3-Ref(Var3,-1)),0);
  43. Ut=Wilders(Up,30);
  44. Dt=Wilders(Dn,30);
  45. R10SIt=100*(Ut/(Ut+Dt));
  46. R10SIt10=MA(R10SIt,10);
  47. AddToComposite(R10SIt10,"~10","V");
  48. Var6=MA(MACD(),15);
  49. Up=IIf(Var6>Ref(Var6,-1),abs(Var6-Ref(Var6,-1)),0);
  50. Dn=IIf(Var6<Ref(Var6,-1),abs(Var6-Ref(Var6,-1)),0);
  51. Ut=Wilders(Up,30);
  52. Dt=Wilders(Dn,30);
  53. R15SIt=100*(Ut/(Ut+Dt));
  54. R15SIt10=MA(R15SIt,10);
  55. AddToComposite(R15SIt10,"~15","V");
  56. Var4=MA(MACD(),20);
  57. Up=IIf(Var4>Ref(Var4,-1),abs(Var4-Ref(Var4,-1)),0);
  58. Dn=IIf(Var4<Ref(Var4,-1),abs(Var4-Ref(Var4,-1)),0);
  59. Ut=Wilders(Up,30);
  60. Dt=Wilders(Dn,30);
  61. R20SIt=100*(Ut/(Ut+Dt));
  62. R20SIt10=MA(R20SIt,10);
  63. AddToComposite(R20SIt10,"~20","V");
  64. Var1=MA(MACD(),25);
  65. Up=IIf(Var1>Ref(Var1,-1),abs(Var1-Ref(Var1,-1)),0);
  66. Dn=IIf(Var1<Ref(Var1,-1),abs(Var1-Ref(Var1,-1)),0);
  67. Ut=Wilders(Up,30);
  68. Dt=Wilders(Dn,30);
  69. R25SIt=100*(Ut/(Ut+Dt));
  70. R25SIt10=MA(R25SIt,10);
  71. AddToComposite(R25SIt10,"~25","V");
  72. Var2=MA(MACD(),30);
  73. Up=IIf(Var2>Ref(Var2,-1),abs(Var2-Ref(Var2,-1)),0);
  74. Dn=IIf(Var2<Ref(Var2,-1),abs(Var2-Ref(Var2,-1)),0);
  75. Ut=Wilders(Up,30);
  76. Dt=Wilders(Dn,30);
  77. R30SIt=100*(Ut/(Ut+Dt));
  78. R30SIt10=MA(R30SIt,10);
  79. AddToComposite(R30SIt10,"~30","V");
  80. Var5=MA(MACD(),35);
  81. Up=IIf(Var5>Ref(Var5,-1),abs(Var5-Ref(Var5,-1)),0);
  82. Dn=IIf(Var5<Ref(Var5,-1),abs(Var5-Ref(Var5,-1)),0);
  83. Ut=Wilders(Up,30);
  84. Dt=Wilders(Dn,30);
  85. R35SIt=100*(Ut/(Ut+Dt));
  86. R35SIt10=MA(R35SIt,10);
  87. AddToComposite(R35SIt10,"~35","V");
  88. Var7=MA(MACD(),40);
  89. Up=IIf(Var7>Ref(Var7,-1),abs(Var7-Ref(Var7,-1)),0);
  90. Dn=IIf(Var7<Ref(Var7,-1),abs(Var7-Ref(Var7,-1)),0);
  91. Ut=Wilders(Up,30);
  92. Dt=Wilders(Dn,30);
  93. R40SIt=100*(Ut/(Ut+Dt));
  94. R40SIt10=MA(R40SIt,10);
  95. AddToComposite(R40SIt10,"~40","V");
  96. /*MEAN RSIT 10,20,30,40 VAR=MACD()*/
  97. Var=MACD();
  98. Up=IIf(Var>Ref(Var,-1),abs(Var-Ref(Var,-1)),0);
  99. Dn=IIf(Var<Ref(Var,-1),abs(Var-Ref(Var,-1)),0);
  100. Ut=Wilders(Up,30);
  101. Dt=Wilders(Dn,30);
  102. RSIt=100*(Ut/(Ut+Dt));
  103. RSIt10=MA(RSIt,10);
  104. RSIt20=MA(RSIt,20);
  105. RSIt30=MA(RSIt,30);
  106. RSIt40=MA(RSIt,40);
  107. s1=IIf(RSIt>=0 AND RSIt<=100,RSIt,0);values3 = s1;
  108. s10=IIf(RSIt10>=0 AND RSIt10<=100,RSIt10,0);values4 = s10;
  109. s20=IIf(RSIt20>=0 AND RSIt20<=100,RSIt20,0);values5 = s20;
  110. s30=IIf(RSIt30>=0 AND RSIt30<=100,RSIt30,0);values6 = s30;
  111. s40=IIf(RSIt40>=0 AND RSIt40<=100,RSIt40,0);values7 = s40;
  112. AddToComposite(Values3,"~meanrsit","V");
  113. AddToComposite(Values4,"~meanrsit10","V");
  114. AddToComposite(Values5,"~meanrsit20","V");
  115. AddToComposite(Values6,"~meanrsit30","V");
  116. AddToComposite(Values7,"~meanrsit40","V");
  117. /*MEAN RSIT 10,20,30,40 VAR=MA(MACD(),5)*/
  118. Var=MA(MACD(),5);
  119. Up=IIf(Var>Ref(Var,-1),abs(Var-Ref(Var,-1)),0);
  120. Dn=IIf(Var<Ref(Var,-1),abs(Var-Ref(Var,-1)),0);
  121. Ut=Wilders(Up,30);
  122. Dt=Wilders(Dn,30);
  123. RSIt=100*(Ut/(Ut+Dt));
  124. RSIt10=MA(RSIt,10);
  125. RSIt20=MA(RSIt,20);
  126. RSIt30=MA(RSIt,30);
  127. RSIt40=MA(RSIt,40);
  128. s1=IIf(RSIt>=0 AND RSIt<=100,RSIt,0);values3 = s1;
  129. s10=IIf(RSIt10>=0 AND RSIt10<=100,RSIt10,0);values4 = s10;
  130. s20=IIf(RSIt20>=0 AND RSIt20<=100,RSIt20,0);values5 = s20;
  131. s30=IIf(RSIt30>=0 AND RSIt30<=100,RSIt30,0);values6 = s30;
  132. s40=IIf(RSIt40>=0 AND RSIt40<=100,RSIt40,0);values7 = s40;
  133. AddToComposite(Values3,"~5meanrsit","V");
  134. AddToComposite(Values4,"~5meanrsit10","V");
  135. AddToComposite(Values5,"~5meanrsit20","V");
  136. AddToComposite(Values6,"~5meanrsit30","V");
  137. AddToComposite(Values7,"~5meanrsit40","V");
  138. /*MEAN RSIT 10,20,30,40 VAR=MA(MACD(),10)*/
  139. Var=MA(MACD(),10);
  140. Up=IIf(Var>Ref(Var,-1),abs(Var-Ref(Var,-1)),0);
  141. Dn=IIf(Var<Ref(Var,-1),abs(Var-Ref(Var,-1)),0);
  142. Ut=Wilders(Up,30);
  143. Dt=Wilders(Dn,30);
  144. RSIt=100*(Ut/(Ut+Dt));
  145. RSIt10=MA(RSIt,10);
  146. RSIt20=MA(RSIt,20);
  147. RSIt30=MA(RSIt,30);
  148. RSIt40=MA(RSIt,40);
  149. s1=IIf(RSIt>=0 AND RSIt<=100,RSIt,0);values3 = s1;
  150. s10=IIf(RSIt10>=0 AND RSIt10<=100,RSIt10,0);values4 = s10;
  151. s20=IIf(RSIt20>=0 AND RSIt20<=100,RSIt20,0);values5 = s20;
  152. s30=IIf(RSIt30>=0 AND RSIt30<=100,RSIt30,0);values6 = s30;
  153. s40=IIf(RSIt40>=0 AND RSIt40<=100,RSIt40,0);values7 = s40;
  154. AddToComposite(Values3,"~10meanrsit","V");
  155. AddToComposite(Values4,"~10meanrsit10","V");
  156. AddToComposite(Values5,"~10meanrsit20","V");
  157. AddToComposite(Values6,"~10meanrsit30","V");
  158. AddToComposite(Values7,"~10meanrsit40","V");
  159. /*MEAN RSIT 10,20,30,40 VAR=MA(MA(MACD(),5),5)*/
  160. Var=MA(MA(MACD(),5),5);
  161. Up=IIf(Var>Ref(Var,-1),abs(Var-Ref(Var,-1)),0);
  162. Dn=IIf(Var<Ref(Var,-1),abs(Var-Ref(Var,-1)),0);
  163. Ut=Wilders(Up,30);
  164. Dt=Wilders(Dn,30);
  165. RSIt=100*(Ut/(Ut+Dt));
  166. RSIt10=MA(RSIt,10);
  167. RSIt20=MA(RSIt,20);
  168. RSIt30=MA(RSIt,30);
  169. RSIt40=MA(RSIt,40);
  170. s1=IIf(RSIt>=0 AND RSIt<=100,RSIt,0);values3 = s1;
  171. s10=IIf(RSIt10>=0 AND RSIt10<=100,RSIt10,0);values4 = s10;
  172. s20=IIf(RSIt20>=0 AND RSIt20<=100,RSIt20,0);values5 = s20;
  173. s30=IIf(RSIt30>=0 AND RSIt30<=100,RSIt30,0);values6 = s30;
  174. s40=IIf(RSIt40>=0 AND RSIt40<=100,RSIt40,0);values7 = s40;
  175. AddToComposite(Values3,"~55meanrsit","V");
  176. AddToComposite(Values4,"~55meanrsit10","V");
  177. AddToComposite(Values5,"~55meanrsit20","V");
  178. AddToComposite(Values6,"~55meanrsit30","V");
  179. AddToComposite(Values7,"~55meanrsit40","V");
  180. /*MEAN RSIT 10,20,30,40 VAR=MA(MA(MA(MACD(),5),5),5)*/
  181. Var=MA(MA(MA(MACD(),5),5),5);
  182. Up=IIf(Var>Ref(Var,-1),abs(Var-Ref(Var,-1)),0);
  183. Dn=IIf(Var<Ref(Var,-1),abs(Var-Ref(Var,-1)),0);
  184. Ut=Wilders(Up,30);
  185. Dt=Wilders(Dn,30);
  186. RSIt=100*(Ut/(Ut+Dt));
  187. RSIt10=MA(RSIt,10);
  188. RSIt20=MA(RSIt,20);
  189. RSIt30=MA(RSIt,30);
  190. RSIt40=MA(RSIt,40);
  191. s1=IIf(RSIt>=0 AND RSIt<=100,RSIt,0);values3 = s1;
  192. s10=IIf(RSIt10>=0 AND RSIt10<=100,RSIt10,0);values4 = s10;
  193. s20=IIf(RSIt20>=0 AND RSIt20<=100,RSIt20,0);values5 = s20;
  194. s30=IIf(RSIt30>=0 AND RSIt30<=100,RSIt30,0);values6 = s30;
  195. s40=IIf(RSIt40>=0 AND RSIt40<=100,RSIt40,0);values7 = s40;
  196. AddToComposite(Values3,"~555meanrsit","V");
  197. AddToComposite(Values4,"~555meanrsit10","V");
  198. AddToComposite(Values5,"~555meanrsit20","V");
  199. AddToComposite(Values6,"~555meanrsit30","V");
  200. AddToComposite(Values7,"~555meanrsit40","V");
  201. /*ADDITIONAL MACD COMPOSITES ~MACDBULL AND ~MACDBEAR*/
  202. ob=Signal()<MACD();
  203. os=Signal()>=MACD();
  204. values8 = os>0;
  205. values9 = ob>0;
  206. AddToComposite(Values8,"~macdbear","V");
  207. AddToComposite(Values9,"~macdbull","V");
  208. Buy=0;