Weekly chart.afl
上传用户:shiqiang
上传日期:2009-06-12
资源大小:1289k
文件大小:2k
源码类别:

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    Weekly chart
  4. //  Author/Uploader: Graham Kavanagh 
  5. //  E-mail:          gkavanag@bigpond.net.au
  6. //  Date/Time Added: 2003-01-01 22:46:10
  7. //  Origin:          
  8. //  Keywords:        weekly
  9. //  Level:           medium
  10. //  Flags:           indicator
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=248
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=248
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  Weekly chart to be shown in indicator window. This is for fixed weeks
  17. //  Monday to Friday.
  18. //
  19. //------------------------------------------------------------------------------
  20. firstday = ValueWhen( Cum(1)==1, DayOfWeek() );
  21. numweeks = IIf(LastValue(DayOfWeek())==firstday, LastValue(Cum(DayOfWeek()==firstday)),LastValue(Cum(DayOfWeek()==firstday))+1 );
  22. numweek = IIf(firstday==1, Cum( DayOfWeek() < Ref(DayOfWeek(),-1) ), IIf(firstday>1, Cum( DayOfWeek() < Ref(DayOfWeek(),-1) )+1 , 0 ));
  23. numweek = IIf(IsEmpty(numweek),1,numweek);
  24. firstbar = LastValue(Cum(1))-LastValue(numweek)+1;
  25. dayRef =  5-LastValue(DayOfWeek()) + 4*( Cum(1) - LastValue(Cum(1)) );
  26. xxx =  Min(0,5-LastValue(DayOfWeek()) + 4*( Cum(1) - LastValue(Cum(1)) ));
  27. wo = IIf(IsEmpty( Ref(DayOfWeek(),-DayOfWeek()) ), ValueWhen(DayOfWeek()==firstday,O), ValueWhen(DayOfWeek()==1,O ) );
  28. wh = HHV(H,Min(DayOfWeek(),5));
  29. wl = LLV(L,Min(DayOfWeek(),5));
  30. wc = C;
  31. weeko =Ref(wo,xxx);
  32. weekh = Ref(wh,xxx);
  33. weekl = Ref(wl,xxx);
  34. weekc = Ref(wc,xxx);
  35. PlotOHLC(weeko,weekh,weekl,weekc,"weekly",colorBlack,styleCandle);
  36. Filter=1;
  37. AddColumn(DayOfWeek(),"day",1.0);
  38. AddColumn(O,"oooo",1.1);
  39. AddColumn(H,"hhhh",1.1);
  40. AddColumn(L,"llll",1.1);
  41. AddColumn(C,"cccc",1.1);
  42. AddColumn(wo,"wo",1.1);
  43. AddColumn(wh,"wh",1.1);
  44. AddColumn(wl,"wl",1.1);
  45. AddColumn(wc,"wc",1.1);
  46. AddColumn(weeko,"wko",1.1);
  47. AddColumn(weekh,"wkh",1.1);
  48. AddColumn(weekl,"wkl",1.1);
  49. AddColumn(weekc,"wkc",1.1);
  50. AddColumn(firstbar ,"fstb",1.0);
  51. AddColumn(numweek ,"nwk",1.0);
  52. AddColumn(Cum(1),"cum1",1.0);
  53. AddColumn(xxx,"xxx",1.0);
  54. AddColumn(Ref(DateNum(),xxx),"refdate",1.0);