커뮤니티

Dynamic Darvas Line 예스랭귀지로 변환 꼭 부탁드리겠습니다.

프로필 이미지
haenoori
2025-11-26 00:49:33
57
글번호 228405
답변완료

Dynamic Darvas Line이 트레이딩뷰에 오픈 소스로 있어 예스랭귀지로 변환 부탁드리고자 합니다.  지표는 아래와 같습니다.   그리고 대단히 죄송합니다마는, 매수 시점을 찾을 수 있는 종목 검색식도 가능하면 함께 부탁드립니다.  미리 감사드립니다. 
indicator('Dynamic Darvas Lines [CHE]', overlay=true)
// ============================== // Parameters Group // ============================== boxLength = input.int(defval=5, title='Box Length', minval=3, maxval=500, group='Parameters', tooltip='Length of the box in bars.')
debugMode = input.bool(defval=false, title='Debug Mode', group='Debugging', tooltip='Enable to display debug lines for lowest low and highest high.')
// ============================== // Color Management Group // ============================== topBoxColor = input.color(color.rgb(76, 175, 80, 80), title='Top of Box Color', group='Colors', tooltip='Color for the top line of the box with transparency.')
bottomBoxColor = input.color(color.rgb(255, 82, 82, 80), title='Bottom of Box Color', group='Colors', tooltip='Color for the bottom line of the box with transparency.')
buySignalColor = input.color(color.green, title='Buy Signal Color', group='Colors', tooltip='Color for the buy signal labels.')
sellSignalColor = input.color(color.red, title='Sell Signal Color', group='Colors', tooltip='Color for the sell signal labels.')
plotCircleBuyColor = input.color(color.rgb(76, 175, 80, 0), title='Buy Plot Circle Color', group='Colors', tooltip='Color for the buy signal circles.')
plotCircleSellColor = input.color(color.rgb(255, 82, 82, 0), title='Sell Plot Circle Color', group='Colors', tooltip='Color for the sell signal circles.')
debugLowestLowColor = input.color(color.blue, title='Debug Lowest Low Color', group='Debugging', tooltip='Color for the debug line showing the lowest low.')
debugHighestHighColor = input.color(color.orange, title='Debug Highest High Color', group='Debugging', tooltip='Color for the debug line showing the highest high.')
// ============================== // Functions // ============================== f_lowest(series, length) =>     var float min_value = na     min_value := series[length - 1]         for i = 0 to length - 2         min_value := na(min_value) or series[i] < min_value ? series[i] : min_value         min_value
f_highest(series, length) =>     var float max_value = na     max_value := series[length - 1]         for i = 0 to length - 2         max_value := na(max_value) or series[i] > max_value ? series[i] : max_value         max_value
f_valueWhen(condition, series, occurrence) =>     var float value = na     if (condition)         value := series     value
f_barsSince(condition) =>     var int bars = 0     bars := condition ? 0 : (bars[1] + 1)     bars
f_crossover(series1, series2) =>     crossover = (series1[1] < series2[1]) and (series1 > series2)     crossover
f_crossunder(series1, series2) =>     crossunder = (series1[1] > series2[1]) and (series1 < series2)     crossunder
// ============================== // Calculations for Box Lines // ============================== lowestLow = f_lowest(low, boxLength) highestHigh = f_highest(high, boxLength) recentHigh = f_valueWhen(high > f_highest(high, boxLength - 1)[1], high, 0) isBoxCondition = f_highest(high, boxLength - 2) < f_highest(high, boxLength - 1) topBox = f_valueWhen(f_barsSince(high > f_highest(high, boxLength - 1)[1]) == boxLength - 2 and isBoxCondition, recentHigh, 0) bottomBox = f_valueWhen(f_barsSince(high > f_highest(high, boxLength - 1)[1]) == boxLength - 2 and isBoxCondition, lowestLow, 0)
var string lastSignal = 'None'
// ============================== // Signal Detection // ============================== buySignal = f_crossover(close, topBox) and (lastSignal != 'Buy') sellSignal = f_crossunder(close, bottomBox) and (lastSignal != 'Sell')
if buySignal     lastSignal := 'Buy' if sellSignal     lastSignal := 'Sell'
var float saved_close = na
saved_close := buySignal or sellSignal ? close : saved_close
// ============================== // Plotting // ============================== // Plot the saved close prices with circles plot(saved_close, color = lastSignal == "Buy" ? plotCircleBuyColor : plotCircleSellColor, style = plot.style_circles, title='Signal Close Price')
// Plot the box lines with user-defined colors plot(topBox, linewidth=2, color=topBoxColor, title='Top of Box') plot(bottomBox, linewidth=2, color=bottomBoxColor, title='Bottom of Box')
// ============================== // Alerts // ============================== alertcondition(buySignal, title='Buy Signal', message='Buy Signal Triggered') alertcondition(sellSignal, title='Sell Signal', message='Sell Signal Triggered')
// ============================== // Plotting Signal Shapes // ============================== plotshape(buySignal, style=shape.labelup, location=location.belowbar, color=color.new(buySignalColor, 0), size=size.tiny, title='Buy Signal', text='Buy', textcolor=color.new(color.white, 0)) plotshape(sellSignal, style=shape.labeldown, location=location.abovebar, color=color.new(sellSignalColor, 0), size=size.tiny, title='Sell Signal', text='Sell', textcolor=color.new(color.white, 0))
// ============================== // Debugging Lines // ============================== plot(debugMode ? lowestLow : na, color=debugLowestLowColor, title='Debug Lowest Low', linewidth=1, style=plot.style_line) plot(debugMode ? highestHigh : na, color=debugHighestHighColor, title='Debug Highest High', linewidth=1, style=plot.style_line)

지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-11-26 13:00:18

안녕하세요 예스스탁입니다. input:boxLength(5); input:debugMode(false); input : topBoxColor(LightGreen); input : bottomBoxColor(Pink); input : buySignalColor(green); input : sellSignalColor(red); input : plotCircleBuyColor(Green); input : plotCircleSellColor(Red); input : debugLowestLowColor(blue); input : debugHighestHighColor(orange); var : lowestLow(0),highestHigh(0),recentHigh(0),bs(Nan),lastSignal(""); var : isBoxCondition(false),saved_close(Nan),tx(0),tx1(0); var : topBox(0),bottomBox(0),buySignal(False),sellSignal(False); lowestLow = lowest(low, boxLength); highestHigh = highest(high, boxLength); if high > highest(high, boxLength - 1)[1] Then { recentHigh = high; bs = 0; } Else bs = bs+1; isBoxCondition = highest(high, boxLength - 2) < highest(high, boxLength - 1); if bs == boxLength - 2 and isBoxCondition Then { topBox = recentHigh; bottomBox = lowestLow; } buySignal = CrossUp(close, topBox) and (lastSignal != "Buy"); sellSignal = CrossDown(close, bottomBox) and (lastSignal != "Sell"); if buySignal Then lastSignal = "Buy"; if sellSignal then lastSignal = "Sell"; saved_close = iff(buySignal or sellSignal , close , saved_close); plot1(saved_close,"Signal Close Price", iff(lastSignal == "Buy" , plotCircleBuyColor , plotCircleSellColor)); plot2(topBox, "Top of Box",topBoxColor); plot3(bottomBox, "Bottom of Box",bottomBoxColor); if buySignal == true Then { tx = Text_New(sDate,sTime,L,"▲"); Text_SetStyle(tx,2,0); Text_SetColor(tx,buySignalColor); } if sellSignal == true Then { tx = Text_New(sDate,sTime,H,"▼"); Text_SetStyle(tx,2,1); Text_SetColor(tx,sellSignalColor); } if debugMode == true Then { plot4(lowestLow ,"Debug Lowest Low", debugLowestLowColor); plot5(highestHigh ,"Debug Highest High",debugHighestHighColor); } Else { NoPlot(4); NoPlot(5); } 즐거운 하루되세요