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

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    Lagging MA-Xover
  4. //  Author/Uploader: Thomas Heyen 
  5. //  E-mail:          
  6. //  Date/Time Added: 2006-06-08 05:27:49
  7. //  Origin:          Result of testing futures intraday models
  8. //  Keywords:        Model Moving Average Crossover
  9. //  Level:           medium
  10. //  Flags:           system
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=625
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=625
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  Fast DEMA crossing its same period lagging EMA.
  17. //
  18. //------------------------------------------------------------------------------
  19. /* ###################
  20. Lagging MA-Xover
  21. Author: Thomas Heyen
  22. Intraday Trading Model
  23. Please set your Chart to
  24. the Timeframe of the Model!
  25. Otherwise Trading Ribbbon and
  26. Shapes will not correspond to
  27. the Graph.
  28. #####################*/
  29. MarketHours = TimeNum()>=094000 AND TimeNum()<=154400; 
  30. MarketClose= TimeNum()>=154444 AND TimeNum()<=240000;
  31. TimeFrameSet(120);
  32. smooth = Optimize("smooth",20,2,40,1);
  33. Lag = Optimize("lag",22,2,40,1);
  34. fast = DEMA(C,smooth);
  35. slow = Ref(EMA(C,smooth),-Lag);
  36. Buy = Cross(fast,slow) AND MArkethours;
  37. Sell = Cross(slow,fast) OR slow == fast OR MArketclose;
  38. Cover = Cross(fast,slow) OR slow == fast OR MArketclose;
  39. Short = Cross(slow,fast) AND MArkethours;
  40. PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorGreen);
  41. PlotShapes(IIf(Short,shapeDownArrow,shapeNone),colorRed);
  42. // Plot Trading Ribbon
  43. Color = IIf( BarsSince(Sell)>BarsSince(Buy), colorGreen, IIf( BarsSince(Cover)>BarsSince(Short), colorRed, colorWhite ));
  44. Plot( 1, "", Color, styleArea | styleOwnScale | styleNoLabel, -0.1, 15 );
  45. TimeFrameRestore();