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

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    Elder Impulse Indicator
  4. //  Author/Uploader: Lal 
  5. //  E-mail:          
  6. //  Date/Time Added: 2005-10-28 18:01:49
  7. //  Origin:          Elder's CIMTR
  8. //  Keywords:        Elder, Impulse
  9. //  Level:           medium
  10. //  Flags:           indicator
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=570
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=570
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  Detects an "impulse" in price and plots up/down arrows accordingly along
  17. //  with Close bars.
  18. //
  19. //------------------------------------------------------------------------------
  20. /**************************************************************************
  21. Name : Elder Impulse Indicator
  22. Coded by : Lal
  23. Date : 28.10.2005
  24. Note :  Please refer to Elder's "Come Into my Trading Room"
  25. for full details 
  26. ******************************************************************************/
  27. // User-defined parameter for EMA periods
  28. EMA_prds = Param("EMA_periods", 12, 1, 30, 1);
  29. // Compute EMA and MACD Histogram
  30. DayEMA = EMA(Close, EMA_prds);
  31. Histogram = MACD() - Signal();
  32. // Determine if we have an Impulse UP, DOWN or None
  33. Impulse_Up = DayEMA > Ref(DayEMA, -1) AND Histogram > Ref(Histogram, -1);
  34. Impulse_Down = DayEMA < Ref(DayEMA, -1) AND Histogram < Ref(Histogram, -1);   
  35. Impulse_None = (NOT Impulse_UP) AND (NOT Impulse_Down);
  36. // Compute Weekly MACD and determine whether rising or falling
  37. // Note: uses "non-standard"  parameters!
  38. TimeFrameSet(inWeekly);
  39. MACD_val = MACD(5, 8);
  40. Signal_val = Signal(5, 8, 5);
  41. Hist_in_w = MACD_val - Signal_val;
  42. wh_rising  = Hist_in_w > Ref(Hist_in_w, -1);
  43. wh_falling  = Hist_in_w < Ref(Hist_in_w, -1);
  44. TimeFrameRestore();
  45. // Now get Monthly MACD Histogram....
  46. TimeFrameSet(inMonthly);
  47. MACD_val = MACD(5, 8);
  48. Signal_val = Signal(5, 8, 5);
  49. Hist_in_m = MACD_val - Signal_val;
  50. mh_rising = Hist_in_m > Ref(Hist_in_m, -1);
  51. mh_falling = Hist_in_m < Ref(Hist_in_m, -1);
  52. TimeFrameRestore();
  53. wh_rising  = TimeFrameExpand( wh_rising, inWeekly ); 
  54. wh_falling  = TimeFrameExpand( wh_falling, inWeekly ); 
  55. mh_rising  = TimeFrameExpand(mh_rising, inMonthly);
  56. mh_falling  = TimeFrameExpand(mh_falling, inMonthly);
  57. kol  = IIf( wh_rising, colorGreen,  IIf(wh_falling, colorRed, colorLightGrey));
  58. mkol  = IIf( mh_rising, colorBlue,  IIf(mh_falling, colorYellow, colorLightGrey));
  59. // Plot them all!
  60. Plot(Close, "Close", colorTeal, styleBar);
  61. PlotShapes(shapeUpArrow * Impulse_Up, colorBlue, 0, Low, -12);
  62. PlotShapes(shapeDownArrow * Impulse_Down, colorRed, 0, High, -12);
  63. PlotShapes(shapeSmallCircle * Impulse_None, colorWhite, 0, High, 5);
  64. Plot(10, "ribbon", kol, styleOwnScale|styleArea|styleNoLabel, -12, 156); // Weekly trend
  65. Plot(10, "ribbon", mkol, styleOwnScale|styleArea|styleNoLabel, -0.5, 150); // Monthly Trend