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

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    ElderSafeZoneStopShort
  4. //  Author/Uploader: Leon Nedbalek 
  5. //  E-mail:          ned@hawaii.rr.com
  6. //  Date/Time Added: 2003-12-30 18:39:36
  7. //  Origin:          From Dr. Alexander Elder's "Come Into My Trading Room"
  8. //  Keywords:        Elder SafeZone Stop
  9. //  Level:           medium
  10. //  Flags:           indicator
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=319
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=319
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  Provides results identical to the Excel spreadsheet discussed in the
  17. //  Trading Room book, except that it gives tomorrow's recommended stop from
  18. //  today's end-of-day data instead of today's stop from yesterday's data. To
  19. //  get today's stop, click on yesterday's date in the chart. For short
  20. //  positions only. Also see the companion indicator ElderSafeZoneStopLong.
  21. //
  22. //------------------------------------------------------------------------------
  23. H1=Ref(H,-1);
  24. Pd=Param("Period",10,1,50,1);
  25. UpPen=IIf(H>H1,H-H1,0);
  26. UpPenSum=Sum(UpPen,Pd);
  27. UpPenCount=Sum(H>H1,Pd);
  28. AvgUpPen=UpPenSum/UpPenCount;
  29. AvgUpPenMult=Param("Multiplier",2,1,4,0.1);
  30. DaysInTrade=Param("Days in trade",1,1,50,1);
  31. StopShort=H+(AvgUpPen*AvgUpPenMult);
  32. SafeZoneStopShort=LLV(StopShort,DaysInTrade);
  33. Graph0=Close; Graph0Style=styleBar|styleThick; Graph0Color=colorWhite;
  34. Graph1=SafeZoneStopShort; Graph1Style=styleDots|styleNoLine; Graph1Color=colorLightOrange;
  35. Title="\c55"
  36. +Name() 
  37. +"\c42  Elder SafeZone \c40SHORT"
  38. +"\c42    SafeZoneStop for next trading day after \c55"
  39. +Date()
  40. +": \c33"
  41. +WriteVal(SafeZoneStopShort,1.2)
  42. +"n\c42    Period: \c55"
  43. +WriteVal(Pd,1.0)
  44. +"\c42    AvgUpPen: \c55"
  45. +WriteVal(AvgUpPen,1.2)
  46. +"\c42    Multiplier: \c55"
  47. +WriteVal(AvgUpPenMult,1.1)
  48. +"\c42    Days in trade (inclusive): \c55"
  49. +WriteVal(DaysInTrade,1.0);
  50.