커뮤니티

수식 부탁드립니다

프로필 이미지
사노소이
2025-05-28 03:32:53
238
글번호 191229
답변완료
지표식 부탁드립니다. 1. //@version=5 indicator("DC", shorttitle="DC", overlay=true) length = input.int(10, title="Donchian Period", minval=1) offset = input.int(5, title="Offset") // Lvels upper = ta.highest(high, length) lower = ta.lowest(low, length) basis = (upper + lower) / 2 // Plot channels plot(basis, "Basis", color=color.orange, offset=offset) p1 = plot(upper, "Upper", color=color.blue, offset=offset) p2 = plot(lower, "Lower", color=color.blue, offset=offset) // Trend logic var int trend = 0 trend := close > upper[1] ? 1 : close < lower[1] ? -1 : trend[1] trendChangeUp = trend == 1 and trend[1] != 1 trendChangeDown = trend == -1 and trend[1] != -1 // Plot breakout arrows plotshape(trendChangeUp, title="Breakout Up", location=location.belowbar, color=color.green, style=shape.labelup, size=size.tiny, text="BUY", textcolor=color.new(color.white, 0)) plotshape(trendChangeDown, title="Breakout Down", location=location.abovebar, color=color.red, style=shape.labeldown, size=size.tiny, text="SELL", textcolor=color.new(color.white, 0)) // Fill between upper and lower with trend-based color fillColor = trend == 1 ? color.new(color.green, 85) : trend == -1 ? color.new(color.red, 85) : color.new(color.gray, 90) fill(p1, p2, color=fillColor, title="Trend Fill") 2. //@version=4 study("BOX", overlay=true, shorttitle="BOX") // 사용자 입력: 박스 길이 설정 boxp = input(5, "BOX LENGTH") // 박스 상단 및 하단 계산 LL = lowest(low, boxp) k1 = highest(high, boxp) k2 = highest(high, boxp - 1) k3 = highest(high, boxp - 2) NH = valuewhen(high > k1[1], high, 0) box1 = k3 < k2 TopBox = valuewhen(barssince(high > k1[1]) == boxp - 2 and box1, NH, 0) BottomBox = valuewhen(barssince(high > k1[1]) == boxp - 2 and box1, LL, 0) // 박스 상단 및 하단 플로팅 topPlot = plot(TopBox, linewidth=3, color=color.green, title="Top Box") bottomPlot = plot(BottomBox, linewidth=3, color=color.red, title="Bottom Box") // 박스 내부 영역 채우기 fill(topPlot, bottomPlot, color=color.new(color.blue, 90), title="Box Fill") // 봉의 위치에 따른 색상 지정 insideBox = close >= BottomBox and close <= TopBox aboveBox = close > TopBox belowBox = close < BottomBox barcolor(insideBox ? color.gray : na) barcolor(aboveBox ? color.green : na) barcolor(belowBox ? color.red : na)
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-05-28 08:40:13

안녕하세요 예스스탁입니다. 1 input : length(10); input : offset(5); var : upper(0),lower(0),basis(0); upper = highest(high, length); lower = lowest(low, length); basis = (upper + lower) / 2; plot1(basis, "Basis", orange); plot2(upper, "Upper", blue); plot3(lower, "Lower", blue); FixPlotShift(1,offset); FixPlotShift(2,offset); FixPlotShift(3,offset); var : trend(0),trendChangeUp(False),trendChangeDown(False),tx(0); trend = iff(close > upper[1] , 1 , IFf( close < lower[1] , -1 , trend[1])); trendChangeUp = trend == 1 and trend[1] != 1; trendChangeDown = trend == -1 and trend[1] != -1; if trendChangeUp == true Then { tx = Text_New(sDate,sTime,L,"▲"); Text_SetStyle(tx,2,0); Text_SetSize(tx,12); Text_SetColor(tx,Green); } if trendChangeDown == true Then { tx = Text_New(sDate,sTime,H,"▼"); Text_SetStyle(tx,2,1); Text_SetSize(tx,12); Text_SetColor(tx,Green); } 2 input : boxp(5); var : LL(0),k1(0),k2(0),k3(0),NH(0),box1(False); var : bs(0),TopBox(0),BottomBox(0); LL = lowest(low, boxp); k1 = highest(high, boxp); k2 = highest(high, boxp - 1); k3 = highest(high, boxp - 2); if high > k1[1] Then { NH = high; bs = 0; } Else { if NH > 0 Then bs = bs+1; } box1 = k3 < k2; if bs == boxp-2 and box1 Then { TopBox = NH; BottomBox = LL; } if TopBox > 0 Then plot1(TopBox, "Top Box",Green); if BottomBox > 0 Then plot2(BottomBox, "Bottom Box",Red); 즐거운 하루되세요 > 사노소이 님이 쓴 글입니다. > 제목 : 수식 부탁드립니다 > 지표식 부탁드립니다. 1. //@version=5 indicator("DC", shorttitle="DC", overlay=true) length = input.int(10, title="Donchian Period", minval=1) offset = input.int(5, title="Offset") // Lvels upper = ta.highest(high, length) lower = ta.lowest(low, length) basis = (upper + lower) / 2 // Plot channels plot(basis, "Basis", color=color.orange, offset=offset) p1 = plot(upper, "Upper", color=color.blue, offset=offset) p2 = plot(lower, "Lower", color=color.blue, offset=offset) // Trend logic var int trend = 0 trend := close > upper[1] ? 1 : close < lower[1] ? -1 : trend[1] trendChangeUp = trend == 1 and trend[1] != 1 trendChangeDown = trend == -1 and trend[1] != -1 // Plot breakout arrows plotshape(trendChangeUp, title="Breakout Up", location=location.belowbar, color=color.green, style=shape.labelup, size=size.tiny, text="BUY", textcolor=color.new(color.white, 0)) plotshape(trendChangeDown, title="Breakout Down", location=location.abovebar, color=color.red, style=shape.labeldown, size=size.tiny, text="SELL", textcolor=color.new(color.white, 0)) // Fill between upper and lower with trend-based color fillColor = trend == 1 ? color.new(color.green, 85) : trend == -1 ? color.new(color.red, 85) : color.new(color.gray, 90) fill(p1, p2, color=fillColor, title="Trend Fill") 2. //@version=4 study("BOX", overlay=true, shorttitle="BOX") // 사용자 입력: 박스 길이 설정 boxp = input(5, "BOX LENGTH") // 박스 상단 및 하단 계산 LL = lowest(low, boxp) k1 = highest(high, boxp) k2 = highest(high, boxp - 1) k3 = highest(high, boxp - 2) NH = valuewhen(high > k1[1], high, 0) box1 = k3 < k2 TopBox = valuewhen(barssince(high > k1[1]) == boxp - 2 and box1, NH, 0) BottomBox = valuewhen(barssince(high > k1[1]) == boxp - 2 and box1, LL, 0) // 박스 상단 및 하단 플로팅 topPlot = plot(TopBox, linewidth=3, color=color.green, title="Top Box") bottomPlot = plot(BottomBox, linewidth=3, color=color.red, title="Bottom Box") // 박스 내부 영역 채우기 fill(topPlot, bottomPlot, color=color.new(color.blue, 90), title="Box Fill") // 봉의 위치에 따른 색상 지정 insideBox = close >= BottomBox and close <= TopBox aboveBox = close > TopBox belowBox = close < BottomBox barcolor(insideBox ? color.gray : na) barcolor(aboveBox ? color.green : na) barcolor(belowBox ? color.red : na)