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

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    Bow tie
  4. //  Author/Uploader: dtholz 
  5. //  E-mail:          
  6. //  Date/Time Added: 2002-02-28 00:06:30
  7. //  Origin:          AFL Implementation by Geoff Mulhall
  8. //  Keywords:        Dave Landry's Bow
  9. //  Level:           basic
  10. //  Flags:           exploration
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=167
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=167
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  /* Boe Tie - AFL Implementation by Geoff Mulhall 12-5-2001
  17. //
  18. //------------------------------------------------------------------------------
  19.  
  20. /* Boe Tie - AFL Implementation by Geoff Mulhall 12-5-2001 */
  21. dollars = 5000; /* Or whatever you investment is to be - for the bangforbuck calculation */
  22. maShort = 10;
  23. maMedium = 20;
  24. maLong = 30;
  25.  
  26. /* Bow Tie conditions - Short term moving average has crossed the medium term moving average sometime in the last 15 days - Add more conditions for more days */ 
  27.  
  28. cond11 = ref(cross(ma(close,maShort),ma(close,maMedium)),-1) > 0;
  29. cond12 =  ref(cross(ma(close,maShort),ma(close,maMedium)),-2) > 0;
  30. cond13 =  ref(cross(ma(close,maShort),ma(close,maMedium)),-3) > 0;
  31. cond14 =  ref(cross(ma(close,maShort),ma(close,maMedium)),-4) > 0;
  32. cond15 =  ref(cross(ma(close,maShort),ma(close,maMedium)),-5) > 0;
  33. cond16 =  ref(cross(ma(close,maShort),ma(close,maMedium)),-6) > 0;
  34. cond17 =  ref(cross(ma(close,maShort),ma(close,maMedium)),-7) > 0;
  35. cond18 =  ref(cross(ma(close,maShort),ma(close,maMedium)),-8) > 0;
  36. cond19 =  ref(cross(ma(close,maShort),ma(close,maMedium)),-9) > 0;
  37. cond110 =  ref(cross(ma(close,maShort),ma(close,maMedium)),-10) > 0;
  38. cond111 =  ref(cross(ma(close,maShort),ma(close,maMedium)),-11) > 0;
  39. cond112 =  ref(cross(ma(close,maShort),ma(close,maMedium)),-12) > 0;
  40. cond113 =  ref(cross(ma(close,maShort),ma(close,maMedium)),-13) > 0;
  41. cond114 =  ref(cross(ma(close,maShort),ma(close,maMedium)),-14) > 0;
  42. cond115 =  ref(cross(ma(close,maShort),ma(close,maMedium)),-15) > 0;
  43.  
  44. cond1 = cond11 OR cond12 OR cond13 OR cond14 OR cond15 OR cond16 OR cond17 OR cond18 OR cond19 OR cond110 OR cond111 OR cond112 OR cond113 OR cond114 OR cond115; 
  45.  
  46. /* Moving averages must be in the correct order at the buy signal */
  47.  
  48. cond2 = (ma(close,maShort) > ma(close,maMedium)) AND (ma(close,maMedium) > ma(close,maLong)); 
  49.  
  50. /* Signal is given when the close crosses above the short term moving average */
  51.  
  52. cond3 = cross(close,ma(close,maShort));
  53.  
  54. filter =  cond1 AND cond2 AND cond3;
  55.  
  56. buy = filter;
  57.  
  58. sell = 0; 
  59.  
  60. BangForBucks = (dollars/close) * atr(200);
  61.  
  62. numcolumns = 3;
  63. column0 = close;
  64. column0format = 3.2;
  65. column0name = "Close";
  66. column1 = atr(maLong);
  67. column1format = 3.4;
  68. column1name = "ATR - maLong";
  69. column2 = BangForBucks;
  70. column2format = 3.2;
  71. column2name = "BangForBucks"; 
  72.