xmd79

hack2

Oct 2nd, 2021
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © DarkPoolTrading
  3. // Based on the Function Sine Wave Indicator by RicardoSantos
  4.  
  5. //@version=4
  6. study(title='Function Cosine Wave', precision=12)
  7.  
  8. method1 = input("Median", options=["EMA", "Median", "SMA"])
  9. length1 = input(5)
  10. mult1 = input(1, minval=0, maxval=1)
  11.  
  12. method2 = input("Median", options=["EMA", "Median", "SMA"])
  13. length2 = input(7)
  14. mult2 = input(1, minval=0, maxval=1)
  15.  
  16. method3 = input("Median", options=["EMA", "Median", "SMA"])
  17. length3 = input(9)
  18. mult3 = input(1, minval=0, maxval=1)
  19. //----
  20. Avg(x, length, method) =>
  21. sma_1 = sma(x, length)
  22. ema_1 = ema(x, length)
  23. percentile_linear_interpolation_1 = percentile_linear_interpolation(x, length, 50)
  24. method == "SMA" ? sma_1 :
  25. method == "EMA" ? ema_1 : percentile_linear_interpolation_1
  26. //----
  27. a1 = highest(length1) - max(close, open)
  28. b1 = min(close, open) - lowest(length1)
  29. c1 = max(close, open) + a1 * mult1
  30. d1 = min(close, open) - b1 * mult1
  31.  
  32. a2 = highest(length2) - max(close, open)
  33. b2 = min(close, open) - lowest(length2)
  34. c2 = max(close, open) + a2 * mult2
  35. d2 = min(close, open) - b2 * mult2
  36.  
  37. a3 = highest(length3) - max(close, open)
  38. b3 = min(close, open) - lowest(length3)
  39. c3 = max(close, open) + a3 * mult3
  40. d3 = min(close, open) - b3 * mult3
  41. //----
  42. e1 = Avg(c1, length1, method1)
  43. f1 = Avg(d1, length1, method1)
  44. g1 = 0
  45. cross_1 = cross(close, f1)
  46. g1 := cross(close, e1) ? 1 : cross_1 ? 0 : nz(g1[1])
  47.  
  48. e2 = Avg(c2, length2, method2)
  49. f2 = Avg(d2, length2, method2)
  50. g2 = 0
  51. cross_2 = cross(close, f2)
  52. g2 := cross(close, e2) ? 1 : cross_2 ? 0 : nz(g2[1])
  53.  
  54. e3 = Avg(c3, length3, method3)
  55. f3 = Avg(d3, length3, method3)
  56. g3 = 0
  57. cross_3 = cross(close, f3)
  58. g3 := cross(close, e3) ? 1 : cross_3 ? 0 : nz(g3[1])
  59. //---
  60. hilo1 = g1 * f1 + (1 - g1) * e1
  61. css1 = g1 == 1 ? color.green : color.red
  62. plot(hilo1, color=css1, style=plot.style_line, show_last=1, linewidth=1, transp=0, trackprice=true)
  63.  
  64. hilo2 = g2 * f2 + (1 - g2) * e2
  65. css2 = g2 == 1 ? color.green : color.red
  66. plot(hilo2, color=css2, style=plot.style_line, show_last=1, linewidth=1, transp=0, trackprice=true)
  67.  
  68. hilo3 = g3 * f3 + (1 - g3) * e3
  69. css3 = g3 == 1 ? color.green : color.red
  70. plot(hilo3, color=css3, style=plot.style_line, show_last=1, linewidth=1, transp=0, trackprice=true)
  71.  
  72.  
  73. //end of this part
  74.  
  75.  
  76.  
  77. wave_height = input(100)
  78. wave_duration = input(50)
  79. n = bar_index
  80.  
  81. f_cosine_wave(_wave_height, _wave_duration)=>
  82. _pi = 3.14159265359
  83. _w = 2 * _pi / _wave_duration
  84. _cosine_wave = _wave_height * sin((_w * n) + (_pi/2))
  85.  
  86. wave = f_cosine_wave(wave_height, wave_duration)
  87. wave2 = f_cosine_wave(wave_height, close)
  88. plot(series=wave, title='Normal', color=#FFFFFF)
  89. //plot(series=wave2, title='Price as cycle duration', color=#C9A0DC)
  90.  
  91. //end of this part
  92.  
  93.  
  94. //end of this part
  95.  
  96.  
  97. //@version=4
  98. //study(title="[RS]Compounded Risk Score", shorttitle="CRS")
  99. // if you took a trade for every bars close for the duration of the length
  100. // how would those trades fair atm?
  101. // values closer to (100 | -100) are better for its (bull | bear), closer to 0 will be closer to break eaven.
  102. // this indicator is optimal for trending markets.
  103.  
  104. length = input(100)
  105. avg_length = input(25)
  106.  
  107. f_compound_risk(_source, _length) =>
  108. _total = 0.0
  109. _absolute = 0.0
  110. for _i = 1 to _length by 1
  111. _container0 = _total
  112. _container1 = _absolute
  113. _total := _container0 + _source[0] - _source[_i]
  114. _absolute := _container1 + abs(_source[0] - _source[_i])
  115. _absolute
  116. if _total > 0
  117. _container = _total
  118. _total := _total / _absolute
  119. _total
  120. else
  121. _container = _total
  122. _total := 0 - abs(_container) / _absolute
  123. _total
  124. _total * 100
  125.  
  126. //inp = input(close)
  127.  
  128. cr = f_compound_risk(wave, length)
  129. ma = ema(cr, avg_length)
  130.  
  131. plot(series=cr, color=color.black, transp=0)
  132. plot(series=ma, color=color.navy, transp=0)
  133. hline(100)
  134. hline(50)
  135. hline(0)
  136. hline(-50)
  137. hline(-100)
  138.  
Advertisement
Add Comment
Please, Sign In to add comment