PineCoders

BS2

Sep 24th, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 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. // © racer8
  3. //@version=4
  4. study("BS2",precision=2)
  5. i_p = input(36, minval = 2)
  6.  
  7. a = array.new_float(i_p)
  8. b = array.new_float(i_p)
  9. c = array.new_float(i_p)
  10.  
  11. array.set(a, 0, close - low)
  12. for _i = 1 to i_p - 1
  13. array.set(a, _i, high[_i] <= close ? tr[_i] : 0)
  14.  
  15. array.set(b, 0, close - high)
  16. for _i = 1 to i_p - 1
  17. array.set(b, _i, low[_i] >= close ? - tr[_i] : 0)
  18.  
  19. for _i = 1 to i_p - 1
  20. array.set(c, _i, high[_i] > close ? (low[_i] < close ? (close - low[_i]) + (close - high[_i]) : 0) : 0)
  21.  
  22. a_sum = array.sum(a)
  23. b_sum = array.sum(b)
  24. c_sum = array.sum(c)
  25.  
  26. total_sum = a_sum+b_sum+c_sum
  27. nn = input(1,"Smoothing Length")
  28. ma = sma(total_sum,nn)
  29. co = ma>=0? color.lime:color.red
  30. plot(ma,color=co,style=plot.style_line,transp=0)
  31. bgcolor(co,transp=80)
  32. barcolor(co)
Add Comment
Please, Sign In to add comment