Rea Time Daily Price Levels.afl
上传用户:shiqiang
上传日期:2009-06-12
资源大小:1289k
文件大小:4k
源码类别:

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    Rea Time Daily Price Levels
  4. //  Author/Uploader: Ara Kaloustian 
  5. //  E-mail:          ara1@san.rr.com
  6. //  Date/Time Added: 2005-10-10 01:40:26
  7. //  Origin:          
  8. //  Keywords:        Real Time Daily Price Levels
  9. //  Level:           medium
  10. //  Flags:           indicator
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=564
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=564
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  This program computes and plots prices levels fir real time data, for
  17. //  following parameters: Toda's Open, Prior Day Open, Clode, High, Low, First
  18. //  hour High, Low.
  19. //
  20. //------------------------------------------------------------------------------
  21. //File: Bruce Chart
  22. //August 5, 2005
  23. //
  24. //Program computes and displays various price values in real time 
  25. //
  26. // Today's Open
  27. // Prior Day High
  28. // Prior Day Low
  29. // Prior Day Open
  30. // Prior Day Close
  31. // Prior Day Middle 
  32. // First Hour High
  33. // First Hour Low
  34. PlotOHLC(Open,High,Low,Close,"",colorBlack,styleCandle);
  35. Bars  = 0;
  36. xpdh  = 90;
  37. //Levels = 1 activates program
  38. Levels     = Param("Levels",1,0,1,1);
  39. ExpFirst   = Param("ExpFirst",1,0,1,1); 
  40. if (Levels ==1)
  41. {
  42. //Convert data to daily
  43. Plot_Range = (TimeNum() >= 63000 AND TimeNum()<= 131500) AND (DateNum()==LastValue(DateNum()));
  44. FH_Range   = (TimeNum() >= 63000 AND TimeNum()<= 73000) AND (DateNum()==LastValue(DateNum()));
  45. FH_Prices  = High * FH_Range;
  46. FH_Marker  = BarsSince(FH_Range>0);
  47. //Find number of bars in 60 minutes 
  48. Num_Bars   = 3600 / Interval(1);  
  49. TimeFrameSet(inDaily);
  50. TOP_        = Open;
  51. PDH_        = Ref(High,-1);
  52. PDL_        = Ref(Low,-1);
  53. PDO_        = Ref(Open,-1);
  54. PDC_        = Ref(Close,-1);
  55. PDM_        = (PDH_+PDL_)/2;
  56. TimeFrameRestore();
  57. TOP         = TimeFrameExpand(TOP_,inDaily,expandFirst); 
  58. PDH         = TimeFrameExpand(PDH_,inDaily,expandFirst); 
  59. PDL         = TimeFrameExpand(PDL_,inDaily,expandFirst); 
  60. PDO         = TimeFrameExpand(PDO_,inDaily,expandFirst); 
  61. PDC         = TimeFrameExpand(PDC_,inDaily,expandFirst); 
  62. PDM         = TimeFrameExpand(PDM_,inDaily,expandFirst); 
  63. FHH        = Ref(HHV(High*FH_Range,Num_Bars),-FH_Marker);
  64. FHL        = Ref(LLV(Low,Num_Bars),-FH_Marker);
  65. Bars       = BarsSince(TimeNum() >= 62900 AND TimeNum() < 64400);//,BarIndex(),1); // AND DateNum()==LastValue(DateNum());
  66. x0         = BarCount-LastValue(Bars);
  67. x1         = BarCount-1;
  68. TOP_Line   = LineArray(x0,LastValue(TOP),x1,LastValue(TOP),0);
  69. PDH_Line   = LineArray(x0,LastValue(PDH),x1,LastValue(PDH),0);
  70. PDL_Line   = LineArray(x0,LastValue(PDL),x1,LastValue(PDL),0);
  71. PDC_Line   = LineArray(x0,LastValue(PDC),x1,LastValue(PDC),0);
  72. PDM_Line   = LineArray(x0,LastValue(PDM),x1,LastValue(PDM),0);
  73. FHH_Line   = LineArray(x0,LastValue(FHH),x1,LastValue(FHH),0);
  74. FHL_Line   = LineArray(x0,LastValue(FHL),x1,LastValue(FHL),0);
  75. Plot(TOP_Line,"",colorGreen,styleDashed|styleNoRescale);
  76. Plot(PDH_Line,"",colorPlum,styleLine|styleNoRescale);
  77. Plot(PDL_Line,"",colorRed,styleLine|styleNoRescale);
  78. Plot(PDC_Line,"",colorAqua,styleLine|styleNoRescale);
  79. Plot(PDM_Line,"",colorYellow,styleLine|styleNoRescale);
  80. Plot(FHH_Line,"",IIf(FH_Range==1,Null,colorBlue),styleLine|styleNoRescale);
  81. Plot(FHL_Line,"",IIf(FH_Range==1,Null,colorBlue),styleLine|styleNoRescale);
  82. }
  83. Title = Name() + "  Daily Levels Bruce 1   " + Interval(2) + "  " + WriteVal(TimeNum(),1.0) + "    Open: " + WriteVal(Open,1.2) + "   High: " + WriteVal(High,1.2) 
  84. + "   Low: " + WriteVal(Low,1.2) + "   Close: " + WriteVal(Close,1.2);