Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=3
- study(shorttitle="BBm", title='overlay', overlay=true)
- ma_type = input(defval='SMA', type=string, options=['SMA', 'Double SMA', 'Triple SMA', 'EMA', 'Double EMA', 'Triple EMA', 'HMA'])
- ma_src = input(close)
- ma_01_length = input(20)
- //sma_02_length = input(200)
- fractal_size = input(2)
- f_ma(_type, _src, _length)=>
- _ma = 0.0
- if _type == 'SMA'
- _ma := sma(_src, _length)
- if _type == 'Double SMA'
- _ma := sma(sma(_src, _length), _length)
- if _type == 'Triple SMA'
- _ma := sma(sma(sma(_src, _length), _length), _length)
- if _type == 'EMA'
- _ma := ema(_src, _length)
- if _type == 'Double EMA'
- _ma := ema(ema(_src, _length), _length)
- if _type == 'Triple EMA'
- _ma := ema(ema(ema(_src, _length), _length), _length)
- _return = _ma
- ma_01 = f_ma(ma_type, ma_src, ma_01_length)
- //sma_02 = sma(sma_src, sma_02_length)
- //-------------------------------------------
- sleeve_ma_type = input(defval='SMA', type=string, options=['SMA', 'Double SMA', 'Triple SMA', 'EMA', 'Double EMA', 'Triple EMA', 'HMA'])
- sleeve_src = input(close)
- sleeve_01_length = input(5)
- sleeve_02_length = input(10)
- sleeve_01 = f_ma(sleeve_ma_type, sleeve_src, sleeve_01_length)
- sleeve_02 = f_ma(sleeve_ma_type, sleeve_src, sleeve_02_length)
- //--------------------------------------------
- atr_length = input(100)
- atr = atr(atr_length)
- atr_deviation = atr * input(2.618)
- atr_smoothing_length = input(1)
- f_atr_stop(_deviation, _length)=>
- _stop = close
- _stop := nz(_stop[1], close)
- if close > _stop
- _stop := max(_stop, close - _deviation)
- if close < _stop
- _stop := min(_stop, close + _deviation)
- _return = ema(_stop, _length)
- stop = f_atr_stop(atr_deviation, atr_smoothing_length)
- up_1 = stop + atr_deviation + (atr * 0)
- do_1 = stop - atr_deviation - (atr * 0)
- //--------------------------------------------
- h = pivothigh(high, fractal_size, fractal_size)
- l = pivotlow(low, fractal_size, fractal_size)
- //--------------------------------------------
- plotcandle(high, high, low, high, title='Candles', color=black, show_last=2)
- plotcandle(low, high, low, low, title='Candles', color=black, show_last=2)
- plot(series=stop, title='ATR AVG', color=black)
- plot(series=up_1, title='ATR Upper', color=black, transp=0)
- plot(series=do_1, title='ATR Lower', color=black, transp=0)
- plot(series=h, title='H', color=black, linewidth=2, style=cross, transp=0, offset=-fractal_size)
- plot(series=l, title='L', color=black, linewidth=2, style=cross, transp=0, offset=-fractal_size)
- //plotshape(series=h, title='H', style=shape.triangleup, location=location.absolute, color=black, transp=0, offset=-fractal_size)
- //plotshape(series=l, title='L', style=shape.triangledown, location=location.absolute, color=black, transp=0, offset=-fractal_size)
- ma_color = ma_src > ma_01 ? #2d862d : #993333
- m1 = plot(series=ma_01, title='SMA 1', color=ma_color, linewidth=2, transp=0)
- //m2 = plot(series=sma_02, title='SMA 2', color=navy, linewidth=2, transp=0)
- s0 = plot(series=sleeve_src, title='S', color=black, transp=0)
- plot(series=sleeve_src[1], title='S', color=black, style=circles, linewidth=1, transp=0, show_last=1)
- plot(series=sleeve_src, title='S', color=black, style=circles, linewidth=2, transp=0, show_last=1)
- s1 = plot(series=sleeve_01, title='S', color=black, transp=60)
- s2 = plot(series=sleeve_02, title='S', color=black, transp=80)
- fill(plot1=m1, plot2=s2, color=sleeve_02 > ma_01 ? #ffffe6 : #e6e6ff, transp=50, title='Sleeve')
- fill(plot1=s0, plot2=s2, color=#bfbfbf, transp=50, title='Sleeve')
- fill(plot1=s0, plot2=s1, color=#999999, transp=50, title='Sleeve')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement