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

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    EMA Crossover
  4. //  Author/Uploader: David McMillin 
  5. //  E-mail:          dmcmillin@socal.rr.com
  6. //  Date/Time Added: 2004-08-13 10:50:12
  7. //  Origin:          Unknown but basic
  8. //  Keywords:        EMA Crossover
  9. //  Level:           medium
  10. //  Flags:           system
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=379
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=379
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  The formula is meant to work with Buystops and Sellstops at the previous
  17. //  days's 7d-ema crossovers. Appears to work well with long trades in about
  18. //  20% of the SPX. Designed for weekly traders.
  19. //
  20. //------------------------------------------------------------------------------
  21. // EMA Cross
  22. Range1=Optimize("range1",7,1,20,1);
  23. Range2=Optimize("range2",7,1,20,1);
  24. Plot( Close, "Price", colorBlack, styleCandle ); 
  25. Plot(EMA( Close,range1), "7d-ema", colorRed );  
  26. Buy = Cross((Close),(EMA(Close,range1))); 
  27. Buystop = Ref(EMA(Close,range1),-1); 
  28. BuyPrice = Max(Buystop,Low); 
  29. Sell = Cross(EMA(Close,range2),(Close)); 
  30. Sellstop = Ref(EMA(Close,range1),-1); 
  31. SellPrice = Min(sellstop,High); 
  32. Short = Sell; 
  33. Cover = Buy;