커뮤니티

슈퍼트렌드

프로필 이미지
고성
2026-09-22 08:01:29
37
글번호 233707
답변완료

트레이딩뷰 수식입니다. 상승트렌드는 주가 상단선과, 하락트렌드는 주가 하단선과의

채우기 기능을,각각 분리하여 볼 수 있도록 변환 부탁드립니다.


atrPeriod = input.int(10,    "ATR Length", minval = 1)

factor =    input.float(3.0, "Factor",     minval = 0.01, step = 0.01)

[supertrend, direction] = ta.supertrend(factor, atrPeriod)


supertrend := barstate.isfirst ? na : supertrend

upTrend =    plot(direction < 0 ? supertrend : na, "Up Trend",   color = color.green, style = plot.style_linebr)

downTrend =  plot(direction < 0 ? na : supertrend, "Down Trend", color = color.red,   style = plot.style_linebr)

bodyMiddle = plot(barstate.isfirst ? na : (open + close) / 2, "Body Middle",display = display.none)

fill(bodyMiddle, upTrend,   title = "Uptrend background",   color = color.new(color.green, 90), fillgaps = false)

fill(bodyMiddle, downTrend, title = "Downtrend background", color = color.new(color.red,   90), fillgaps = false)

alertcondition(direction[1] > direction, title='Downtrend to Uptrend', message='The Supertrend value switched from Downtrend to Uptrend ')

alertcondition(direction[1] < direction, title='Uptrend to Downtrend', message='The Supertrend value switched from Uptrend to Downtrend')

alertcondition(direction[1] != direction, title='Trend Change', message='The Supertrend value switched from Uptrend to Downtrend or vice versa')


지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2026-09-22 13:16:47

안녕하세요 예스스탁입니다. 채우기는 수식안에서 설정이 가능하지 않습니다. 지표속성창의 차트표시탭에서 채우기 기능을 이용해 직접 설정하셔야 합니다. input : atrperiod(10),factor (3.0); var : src(0), alpha(0),ATRV(0),upperBand(0),lowerBand(0),direction(0),SuperTrend(C); if CurrentBar > 1 Then { src = (H+L)/2; alpha = 1 / atrperiod ; ATRV = IFf(IsNan(ATRV[1]) == true, ma(TrueRange,atrperiod) , alpha * TrueRange + (1 - alpha) * IFf(isnan(ATRV[1])==true,0,ATRV[1])); upperBand = src + factor * AtrV; lowerBand = src - factor * AtrV; if lowerBand > lowerBand[1] or close[1] < lowerBand[1] Then lowerBand = lowerBand; Else lowerBand = lowerBand[1]; if upperBand < upperBand[1] or close[1] > upperBand[1] Then upperBand = upperBand; Else upperBand = upperBand[1]; if C > UpperBand Then direction = 1; if C < LowerBand Then direction = -1; if direction == 1 Then SuperTrend = lowerband; Else SuperTrend = upperband; } if direction < 0 Then { plot1(supertrend,"Up Trend",red); NoPlot(2); } Else { NoPlot(1); plot2(supertrend,"Down Trend",blue); } plot3((open + close) / 2, "Body Middle"); 즐거운 하루되세요