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

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    LunarPhase
  4. //  Author/Uploader: Marcelin Tudor 
  5. //  E-mail:          marcelint@gmail.com
  6. //  Date/Time Added: 2006-09-03 10:02:09
  7. //  Origin:          
  8. //  Keywords:        
  9. //  Level:           basic
  10. //  Flags:           exploration
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=682
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=682
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  Plot Full Moon and New Moon on your chart. Simply and easy.
  17. //
  18. //------------------------------------------------------------------------------
  19. // Input your local time zone
  20. TZ=Param("Your local Time Zone? [-12 to +12hrs]",2, -12,12,1);
  21. // Lunar cycle
  22. LunarMonth=29.530589;
  23. Offset=7.254621;
  24. // Calendar }
  25. leap=frac(Year( )/4)==0 AND frac(Year()/ 100)!=0 OR frac(Year()/ 400)==0;
  26. y=Year()*365+ int(Year( )/4)-int( Year()/100) +int(Year( )/400);
  27. m=
  28. IIf(Month()==2,31-leap,
  29. IIf(Month()==3,59,
  30. IIf(Month()==4,90,
  31. IIf(Month()==5,120,
  32. IIf(Month()==6,151,
  33. IIf(Month()==7,181,
  34. IIf(Month()==8,212,
  35. IIf(Month()==9,243,
  36. IIf(Month()==10,273,
  37. IIf(Month()==11,304,
  38. IIf(Month()==12,334, -leap))))))) ))));
  39. CurrentDay=y+ m+Day()-TZ/ 24-Offset;
  40. // Full Moon }
  41. FM=frac(CurrentDay/ LunarMonth) ;
  42. FM=PeakBars( FM, 1, 1)==0;
  43. // New Moon }
  44. NM=frac((CurrentDay +LunarMonth/ 2)/LunarMonth) ;
  45. NM=PeakBars( NM, 1,1)==0;
  46. FullMoon=FM-NM==1;
  47. NewMoon=FM-NM==-1;
  48. //Plot Moon Phase in own window }
  49. SetChartOptions(0,chartShowArrows|chartShowDates);
  50. _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
  51. Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
  52. SetChartBkGradientFill( ParamColor("BgTop", colorWhite),ParamColor("BgBottom", colorLightYellow));
  53. shape = IIf(FullMoon,shapeCircle+shapePositionAbove,IIf(NewMoon,shapeCircle+shapePositionAbove,Null));
  54. PlotShapes(shape,IIf(FullMoon,colorYellow,colorBlack),0,H);