Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © racer8
- //@version=4
- study("BS2",precision=2)
- i_p = input(36, minval = 2)
- a = array.new_float(i_p)
- b = array.new_float(i_p)
- c = array.new_float(i_p)
- array.set(a, 0, close - low)
- for _i = 1 to i_p - 1
- array.set(a, _i, high[_i] <= close ? tr[_i] : 0)
- array.set(b, 0, close - high)
- for _i = 1 to i_p - 1
- array.set(b, _i, low[_i] >= close ? - tr[_i] : 0)
- for _i = 1 to i_p - 1
- array.set(c, _i, high[_i] > close ? (low[_i] < close ? (close - low[_i]) + (close - high[_i]) : 0) : 0)
- a_sum = array.sum(a)
- b_sum = array.sum(b)
- c_sum = array.sum(c)
- total_sum = a_sum+b_sum+c_sum
- nn = input(1,"Smoothing Length")
- ma = sma(total_sum,nn)
- co = ma>=0? color.lime:color.red
- plot(ma,color=co,style=plot.style_line,transp=0)
- bgcolor(co,transp=80)
- barcolor(co)
Add Comment
Please, Sign In to add comment