커뮤니티

지표 변환 부탁드립니다.

프로필 이미지
삼손감자
2025-05-14 10:12:04
284
글번호 190801
답변완료
//@version=6 indicator("Trend Classifier [ChartPrime]", overlay = true, max_labels_count = 500) // --------------------------------------------------------------------------------------------------------------------} // &#128204; &#120400;&#120398;&#120384;&#120397; &#120388;&#120393;&#120395;&#120400;&#120399;&#120398; // --------------------------------------------------------------------------------------------------------------------{ int length = input.int(10, "Length") bool show_bands = input.bool(true, "Trend Bands") color col_up = input.color(#008fa5, "", inline = "col") color col_dn = input.color(#e14c60, "", inline = "col") color col_range = input.color(#edae49, "", inline = "col") // --------------------------------------------------------------------------------------------------------------------} // &#128204; &#120388;&#120393;&#120383;&#120388;&#120382;&#120380;&#120399;&#120394;&#120397; &#120382;&#120380;&#120391;&#120382;&#120400;&#120391;&#120380;&#120399;&#120388;&#120394;&#120393;&#120398; // --------------------------------------------------------------------------------------------------------------------{ smema(src, length)=> ta.sma(ta.ema(src, length), length) col_distance(src, col)=> distance = math.abs(close - src) col_size = distance / ta.percentile_linear_interpolation(distance, 400, 100) show_bands ? color.from_gradient(col_size, 0, 0.5, color(na), col) : color(na) float smema = smema(close, length) float distance1 = close - smema float distance2 = smema - close float step = smema(high-low, 100) float smema_up3 = smema + step * 3 float smema_up2 = smema + step * 2 float smema_up1 = smema + step float smema_dn3 = smema - step * 3 float smema_dn2 = smema - step * 2 float smema_dn1 = smema - step bool trend = smema > smema[1] bool above3 = close > smema_up3 bool above2 = close > smema_up2 bool above1 = close > smema_up1 bool below1 = close < smema_dn1 bool below2 = close < smema_dn2 bool below3 = close < smema_dn3 int bull_strength = (above1 ? 1 : 0) + (above2 ? 1 : 0) + (above3 ? 1 : 0) int bear_strength = (below1 ? 1 : 0) + (below2 ? 1 : 0) + (below3 ? 1 : 0) label_signal = trend and bull_strength >= 1 ? 1 : not trend and bear_strength >= 1 ? -1 : 0 // --------------------------------------------------------------------------------------------------------------------} // &#128204; &#120401;&#120388;&#120398;&#120400;&#120380;&#120391;&#120388;&#120405;&#120380;&#120399;&#120388;&#120394;&#120393; // --------------------------------------------------------------------------------------------------------------------{ table mytbl = table.new(position.top_right, 10, 50) if barstate.islast table.cell(mytbl, 0, 0, "Bull Strength", text_color = chart.fg_color) table.cell(mytbl, 0, 1, "Bear Strength", text_color = chart.fg_color) for i = 0 to 3 table.cell(mytbl, 1+i, 0, "") if bull_strength >= 0 for i = 0 to bull_strength table.cell(mytbl, i+1, 0, i == bull_strength ? str.tostring(bull_strength) : "", bgcolor = color.new(col_up, 80 - i * 30), text_color = chart.fg_color) if bear_strength >= 0 for i = 0 to bear_strength table.cell(mytbl, i+1, 1, i == bear_strength ? str.tostring(bear_strength) : "", bgcolor = color.new(col_dn, 80 - i * 30), text_color = chart.fg_color) color color_class = label_signal > 0 ? col_up : label_signal < 0 ? col_dn : col_range // Labels barcolor(color_class) plotcandle(open, high, low, close, title='Candles Color', color = color_class, wickcolor=color_class, bordercolor = color_class, force_overlay = true) plotshape(trend != trend[1] ? smema[1] : na, location=location.absolute, color=chart.fg_color, style=shape.diamond, title="Trend Signal", force_overlay = true, offset = -1, size = size.tiny) if label_signal == 1 label.new(bar_index, low, "▲₩n" + str.tostring(bull_strength), style = label.style_label_up, color = color(na), size = size.tiny, textcolor = color_class) if label_signal == -1 label.new(bar_index, high, str.tostring(bear_strength) + "₩n▼", style = label.style_label_down, color = color(na), size = size.tiny, textcolor = color_class) color col_mid = smema > smema[1] ? col_up : col_dn color col_up1 = col_distance(smema_up1, close > smema_up1 and trend ? col_up : close < smema_up1 and not trend ? col_dn : color(na)) color col_up2 = col_distance(smema_up2, close > smema_up2 and trend ? col_up : close < smema_up2 and not trend ? col_dn : color(na)) color col_up3 = col_distance(smema_up3, close > smema_up3 and trend ? col_up : close < smema_up3 and not trend ? col_dn : color(na)) color col_dn1 = col_distance(smema_dn1, close < smema_dn1 and not trend ? col_dn : close > smema_dn1 and trend ? col_up : color(na)) color col_dn2 = col_distance(smema_dn2, close < smema_dn2 and not trend ? col_dn : close > smema_dn2 and trend ? col_up : color(na)) color col_dn3 = col_distance(smema_dn3, close < smema_dn3 and not trend ? col_dn : close > smema_dn3 and trend ? col_up : color(na)) plot(smema_up3, color = col_up3, editable = false) plot(smema_up2, color = col_up2, editable = false) plot(smema_up1, color = col_up1, editable = false) plot(smema, "Trend Line",color = col_mid, editable = true, linewidth = 2) plot(smema_dn1, color = col_dn1, editable = false) plot(smema_dn2, color = col_dn2, editable = false) plot(smema_dn3, color = col_dn3, editable = false) // --------------------------------------------------------------------------------------------------------------------}
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-05-14 16:53:50

안녕하세요 예스스탁입니다. 선의 그라데이션효과까지 작성해 드리기는 어렵습니다. 선은 동일색으로 표시가 됩니다. input : length(10); input : col_up(Green); input : col_dn(Red); input : col_range(Orange); var : smema(0),distance1(0),distance2(0); var : stp(0),trend(False); var : smema_up3(0),smema_up2(0),smema_up1(0); var : smema_dn3(0),smema_dn2(0),smema_dn1(0); var : above3(False),above2(False),above1(False); var : below3(False),below2(False),below1(False); var : bull_strength(0),bear_strength(0),label_signal(0); smema = ma(ema(close, length), length); distance1 = close - smema; distance2 = smema - close; stp = ma(ema(high-low, 100), 100); smema_up3 = smema + stp * 3; smema_up2 = smema + stp * 2; smema_up1 = smema + stp; smema_dn3 = smema - stp * 3; smema_dn2 = smema - stp * 2; smema_dn1 = smema - stp; trend = smema > smema[1]; above3 = close > smema_up3; above2 = close > smema_up2; above1 = close > smema_up1; below1 = close < smema_dn1; below2 = close < smema_dn2; below3 = close < smema_dn3; bull_strength = IFF(above1 , 1 , 0) + IFF(above2 , 1 , 0) + IFF(above3 , 1 , 0); bear_strength = IFF(below1 , 1 , 0) + IFF(below2 , 1 , 0) + IFF(below3 , 1 , 0); label_signal = IFF(trend and bull_strength >= 1 , 1 ,IFF(trend == False and bear_strength >= 1 , -1 , 0)); var : tx(0),tx1(0),tx2(0); if trend != trend[1] Then { tx = Text_New(sDate[1],sTime[1],smema[1],"◆"); Text_SetStyle(tx,2,2); } if label_signal == 1 Then { tx1 = Text_New(sDate,sTime,L,"▲"+NewLine+NumToStr(bull_strength,0)); Text_SetStyle(tx1,2,0); Text_SetColor(tx1,col_up); } if label_signal == -1 Then { tx2 = Text_New(sDate,sTime,H,NumToStr(bear_strength,0)+NewLine+"▼"); Text_SetStyle(tx2,2,1); Text_SetColor(tx2,col_dn); } var : clr(0); clr = iff(smema > smema[1] , col_up , col_dn); plot1(smema_up3,"up3", clr); plot2(smema_up2,"up2",clr); plot3(smema_up1,"up1",clr); plot4(smema, "Trend Line",clr); plot5(smema_dn1,"dn1",clr); plot6(smema_dn2,"dn2",clr); plot7(smema_dn3,"dn3",clr); 즐거운 하루되세요 > 삼손감자 님이 쓴 글입니다. > 제목 : 지표 변환 부탁드립니다. > //@version=6 indicator("Trend Classifier [ChartPrime]", overlay = true, max_labels_count = 500) // --------------------------------------------------------------------------------------------------------------------} // &#128204; &#120400;&#120398;&#120384;&#120397; &#120388;&#120393;&#120395;&#120400;&#120399;&#120398; // --------------------------------------------------------------------------------------------------------------------{ int length = input.int(10, "Length") bool show_bands = input.bool(true, "Trend Bands") color col_up = input.color(#008fa5, "", inline = "col") color col_dn = input.color(#e14c60, "", inline = "col") color col_range = input.color(#edae49, "", inline = "col") // --------------------------------------------------------------------------------------------------------------------} // &#128204; &#120388;&#120393;&#120383;&#120388;&#120382;&#120380;&#120399;&#120394;&#120397; &#120382;&#120380;&#120391;&#120382;&#120400;&#120391;&#120380;&#120399;&#120388;&#120394;&#120393;&#120398; // --------------------------------------------------------------------------------------------------------------------{ smema(src, length)=> ta.sma(ta.ema(src, length), length) col_distance(src, col)=> distance = math.abs(close - src) col_size = distance / ta.percentile_linear_interpolation(distance, 400, 100) show_bands ? color.from_gradient(col_size, 0, 0.5, color(na), col) : color(na) float smema = smema(close, length) float distance1 = close - smema float distance2 = smema - close float step = smema(high-low, 100) float smema_up3 = smema + step * 3 float smema_up2 = smema + step * 2 float smema_up1 = smema + step float smema_dn3 = smema - step * 3 float smema_dn2 = smema - step * 2 float smema_dn1 = smema - step bool trend = smema > smema[1] bool above3 = close > smema_up3 bool above2 = close > smema_up2 bool above1 = close > smema_up1 bool below1 = close < smema_dn1 bool below2 = close < smema_dn2 bool below3 = close < smema_dn3 int bull_strength = (above1 ? 1 : 0) + (above2 ? 1 : 0) + (above3 ? 1 : 0) int bear_strength = (below1 ? 1 : 0) + (below2 ? 1 : 0) + (below3 ? 1 : 0) label_signal = trend and bull_strength >= 1 ? 1 : not trend and bear_strength >= 1 ? -1 : 0 // --------------------------------------------------------------------------------------------------------------------} // &#128204; &#120401;&#120388;&#120398;&#120400;&#120380;&#120391;&#120388;&#120405;&#120380;&#120399;&#120388;&#120394;&#120393; // --------------------------------------------------------------------------------------------------------------------{ table mytbl = table.new(position.top_right, 10, 50) if barstate.islast table.cell(mytbl, 0, 0, "Bull Strength", text_color = chart.fg_color) table.cell(mytbl, 0, 1, "Bear Strength", text_color = chart.fg_color) for i = 0 to 3 table.cell(mytbl, 1+i, 0, "") if bull_strength >= 0 for i = 0 to bull_strength table.cell(mytbl, i+1, 0, i == bull_strength ? str.tostring(bull_strength) : "", bgcolor = color.new(col_up, 80 - i * 30), text_color = chart.fg_color) if bear_strength >= 0 for i = 0 to bear_strength table.cell(mytbl, i+1, 1, i == bear_strength ? str.tostring(bear_strength) : "", bgcolor = color.new(col_dn, 80 - i * 30), text_color = chart.fg_color) color color_class = label_signal > 0 ? col_up : label_signal < 0 ? col_dn : col_range // Labels barcolor(color_class) plotcandle(open, high, low, close, title='Candles Color', color = color_class, wickcolor=color_class, bordercolor = color_class, force_overlay = true) plotshape(trend != trend[1] ? smema[1] : na, location=location.absolute, color=chart.fg_color, style=shape.diamond, title="Trend Signal", force_overlay = true, offset = -1, size = size.tiny) if label_signal == 1 label.new(bar_index, low, "▲₩n" + str.tostring(bull_strength), style = label.style_label_up, color = color(na), size = size.tiny, textcolor = color_class) if label_signal == -1 label.new(bar_index, high, str.tostring(bear_strength) + "₩n▼", style = label.style_label_down, color = color(na), size = size.tiny, textcolor = color_class) color col_mid = smema > smema[1] ? col_up : col_dn color col_up1 = col_distance(smema_up1, close > smema_up1 and trend ? col_up : close < smema_up1 and not trend ? col_dn : color(na)) color col_up2 = col_distance(smema_up2, close > smema_up2 and trend ? col_up : close < smema_up2 and not trend ? col_dn : color(na)) color col_up3 = col_distance(smema_up3, close > smema_up3 and trend ? col_up : close < smema_up3 and not trend ? col_dn : color(na)) color col_dn1 = col_distance(smema_dn1, close < smema_dn1 and not trend ? col_dn : close > smema_dn1 and trend ? col_up : color(na)) color col_dn2 = col_distance(smema_dn2, close < smema_dn2 and not trend ? col_dn : close > smema_dn2 and trend ? col_up : color(na)) color col_dn3 = col_distance(smema_dn3, close < smema_dn3 and not trend ? col_dn : close > smema_dn3 and trend ? col_up : color(na)) plot(smema_up3, color = col_up3, editable = false) plot(smema_up2, color = col_up2, editable = false) plot(smema_up1, color = col_up1, editable = false) plot(smema, "Trend Line",color = col_mid, editable = true, linewidth = 2) plot(smema_dn1, color = col_dn1, editable = false) plot(smema_dn2, color = col_dn2, editable = false) plot(smema_dn3, color = col_dn3, editable = false) // --------------------------------------------------------------------------------------------------------------------}