Another FIb Level.afl
上传用户:shiqiang
上传日期:2009-06-12
资源大小:1289k
文件大小:4k
源码类别:

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    Another FIb Level
  4. //  Author/Uploader: Sggin 
  5. //  E-mail:          sggin1@excite.com
  6. //  Date/Time Added: 2006-02-06 10:29:54
  7. //  Origin:          
  8. //  Keywords:        Fib
  9. //  Level:           basic
  10. //  Flags:           indicator
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=584
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=584
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  Based on Aron Pipa's formula "Automatic Fib Levels" , December, 11, 2005
  17. //
  18. //  I changed the formula around a little so u can select the fib lines in a
  19. //  large timeframes , eg daily, and see them in smaller times frames like 5
  20. //  min, so you can see major retracement levels,
  21. //
  22. //------------------------------------------------------------------------------
  23. /*---------------------------------------------------
  24. Another Fib Level
  25. Based on Aron Pipa's formula , December, 11, 2005
  26.    * Under Parameters, select "axis & Grid" , 
  27.      "show date axis" = "yes"
  28. * Dash lines are the fib extentions
  29. * If you are not familiar with begin/end values double 
  30. click a lot around the screen til you get the idea 
  31. * Select your fib retrace in a higher timeframe e.g. 
  32. daily and view chart in e.g. 5 min, to see magor 
  33. retracement  lines.
  34. --------------------------------------------------------*/
  35. EnableTextOutput(0);
  36. // Get values for fib levels 
  37. StartBar=BeginValue(BarIndex());
  38. FinishBar = EndValue( BarIndex() ); 
  39. LastBar=BarCount-1;
  40. period = FinishBar - StartBar;
  41. Lo =LLV(L,period);
  42. Hi = HHV(H,period);
  43. i = startbar;
  44. for( i = startbar; i < finishbar; i++ )
  45. {
  46. Line100 = EndValue(H);
  47. Line0 = BeginValue(L);
  48. Line1 = Line0 + abs(Line100-Line0)*0.236;
  49. Line2 = Line0 + abs(Line100-Line0)*0.382;
  50. Line3 = Line0 + abs(Line100-Line0)*0.5;
  51. Line4 = Line0 + abs(Line100-Line0)*0.618;
  52. }
  53. // fib lines, the "x" is the extension
  54. fib0= LineArray(startbar, Line0, finishbar, Line0, 0, 1);fib0x= LineArray(finishbar, Line0, Lastbar, Line0, 0, 1);
  55. fib100 = LineArray(startbar, Line100, finishbar, Line100, 0, 1);fib100x = LineArray(finishbar, Line100, Lastbar, Line100, 0, 1);
  56. fib1= LineArray(startbar, Line1, finishbar, Line1, 0, 1);fib1x= LineArray(finishbar, Line1, Lastbar, Line1, 0, 1);
  57. fib2= LineArray(startbar, Line2, finishbar, Line2, 0, 1);fib2x= LineArray(finishbar, Line2, Lastbar, Line2, 0, 1);
  58. fib3= LineArray(startbar, Line3, finishbar, Line3, 0, 1);fib3x= LineArray(finishbar, Line3, Lastbar, Line3, 0, 1);
  59. fib4= LineArray(startbar, Line4, finishbar, Line4, 0, 1);fib4x= LineArray(finishbar, Line4, Lastbar, Line4, 0, 1);
  60. // Plot
  61. Plot(C,"", colorBlack,styleCandle);
  62. Plot(fib0,"", colorBlack,styleDots|styleNoRescale);Plot(fib0x,"", colorBlack,styleDashed|styleNoRescale);
  63. Plot(fib100,"", colorBlack,styleDots|styleNoRescale);Plot(fib100x,"", colorBlack,styleDashed|styleNoRescale);
  64. Plot(fib1,"", colorRed,styleNoRescale);Plot(fib1x,"", colorRed,styleDashed|styleNoRescale);
  65. Plot(fib2,"", colorBlue,styleNoRescale);Plot(fib2x,"", colorBlue,styleDashed|styleNoRescale);
  66. Plot(fib3,"", colorGreen,styleNoRescale);Plot(fib3x,"", colorGreen,styleDashed|styleNoRescale);
  67. Plot(fib4,"", colorBrown,styleNoRescale);Plot(fib4x,"", colorBrown,styleDashed|styleNoRescale);
  68. // Title
  69. Title="n Automatic Fib Levels  "+Date()        +"n"+
  70. EncodeColor( colorBlack )  + " 100%  = "+Line100 +"  " +"n"+
  71. EncodeColor( colorBlack )  + " 61.8% = "+EncodeColor( colorBrown )+Line4   +"  " +"n"+
  72. EncodeColor( colorBlack )  + " 50.0% = "+EncodeColor( colorGreen )+Line3   +"  " +"n"+
  73. EncodeColor( colorBlack )   + " 38.2% = "+EncodeColor( colorBlue )+Line2   +"  " +"n"+
  74. EncodeColor( colorBlack )    + " 23.6% = "+EncodeColor( colorRed )+Line1   +"  " +"n"+
  75. EncodeColor( colorBlack )  + "    0% = "+Line0;