IFT of RSI - Multiple TimeFrames.afl
上传用户:shiqiang
上传日期:2009-06-12
资源大小:1289k
文件大小:5k
源码类别:

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    IFT of RSI - Multiple TimeFrames
  4. //  Author/Uploader: Brian Richard 
  5. //  E-mail:          brianrichard99@hotmail.com
  6. //  Date/Time Added: 2004-07-30 23:43:41
  7. //  Origin:          
  8. //  Keywords:        IFT, RSI, TimeFrame
  9. //  Level:           semi-advanced
  10. //  Flags:           indicator
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=375
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=375
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  This is the Inverse Fisher Transform (IFT) of the Relative Strength Index
  17. //  (RSI), across multiple timeframes. It only shows two timeframes at any
  18. //  given time -- the currrent chart time frame, and the next largest time
  19. //  frame (see code for details).
  20. //
  21. //  Hourly chart: When the IFT is oversold on the daily IFT, and lifting up
  22. //  above the oversold line -- and the hourly IFT is also rising -- this is a
  23. //  good buy signal. The reverse is true for a short signal.
  24. //
  25. //  This may be used with 5 min., hourly, daily, and weekly charts.
  26. //
  27. //  Included is Tom DeMark-style duration analysis, which includes trend
  28. //  strength arrows. These arrows are not buy or sell signals. Instead, they
  29. //  represent extreme conditions, which usually end up with a strong rebound,
  30. //  or a strong continuation of the trend. Use something like the Volume Flow
  31. //  Indicator (VFI) to help determine which way the trend will go.
  32. //
  33. //  The white IFT line always represents the smaller time frame (i.e, the
  34. //  default time frame for the chart).
  35. //
  36. //  You may want to build a version of this that uses Tom DeMark's Range
  37. //  Expansion Index, instead of the IFT or RSI. This works well to help
  38. //  determine what this IFT indicator will likely do next.
  39. //
  40. //------------------------------------------------------------------------------
  41. /* IFT-RSI */
  42. TimeFrameSet(in5Minute);
  43. pr_5m = (H+L)/2; 
  44. len_5m = 10; 
  45. maxh_5m = HHV(pr_5m,len_5m); 
  46. minl_5m = LLV(pr_5m,len_5m); 
  47. Array1_5m = .33*2*((pr_5m-minl_5m)/(maxh_5m-minl_5m)-.5); 
  48. val1_5m = AMA(Array1_5m,.67); 
  49. value1_5m = IIf(val1_5m>.99,.999,IIf(val1_5m<-.99,-.999,val1_5m)); 
  50. Array2_5m = .5*log((1+value1_5m)/(1-value1_5m)); 
  51. fish_5m = AMA(Array2_5m,.5); 
  52. /* IFT-RSI */
  53. TimeFrameSet(inHourly);
  54. pr_h = (H+L)/2; 
  55. len_h = 10; 
  56. maxh_h = HHV(pr_h,len_h); 
  57. minl_h = LLV(pr_h,len_h); 
  58. Array1_h = .33*2*((pr_h-minl_h)/(maxh_h-minl_h)-.5); 
  59. val1_h = AMA(Array1_h,.67); 
  60. value1_h = IIf(val1_h>.99,.999,IIf(val1_h<-.99,-.999,val1_h)); 
  61. Array2_h = .5*log((1+value1_h)/(1-value1_h)); 
  62. fish_h = AMA(Array2_h,.5); 
  63. /* IFT-RSI */
  64. TimeFrameSet(inDaily);
  65. pr_d = (H+L)/2; 
  66. len_d = 10; 
  67. maxh_d = HHV(pr_d,len_d); 
  68. minl_d = LLV(pr_d,len_d); 
  69. Array1_d = .33*2*((pr_d-minl_d)/(maxh_d-minl_d)-.5); 
  70. val1_d = AMA(Array1_d,.67); 
  71. value1_d = IIf(val1_d>.99,.999,IIf(val1_d<-.99,-.999,val1_d)); 
  72. Array2_d = .5*log((1+value1_d)/(1-value1_d)); 
  73. fish_d = AMA(Array2_d,.5); 
  74. /* IFT-RSI */
  75. TimeFrameSet(inWeekly);
  76. pr_w = (H+L)/2; 
  77. len_w = 10; 
  78. maxh_w = HHV(pr_w,len_w); 
  79. minl_w = LLV(pr_w,len_w); 
  80. Array1_w = .33*2*((pr_w-minl_w)/(maxh_w-minl_w)-.5); 
  81. val1_w = AMA(Array1_w,.67); 
  82. value1_w = IIf(val1_w>.99,.999,IIf(val1_w<-.99,-.999,val1_w)); 
  83. Array2_w = .5*log((1+value1_w)/(1-value1_w)); 
  84. fish_w = AMA(Array2_w,.5);
  85. /* IFT-RSI */
  86. TimeFrameSet(inMonthly);
  87. pr_mo = (H+L)/2; 
  88. len_mo = 10; 
  89. maxh_mo = HHV(pr_mo,len_mo); 
  90. minl_mo = LLV(pr_mo,len_mo); 
  91. Array1_mo = .33*2*((pr_mo-minl_mo)/(maxh_mo-minl_mo)-.5); 
  92. val1_mo = AMA(Array1_mo,.67); 
  93. value1_mo = IIf(val1_mo>.99,.999,IIf(val1_mo<-.99,-.999,val1_mo)); 
  94. Array2_mo = .5*log((1+value1_mo)/(1-value1_mo)); 
  95. fish_mo = AMA(Array2_mo,.5); 
  96. TimeFrameRestore();
  97. varOverboughtSignal = 0.20;
  98. varOversoldSignal = -0.20;
  99. PlotGrid(varOverboughtSignal);
  100. PlotGrid(varOversoldSignal);
  101. /// DURATION ANALYSIS for Hourly ///
  102. // Identify oversold conditions, marked with red arrow to denote downtrend
  103. varOversold_h = IIf( Ref(fish_h,-7)<=varOversoldSignal 
  104. AND Ref(fish_h,-6)<=varOversoldSignal 
  105. AND Ref(fish_h,-5)<=varOversoldSignal 
  106. AND Ref(fish_h,-4)<=varOversoldSignal 
  107. AND Ref(fish_h,-3)<=varOversoldSignal 
  108. AND Ref(fish_h,-2)<=varOversoldSignal 
  109. AND Ref(fish_h,-1)<=varOversoldSignal 
  110. AND fish_h<=varOversoldSignal ,1,0);
  111. IIf(VarOversold_h>0,PlotShapes(shapeHollowDownArrow*varOversold_h,colorRed),0);
  112. // Identify overbought conditions, marked with green arrow to denote uptrend
  113. varOverbought_h = IIf( Ref(fish_h,-7)>=varOverboughtSignal 
  114. AND Ref(fish_h,-6)>=varOverboughtSignal 
  115. AND Ref(fish_h,-5)>=varOverboughtSignal
  116. AND Ref(fish_h,-4)>=varOverboughtSignal 
  117. AND Ref(fish_h,-3)>=varOverboughtSignal 
  118. AND Ref(fish_h,-2)>=varOverboughtSignal 
  119. AND Ref(fish_h,-1)>=varOverboughtSignal 
  120. AND fish_h>=varOverboughtSignal ,1,0);
  121. IIf(varOverbought_h>0,PlotShapes(shapeHollowUpArrow*varOverbought_h,colorGreen),0);
  122. Plot(TimeFrameExpand(fish_5m, in5Minute), "IFT_5m", colorWhite, styleThick);
  123. Plot(TimeFrameExpand(fish_h, inHourly), "IFT_h", colorOrange, styleThick);
  124. Plot(TimeFrameExpand(fish_d, inDaily), "IFT_d", colorRed, styleThick);
  125. Plot(TimeFrameExpand(fish_w, inWeekly), "IFT_w", colorBlue, styleThick);
  126. Plot(TimeFrameExpand(fish_mo, inMonthly), "IFT_m", colorBlack, styleThick);
  127. Title="IFT-RSI TimeFrame";