커뮤니티

문의 드립니다.

프로필 이미지
신대륙발견
2024-09-11 12:44:41
831
글번호 183378
답변완료
study(shorttitle="BB Filter", title="Bollinger Bands Filter", overlay=true, resolution="") src = input(close, title = "Source") length = input(55, minval=1, title = "SMA length")// 20 for classis Bollinger Bands SMA line (basis) mult = input(1., minval=0.236, maxval=2, title="Standard Deviation")//2 for Classic Bollinger Bands //Maxval = 2 as higher the deviation, higher the risk basis = sma(src, length) dev = mult * stdev(src,length) CC = input(true, "Color Bars") upper = basis + dev lower = basis - dev //Conditions for Long and Short - Extra filter condition can be used such as RSI or CCI etc. short = src<lower// and rsi(close,14)<40 long = src>upper// and rsi(close,14)>60 L1 = barssince(long) S1 = barssince(short) longSignal = L1<S1 and not (L1<S1)[1] shortSignal = S1<L1 and not (S1<L1)[1] //Plots and Fills ////Long/Short shapes with text // plotshape(S1<L1 and not (S1<L1)[1]?close:na, text = "s&#7431;&#671;&#671;", textcolor=#ff0100, color=#ff0100, style=shape.triangledown, size=size.small, location=location.abovebar, transp=0, title = "SELL", editable = true) // plotshape(L1<S1 and not (L1<S1)[1]?close:na, text = "&#665;&#7452;&#655;", textcolor = #008000, color=#008000, style=shape.triangleup, size=size.small, location=location.belowbar, transp=0, title = "BUY", editable = true) plotshape(shortSignal?close:na, color=#ff0100, style=shape.triangledown, size=size.small, location=location.abovebar, transp=0, title = "Short Signal", editable = true) plotshape(longSignal?close:na, color=#008000, style=shape.triangleup, size=size.small, location=location.belowbar, transp=0, title = "Long Signal", editable = true) p1 = plot(upper, color=#ff0000, display=display.all, transp=75, title = "Upper Band") p2 = plot(lower, color=#008000, display=display.all, transp=75, title = "Lower Band") p = plot(basis, color=L1<S1?#008000:S1<L1?#ff0000:na, linewidth=2, editable=false, title="Basis") fill(p,p1, color=color.teal, transp=85, title = "Top Fill") //fill for basis-upper fill(p,p2, color=color.orange, transp=85, title = "Bottom Fill")//fill for basis-lower //Barcolor bcol = src>upper?color.new(#8ceb07,0): src<lower?color.new(#ff0000,0): src>basis?color.green: src<basis?color.red:na barcolor(CC?bcol:na, editable=false, title = "Color Bars") //Alerts ---- // Use 'Once per bar close' alertcondition(condition=longSignal, title="Long - BB Filter", message='BB Filter Long @ {{close}}') // Use 'Once per bar close' alertcondition(condition=shortSignal, title="Short - BB Filter", message='BB Filter Short @ {{close}}') // Use 'Once per bar close' 트레이딩뷰 지표인데 예스 수식으로 좀 바꿔주세요.
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2024-09-12 13:32:31

안녕하세요 예스스탁입니다. input : length(55); input : mult(1); var : src(0),basis(0),dev(0),upper(0),lower(0); var : short(False),long(False),L1(-1),S1(-1); var : longSignal(False),shortSignal(False),tx(0); src = close; basis = ma(src, length); dev = mult * std(src,length); upper = basis + dev; lower = basis - dev; short = src<lower; long = src>upper; if long == true then L1 = 0; Else { if L1 >= 0 Then L1 = L1+1; } if short == true then S1 = 0; Else { if S1 >= 0 Then S1 = S1+1; } longSignal = L1<S1 and !(L1[1]<S1[1]); shortSignal = S1<L1 and !(S1[1]<L1[1]); plot1(upper,"Upper Band"); plot2(lower,"Lower Band"); plot3(basis,"Basis"); if longSignal == true Then { tx = Text_New(sDate,sTime,L,"▲"); Text_SetStyle(tx,2,0); Text_SetColor(tx,Red); } if ShortSignal == true Then { tx = Text_New(sDate,sTime,H,"▼"); Text_SetStyle(tx,2,1); Text_SetColor(tx,Blue); } 풍성한 한가위되시길 바랍니다. > 신대륙발견 님이 쓴 글입니다. > 제목 : 문의 드립니다. > study(shorttitle="BB Filter", title="Bollinger Bands Filter", overlay=true, resolution="") src = input(close, title = "Source") length = input(55, minval=1, title = "SMA length")// 20 for classis Bollinger Bands SMA line (basis) mult = input(1., minval=0.236, maxval=2, title="Standard Deviation")//2 for Classic Bollinger Bands //Maxval = 2 as higher the deviation, higher the risk basis = sma(src, length) dev = mult * stdev(src,length) CC = input(true, "Color Bars") upper = basis + dev lower = basis - dev //Conditions for Long and Short - Extra filter condition can be used such as RSI or CCI etc. short = src<lower// and rsi(close,14)<40 long = src>upper// and rsi(close,14)>60 L1 = barssince(long) S1 = barssince(short) longSignal = L1<S1 and not (L1<S1)[1] shortSignal = S1<L1 and not (S1<L1)[1] //Plots and Fills ////Long/Short shapes with text // plotshape(S1<L1 and not (S1<L1)[1]?close:na, text = "s&#7431;&#671;&#671;", textcolor=#ff0100, color=#ff0100, style=shape.triangledown, size=size.small, location=location.abovebar, transp=0, title = "SELL", editable = true) // plotshape(L1<S1 and not (L1<S1)[1]?close:na, text = "&#665;&#7452;&#655;", textcolor = #008000, color=#008000, style=shape.triangleup, size=size.small, location=location.belowbar, transp=0, title = "BUY", editable = true) plotshape(shortSignal?close:na, color=#ff0100, style=shape.triangledown, size=size.small, location=location.abovebar, transp=0, title = "Short Signal", editable = true) plotshape(longSignal?close:na, color=#008000, style=shape.triangleup, size=size.small, location=location.belowbar, transp=0, title = "Long Signal", editable = true) p1 = plot(upper, color=#ff0000, display=display.all, transp=75, title = "Upper Band") p2 = plot(lower, color=#008000, display=display.all, transp=75, title = "Lower Band") p = plot(basis, color=L1<S1?#008000:S1<L1?#ff0000:na, linewidth=2, editable=false, title="Basis") fill(p,p1, color=color.teal, transp=85, title = "Top Fill") //fill for basis-upper fill(p,p2, color=color.orange, transp=85, title = "Bottom Fill")//fill for basis-lower //Barcolor bcol = src>upper?color.new(#8ceb07,0): src<lower?color.new(#ff0000,0): src>basis?color.green: src<basis?color.red:na barcolor(CC?bcol:na, editable=false, title = "Color Bars") //Alerts ---- // Use 'Once per bar close' alertcondition(condition=longSignal, title="Long - BB Filter", message='BB Filter Long @ {{close}}') // Use 'Once per bar close' alertcondition(condition=shortSignal, title="Short - BB Filter", message='BB Filter Short @ {{close}}') // Use 'Once per bar close' 트레이딩뷰 지표인데 예스 수식으로 좀 바꿔주세요.