커뮤니티

문의 드립니다.

프로필 이미지
신대륙발견
2025-08-21 19:41:40
91
글번호 193420
답변완료
// --- settings ATRperiod = input.int(defval=13, title='ATR Period', minval=1) BBperiod = input.int(defval=6, title='Bollinger Bands Period', minval=1) BBdeviation = input.float(defval=5.00, title='Bollinger Bands Deviation', minval=0.1, step=0.1) UseATRfilter = input(defval=true, title='ATR Filter On/Off') // false = 0, true = 1 showsignals = input(title='Show Signals ', defval=true) // --- end of settings // Bollinger Bands calculation BBUpper = ta.sma(close, BBperiod) + ta.stdev(close, BBperiod) * BBdeviation BBLower = ta.sma(close, BBperiod) - ta.stdev(close, BBperiod) * BBdeviation // ATR calculation atrValue = ta.atr(ATRperiod) // Signal initialization var float FollowLine = na var int BBSignal = 0 // Determine BB signal if (close > BBUpper) BBSignal := 1 else if (close < BBLower) BBSignal := -1 // Buy signal logic if (BBSignal == 1) if (UseATRfilter) FollowLine := low - atrValue else FollowLine := low if (FollowLine < nz(FollowLine[1])) FollowLine := nz(FollowLine[1]) // Sell signal logic if (BBSignal == -1) if (UseATRfilter) FollowLine := high + atrValue else FollowLine := high if (FollowLine > nz(FollowLine[1])) FollowLine := nz(FollowLine[1]) // Trend direction determination var int iTrend = 0 if (nz(FollowLine) > nz(FollowLine[1])) iTrend := 1 else if (nz(FollowLine) < nz(FollowLine[1])) iTrend := -1 // Trend line color based on trend direction lineColor = iTrend > 0 ? color.rgb(9, 98, 232) : color.new(color.rgb(220, 20, 60), 0) //buy & sell conditions buy=0.0 sell=0.0 buy:=iTrend[1]==-1 and iTrend==1 ? 1 : na sell:=iTrend[1]==1 and iTrend==-1? 1 : na //alerts alertcondition(sell == 1 ,title="Sell",message="Follow Line Sell") alertcondition(buy == 1 ,title="Buy",message="Follow Line Buy") alertcondition(buy == 1 or sell == 1 ,title="Signal",message="Follow Line Signal") // Plot the trend line and signals plot(FollowLine, color=lineColor, linewidth=2, title="Follow Line") plotshape(buy == 1 and showsignals ? FollowLine-atrValue :na, text='BUY', style= shape.labelup, location=location.absolute, color=color.blue, textcolor=color.white, offset=0, transp=0,size=size.auto) plotshape(sell == 1 and showsignals ? FollowLine+atrValue:na, text='SELL', style=shape.labeldown, location=location.absolute, color=color.rgb(102, 15, 15), textcolor=color.white, offset=0, transp=0,size=size.auto) 트레이딩뷰 수식입니다. 위 수식을 예스 지표로 만들어주시고 신호검색 수식도 만들어주세요.
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-08-22 10:00:27

안녕하세요 예스스탁입니다. 1 input : ATRperiod(13); input : BBperiod(6); input : BBdeviation(2.00); input : UseATRfilter(true); input : showsignals(true); var : BBupper(0),BBlower(0),alpha(0),atrValue(0); var : FollowLine(Nan),BBSignal(0),iTrend(0); BBUpper = ma(close, BBperiod) + std(close, BBperiod) * BBdeviation; BBLower = ma(close, BBperiod) - std(close, BBperiod) * BBdeviation; alpha = 1 / ATRperiod ; atrValue = IFf(IsNan(atrValue[1]) == true, ma(TrueRange,ATRperiod) , alpha * TrueRange + (1 - alpha) * IFf(isnan(atrValue[1])==true,0,atrValue[1])); if (close > BBUpper) Then BBSignal = 1; else if (close < BBLower) Then BBSignal = -1; if (BBSignal == 1) Then { if (UseATRfilter) Then { FollowLine = low - atrValue; } else { FollowLine = low; } if (FollowLine < iff(IsNan(FollowLine[1])==true,0,FollowLine[1])) Then { FollowLine = iff(IsNan(FollowLine[1])==true,0,FollowLine[1]); } } if (BBSignal == -1) Then { if (UseATRfilter) Then { FollowLine = high + atrValue; } else { FollowLine = high; } if (FollowLine > iff(IsNan(FollowLine[1])==true,0,FollowLine[1])) Then { FollowLine = iff(IsNan(FollowLine[1])==true,0,FollowLine[1]); } } if iff(IsNan(FollowLine)==true,0,FollowLine) > iff(IsNan(FollowLine[1])==true,0,FollowLine[1]) Then iTrend = 1; else if iff(IsNan(FollowLine)==true,0,FollowLine) < iff(IsNan(FollowLine[1])==true,0,FollowLine[1]) Then iTrend = -1; var : lineColor(0),B(0),S(0),tx(0); lineColor = iff(iTrend > 0 , rgb(9, 98, 232) , rgb(220, 20, 60)); b = iff(iTrend[1]==-1 and iTrend==1 , 1 , 0); s = iff(iTrend[1]==1 and iTrend==-1 , 1 , 0); plot1(FollowLine, "Follow Line", lineColor); if B == 1 and showsignals Then { tx = text_new(sDate,stime,L,"▲"); Text_SetColor(tx,Red); Text_SetStyle(tx,2,0); } if S == 1 and showsignals Then { tx = text_new(sDate,stime,H,"▼"); Text_SetColor(tx,Blue); Text_SetStyle(tx,2,1); } 2 input : ATRperiod(13); input : BBperiod(6); input : BBdeviation(2.00); input : UseATRfilter(true); input : showsignals(true); var : BBupper(0),BBlower(0),alpha(0),atrValue(0); var : FollowLine(Nan),BBSignal(0),iTrend(0); BBUpper = ma(close, BBperiod) + std(close, BBperiod) * BBdeviation; BBLower = ma(close, BBperiod) - std(close, BBperiod) * BBdeviation; alpha = 1 / ATRperiod ; atrValue = IFf(IsNan(atrValue[1]) == true, ma(TrueRange,ATRperiod) , alpha * TrueRange + (1 - alpha) * IFf(isnan(atrValue[1])==true,0,atrValue[1])); if (close > BBUpper) Then BBSignal = 1; else if (close < BBLower) Then BBSignal = -1; if (BBSignal == 1) Then { if (UseATRfilter) Then { FollowLine = low - atrValue; } else { FollowLine = low; } if (FollowLine < iff(IsNan(FollowLine[1])==true,0,FollowLine[1])) Then { FollowLine = iff(IsNan(FollowLine[1])==true,0,FollowLine[1]); } } if (BBSignal == -1) Then { if (UseATRfilter) Then { FollowLine = high + atrValue; } else { FollowLine = high; } if (FollowLine > iff(IsNan(FollowLine[1])==true,0,FollowLine[1])) Then { FollowLine = iff(IsNan(FollowLine[1])==true,0,FollowLine[1]); } } if iff(IsNan(FollowLine)==true,0,FollowLine) > iff(IsNan(FollowLine[1])==true,0,FollowLine[1]) Then iTrend = 1; else if iff(IsNan(FollowLine)==true,0,FollowLine) < iff(IsNan(FollowLine[1])==true,0,FollowLine[1]) Then iTrend = -1; var : lineColor(0),B(0),S(0),tx(0); lineColor = iff(iTrend > 0 , rgb(9, 98, 232) , rgb(220, 20, 60)); b = iff(iTrend[1]==-1 and iTrend==1 , 1 , 0); s = iff(iTrend[1]==1 and iTrend==-1 , 1 , 0); if B == 1 and showsignals Then { Buy("B"); } if S == 1 and showsignals Then { Sell("S"); } 즐거운 하루되세요 > 신대륙발견 님이 쓴 글입니다. > 제목 : 문의 드립니다. > // --- settings ATRperiod = input.int(defval=13, title='ATR Period', minval=1) BBperiod = input.int(defval=6, title='Bollinger Bands Period', minval=1) BBdeviation = input.float(defval=5.00, title='Bollinger Bands Deviation', minval=0.1, step=0.1) UseATRfilter = input(defval=true, title='ATR Filter On/Off') // false = 0, true = 1 showsignals = input(title='Show Signals ', defval=true) // --- end of settings // Bollinger Bands calculation BBUpper = ta.sma(close, BBperiod) + ta.stdev(close, BBperiod) * BBdeviation BBLower = ta.sma(close, BBperiod) - ta.stdev(close, BBperiod) * BBdeviation // ATR calculation atrValue = ta.atr(ATRperiod) // Signal initialization var float FollowLine = na var int BBSignal = 0 // Determine BB signal if (close > BBUpper) BBSignal := 1 else if (close < BBLower) BBSignal := -1 // Buy signal logic if (BBSignal == 1) if (UseATRfilter) FollowLine := low - atrValue else FollowLine := low if (FollowLine < nz(FollowLine[1])) FollowLine := nz(FollowLine[1]) // Sell signal logic if (BBSignal == -1) if (UseATRfilter) FollowLine := high + atrValue else FollowLine := high if (FollowLine > nz(FollowLine[1])) FollowLine := nz(FollowLine[1]) // Trend direction determination var int iTrend = 0 if (nz(FollowLine) > nz(FollowLine[1])) iTrend := 1 else if (nz(FollowLine) < nz(FollowLine[1])) iTrend := -1 // Trend line color based on trend direction lineColor = iTrend > 0 ? color.rgb(9, 98, 232) : color.new(color.rgb(220, 20, 60), 0) //buy & sell conditions buy=0.0 sell=0.0 buy:=iTrend[1]==-1 and iTrend==1 ? 1 : na sell:=iTrend[1]==1 and iTrend==-1? 1 : na //alerts alertcondition(sell == 1 ,title="Sell",message="Follow Line Sell") alertcondition(buy == 1 ,title="Buy",message="Follow Line Buy") alertcondition(buy == 1 or sell == 1 ,title="Signal",message="Follow Line Signal") // Plot the trend line and signals plot(FollowLine, color=lineColor, linewidth=2, title="Follow Line") plotshape(buy == 1 and showsignals ? FollowLine-atrValue :na, text='BUY', style= shape.labelup, location=location.absolute, color=color.blue, textcolor=color.white, offset=0, transp=0,size=size.auto) plotshape(sell == 1 and showsignals ? FollowLine+atrValue:na, text='SELL', style=shape.labeldown, location=location.absolute, color=color.rgb(102, 15, 15), textcolor=color.white, offset=0, transp=0,size=size.auto) 트레이딩뷰 수식입니다. 위 수식을 예스 지표로 만들어주시고 신호검색 수식도 만들어주세요.