xmd79

cas3

Apr 29th, 2021
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. //@version=4
  2. study(title="[RS]Compounded Risk Score", shorttitle="CRS")
  3. // if you took a trade for every bars close for the duration of the length
  4. // how would those trades fair atm?
  5. // values closer to (100 | -100) are better for its (bull | bear), closer to 0 will be closer to break eaven.
  6. // this indicator is optimal for trending markets.
  7.  
  8. length = input(100)
  9. avg_length = input(25)
  10.  
  11. f_compound_risk(_source, _length) =>
  12. _total = 0.0
  13. _absolute = 0.0
  14. for _i = 1 to _length by 1
  15. _container0 = _total
  16. _container1 = _absolute
  17. _total := _container0 + _source[0] - _source[_i]
  18. _absolute := _container1 + abs(_source[0] - _source[_i])
  19. _absolute
  20. if _total > 0
  21. _container = _total
  22. _total := _total / _absolute
  23. _total
  24. else
  25. _container = _total
  26. _total := 0 - abs(_container) / _absolute
  27. _total
  28. _total * 100
  29.  
  30. cr = f_compound_risk(close, length)
  31. ma = ema(cr, avg_length)
  32.  
  33. plot(series=cr, color=color.black, transp=0)
  34. plot(series=ma, color=color.navy, transp=0)
  35. hline(100)
  36. hline(50)
  37. hline(0)
  38. hline(-50)
  39. hline(-100)
  40.  
  41.  
  42. //end of this part
  43.  
  44. //@version=4
  45. //study(title="CMO(HMA)", overlay=false)
  46.  
  47. nHMA = input(title="HMA period", type=input.integer, defval=7)
  48.  
  49. HMA = wma(2 * wma(close, round(nHMA / 2)) - wma(close, nHMA), round(sqrt(nHMA)))
  50.  
  51.  
  52. // Use algorithm from the following website
  53. // http://www.technicalindicators.net/indicators-technical-analysis/144-cmo-chande-momentum-oscillator
  54.  
  55. CMO1 = iff(HMA[0] > HMA[1], HMA[0] - HMA[1], 0.0)
  56. CMO2 = iff(HMA[0] < HMA[1], HMA[1] - HMA[0], 0.0)
  57.  
  58. CMO = iff(CMO1 == 0.0 and CMO2 == 0.0, 0.0 * (CMO1 - CMO2), 100 * ((CMO1 - CMO2) / (CMO1 + CMO2)))
  59.  
  60. plot(CMO, "CMO(HMA)", linewidth=3, color=color.teal)
  61.  
  62.  
Advertisement
Add Comment
Please, Sign In to add comment