커뮤니티

문의드립니다.

프로필 이미지
해암
2025-05-21 19:58:31
269
글번호 191045
답변완료

첨부 이미지

아래의 트레이딩뷰 수식을 변환부탁드립니다. =========================== // Settings - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - supertrendAtrPeriod &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;=input.int (defval =10 ,step =1 ,title ="ATR Length",group ="Supertrend") supertrendAtrMultiplier &#160;&#160;&#160;&#160;&#160;&#160;=input.float (defval =2.7 ,step =0.1 ,title ="ATR Multiplier",group ="Supertrend") // &#160;Heikin Ashi Candles haOpen =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,open ) haHigh =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,high ) haLow =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,low ) haClose =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,close ) plotcandle (haOpen <haClose ?haOpen :na ,haHigh ,haLow ,haClose ,title ='Green Candles',color =green ,wickcolor =green ,bordercolor =green ,display =display.pane ) plotcandle (haOpen >=haClose ?haOpen :na ,haHigh ,haLow ,haClose ,title ='Red Candles',color =red ,wickcolor =red ,bordercolor =red ,display =display.pane ) plot (display =display.status_line ,series =haOpen ,color =green ) plot (display =display.status_line ,series =haHigh ,color =green ) plot (display =display.status_line ,series =haLow ,color =red ) plot (display =display.status_line ,series =haClose ,color =red ) // &#160;HA Supertrend haTrueRange =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,ta.atr (supertrendAtrPeriod ))// math.max(haHigh - haLow, math.abs(haHigh - haClose[1]), math.abs(haLow - haClose[1])) haSupertrendUp =((haHigh +haLow )/2 )-(supertrendAtrMultiplier *haTrueRange ) haSupertrendDown =((haHigh +haLow )/2 )+(supertrendAtrMultiplier *haTrueRange ) float trendingUp =na float trendingDown =na direction =0 trendingUp :=haClose [1 ]>trendingUp [1 ]?math.max (haSupertrendUp ,trendingUp [1 ]):haSupertrendUp trendingDown :=haClose [1 ]<trendingDown [1 ]?math.min (haSupertrendDown ,trendingDown [1 ]):haSupertrendDown direction :=haClose >trendingDown [1 ]?1 :haClose <trendingUp [1 ]?-1 :nz (direction [1 ],1 ) supertrend =direction ==1 ?trendingUp :trendingDown supertrendUp =ta.change (direction )<0 supertrendDown =ta.change (direction )>0 // &#160;Plots, Lines, and Labels bodyMiddle =plot ((haOpen +haClose )/2 ,display =display.none ) downTrend =plot (direction <0 ?supertrend :na ,"Down Trend",color =red ,style =plot.style_linebr ) upTrend =plot (direction <0 ?na :supertrend ,"Up Trend",color =green ,style =plot.style_linebr ) fill (bodyMiddle ,upTrend ,lightGreen ,fillgaps =false ) fill (bodyMiddle ,downTrend ,lightRed ,fillgaps =false ) ========================= 첨부된 그림처럼 빨강선과 녹색선을 표현하고자 합니다. atr길이와 atr배수을 변경할수 있게 부탁드립니다. 수식이 길어서 전략은 삭제하고 라인만 나타나보이게 올렸으니 감안하여 부족한 부분이 있다면 보완해주셔서 변환해주시면 더욱 감사하겠습니다. 오늘도 감사합니다. 수고하세요!!!
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-05-22 09:25:06

안녕하세요 예스스탁입니다. input : upertrendAtrPeriod(10); input : supertrendAtrMultiplier(2.7); var : haClose(0),haOpen(0),haHigh(0),haLow(0),haTR(0),alpha(0),haTrueRange(0); var : haSupertrendUp(0),haSupertrendDown(0),trendingUp(Nan),trendingDown(Nan); var : direction(0),supertrend(0),supertrendUp(False),supertrendDown(False); if index == 0 then { haClose = (O+H+L+C)/4; haOpen = open; haHigh = MaxList( high, haOpen, haClose); haLow = MinList( low, haOpen,haClose); } else { haClose = (O+H+L+C)/4; haOpen = (haOpen [1] + haClose [1])/2 ; haHigh = MaxList(High, haOpen, haClose) ; haLow = MinList(Low, haOpen, haClose) ; } haTR = iff(IsNan(haOpen[1]) == true, haOpen-haLow, max(max(haOpen - haLow, abs(haOpen - haClose[1])), abs(haLow - haClose[1]))); alpha = 1 / upertrendAtrPeriod ; haTrueRange = IFf(IsNan(haTrueRange[1]) == true, ma(haTR,upertrendAtrPeriod) , alpha * haTR + (1 - alpha) * IFf(isnan(haTrueRange[1])==true,0,haTrueRange[1])); haSupertrendUp =((haHigh +haLow )/2 )-(supertrendAtrMultiplier *haTrueRange ); haSupertrendDown =((haHigh +haLow )/2 )+(supertrendAtrMultiplier *haTrueRange ); direction = 0; trendingUp = iff(haClose[1]>trendingUp[1] , max (haSupertrendUp ,trendingUp[1]) , haSupertrendUp); trendingDown = iff(haClose[1]<trendingDown[1] , min (haSupertrendDown ,trendingDown[1]) , haSupertrendDown); direction = iff(haClose > trendingDown[1] , 1 , iff(haClose < trendingUp[1], -1 , IFf(IsNan(direction[1]) == true,1,direction[1]))); supertrend = iff(direction == 1 , trendingUp , trendingDown); if direction == 1 Then { plot1(supertrend,"supertrendUp", Green); NoPlot(2); } Else { plot2(supertrend,"supertrendDow", Red); NoPlot(1); } 즐거운 하루되세요 > 해암 님이 쓴 글입니다. > 제목 : 문의드립니다. > 아래의 트레이딩뷰 수식을 변환부탁드립니다. =========================== // Settings - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - supertrendAtrPeriod &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;=input.int (defval =10 ,step =1 ,title ="ATR Length",group ="Supertrend") supertrendAtrMultiplier &#160;&#160;&#160;&#160;&#160;&#160;=input.float (defval =2.7 ,step =0.1 ,title ="ATR Multiplier",group ="Supertrend") // &#160;Heikin Ashi Candles haOpen =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,open ) haHigh =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,high ) haLow =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,low ) haClose =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,close ) plotcandle (haOpen <haClose ?haOpen :na ,haHigh ,haLow ,haClose ,title ='Green Candles',color =green ,wickcolor =green ,bordercolor =green ,display =display.pane ) plotcandle (haOpen >=haClose ?haOpen :na ,haHigh ,haLow ,haClose ,title ='Red Candles',color =red ,wickcolor =red ,bordercolor =red ,display =display.pane ) plot (display =display.status_line ,series =haOpen ,color =green ) plot (display =display.status_line ,series =haHigh ,color =green ) plot (display =display.status_line ,series =haLow ,color =red ) plot (display =display.status_line ,series =haClose ,color =red ) // &#160;HA Supertrend haTrueRange =request.security (ticker.heikinashi (syminfo.tickerid ),timeframe.period ,ta.atr (supertrendAtrPeriod ))// math.max(haHigh - haLow, math.abs(haHigh - haClose[1]), math.abs(haLow - haClose[1])) haSupertrendUp =((haHigh +haLow )/2 )-(supertrendAtrMultiplier *haTrueRange ) haSupertrendDown =((haHigh +haLow )/2 )+(supertrendAtrMultiplier *haTrueRange ) float trendingUp =na float trendingDown =na direction =0 trendingUp :=haClose [1 ]>trendingUp [1 ]?math.max (haSupertrendUp ,trendingUp [1 ]):haSupertrendUp trendingDown :=haClose [1 ]<trendingDown [1 ]?math.min (haSupertrendDown ,trendingDown [1 ]):haSupertrendDown direction :=haClose >trendingDown [1 ]?1 :haClose <trendingUp [1 ]?-1 :nz (direction [1 ],1 ) supertrend =direction ==1 ?trendingUp :trendingDown supertrendUp =ta.change (direction )<0 supertrendDown =ta.change (direction )>0 // &#160;Plots, Lines, and Labels bodyMiddle =plot ((haOpen +haClose )/2 ,display =display.none ) downTrend =plot (direction <0 ?supertrend :na ,"Down Trend",color =red ,style =plot.style_linebr ) upTrend =plot (direction <0 ?na :supertrend ,"Up Trend",color =green ,style =plot.style_linebr ) fill (bodyMiddle ,upTrend ,lightGreen ,fillgaps =false ) fill (bodyMiddle ,downTrend ,lightRed ,fillgaps =false ) ========================= 첨부된 그림처럼 빨강선과 녹색선을 표현하고자 합니다. atr길이와 atr배수을 변경할수 있게 부탁드립니다. 수식이 길어서 전략은 삭제하고 라인만 나타나보이게 올렸으니 감안하여 부족한 부분이 있다면 보완해주셔서 변환해주시면 더욱 감사하겠습니다. 오늘도 감사합니다. 수고하세요!!!