Plot Monthly,Weekly and Daily Moving average.afl
上传用户:shiqiang
上传日期:2009-06-12
资源大小:1289k
文件大小:2k
源码类别:

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    Plot Monthly,Weekly and Daily Moving average
  4. //  Author/Uploader: Anthony Faragasso 
  5. //  E-mail:          ajf1111@epix.net
  6. //  Date/Time Added: 2002-03-02 16:27:46
  7. //  Origin:          
  8. //  Keywords:        
  9. //  Level:           basic
  10. //  Flags:           indicator
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=168
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=168
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  You can plot a Monthly , weekly and Daily Moving average
  17. //
  18. //  on your Daily custom price chart window without changing the view
  19. //
  20. //  settings. Also, Title information is included.
  21. //
  22. //------------------------------------------------------------------------------
  23. //Plot Monthly, Weekly and Daily Moving Average on Daily Price Chart
  24. //Ver.1.01 revision
  25. //3/02/02, coded by Anthony Faragasso
  26. //e-mail: ajf1111@epix.net
  27. MaxGraph=7;
  28. //Input Time periods for Monthly,Weekly and Daily Moving Averages
  29. MonthlyPds=10;//Months
  30. WeeklyPds=20;//Weeks
  31. DailyPds=10;//Days 
  32. /***********************************/
  33. //Input Price Variable ( open, high ,low, close);
  34. Price=C;
  35. MonthlyPrice=Price;
  36. WeeklyPrice=Price;
  37. DailyPrice=Price;
  38. /**********************************/
  39. /***Colors***/
  40. //Set to your Preference
  41. Color=6;//Price chart
  42. MthAvgColor=3;//Monthly AverageLine
  43. WklyAvgColor=5;//weekly AverageLine
  44. DlyAvgColor=4;//Daily AverageLine
  45. /**********************************/
  46. Weekly=ValueWhen(DayOfWeek() > Ref( DayOfWeek(),1),WeeklyPrice);
  47. Monthly=ValueWhen(Day() > Ref( Day(), 1 ),MonthlyPrice);
  48. MonthlyAvg=EMA(Monthly,MonthlyPds);
  49. WeeklyAvg=EMA(Weekly,WeeklyPds);
  50. DailyAvg=EMA(DailyPrice,DailyPds);
  51. Graph0=C;
  52. Graph0Style=64;
  53. Graph0Color=Color;
  54. Graph1=WeeklyAvg;
  55. Graph1Style=1+4;//Thick line
  56. Graph1Color=WklyAvgColor;
  57. Graph2=DailyAvg;
  58. Graph2Style=1;
  59. Graph2Color=DlyAvgColor;
  60. Graph3=MonthlyAvg;
  61. Graph3Style=1;
  62. Graph3Color=MthAvgColor;
  63. Title=Name()+"  "+"("+WriteVal(WeeklyPds,1)+")"+" Week Moving Average= "+"("+WriteVal(WeeklyAvg,1.2)+")"+" :: "+"("+WriteVal(DailyPds,1)+")"+" Period Moving Average= "+"("+WriteVal(DailyAvg,1.2)+")"+" :: "+"("+WriteVal(MonthlyPds,1)+")"+" Month Moving Average= "+"("+WriteVal(MonthlyAvg,1.2)+")";