balance of power (571).afl
上传用户:shiqiang
上传日期:2009-06-12
资源大小:1289k
文件大小:2k
源码类别:

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    balance of power
  4. //  Author/Uploader: abdula 
  5. //  E-mail:          izare2004@yahoo.com
  6. //  Date/Time Added: 2005-11-18 10:36:43
  7. //  Origin:          
  8. //  Keywords:        
  9. //  Level:           basic
  10. //  Flags:           indicator
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=571
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=571
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  54
  17. //
  18. //------------------------------------------------------------------------------
  19. // Balance of Power
  20. // Example code can be found at:
  21. // http://www.traders.com/Documentation/FEEDbk_docs/Archive/082001/TradersTips/TradersTips.html 
  22. //----- This prevents a bad data point from generating a divide by zero.
  23. THL = IIf(H != L, H - L, 0.01);
  24. //----- Reward based on Open
  25. BullOpen = (H - O)/THL;
  26. BearOpen = (O - L)/THL;
  27. //----- Reward based on Close
  28. BullClose = (C - L)/THL;
  29. BearClose = (H - C)/THL;
  30. //----- Reward based on Open - Close
  31. BullOC =IIf(C > O, (C - O)/THL, 0);
  32. BearOC =IIf(O > C, (O - C)/THL, 0);
  33. BullReward = (BullOpen + BullClose + BullOC)/3;
  34. BearReward = (BearOpen + BearClose + BearOC)/3;
  35. BOP = BullReward - BearReward;
  36. Period1 = 34;
  37. SmoothBOP = EMA(BOP, Period1);
  38. Period2 = 34;
  39. SmootherBOP = TEMA(SmoothBOP, Period2);
  40. //Plot(BOP, "BOP", colorBlack, 1);
  41. Plot(SmoothBOP, "BOP " + Period1, colorLightBlue, 1);
  42. Plot(SmootherBOP, "", colorRed);
  43. Plot(Ref(SmootherBOP, -2), "", colorBlue);
  44. Plot(0.1, "", colorGreen);
  45. Plot(0, "", colorBlack);
  46. Plot(-0.1, "", colorGreen);