커뮤니티

지표 변환 부탁드립니다.

프로필 이미지
삼손감자
2025-03-21 10:12:16
418
글번호 189393
답변완료
// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International // https://creativecommons.org/licenses/by-nc-sa/4.0/ // &#169; BigBeluga //@version=6 indicator("Two-Pole Oscillator [BigBeluga]", max_labels_count = 500, max_lines_count = 500) // INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ int length = input.int(20, minval=1, title="Filter Length") bool disp_lvl = input.bool(true, "Levels") color up_color = input.color(#55ffda, "", inline = "color") color dn_color = input.color(#8c5bff, "", inline = "color") var buy_line = line(na) var sell_line = line(na) // } // CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ float sma1 = ta.sma(close, 25) float sma_n1 = ((close - sma1) - ta.sma(close - sma1, 25)) / ta.stdev(close - sma1, 25) float area = ta.sma(high-low, 100) // Two-pole smooth filter function f_two_pole_filter(source, length) => var float smooth1 = na var float smooth2 = na alpha = 2.0 / (length + 1) if na(smooth1) smooth1 := source else smooth1 := (1 - alpha) * smooth1 + alpha * source if na(smooth2) smooth2 := smooth1 else smooth2 := (1 - alpha) * smooth2 + alpha * smooth1 // Oscillator two_p = f_two_pole_filter(sma_n1, length) two_pp = two_p[4] // Colors color buy_col1 = color.from_gradient(two_p, -1, 0.5, up_color, na) color buy_col2 = color.from_gradient(two_p, -1, 0.5, color.new(up_color, 50), na) color sell_col1 = color.from_gradient(two_p, -0.5, 1, na, dn_color) color sell_col2 = color.from_gradient(two_p, -0.5, 1, na, color.new(dn_color, 50)) color color = two_p > two_pp ? color.from_gradient(two_p, -1,1, up_color, color.new(up_color, 0)) : color.from_gradient(two_p, -1,1,color.new(dn_color, 0), dn_color) // Signals bool buy = ta.crossover(two_p, two_pp) and two_p < 0 and barstate.isconfirmed bool sell = ta.crossunder(two_p, two_pp) and two_p > 0 and barstate.isconfirmed // } // PLOT ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ if buy //and two_p < -0.5 sell_line := line(na) if disp_lvl buy_line := line.new( bar_index-1 , low[1] - area , bar_index , low[1] - area , force_overlay = true , color = buy_col1 , style = line.style_dashed ) label.new(bar_index-1, low[1] - area , color = buy_col1, style = label.style_label_up, force_overlay = true, size = size.tiny) if ta.crossunder(low, buy_line.get_y1()) and barstate.isconfirmed label.new( bar_index-1 , buy_line.get_y1() , color = color.new(up_color, 100) , style = label.style_label_center , force_overlay = true , size = size.large , text = "&#10006;" , textcolor = up_color ) buy_line := line(na) if sell //and two_p > 0.5 buy_line := line(na) if disp_lvl sell_line := line.new( bar_index-1 , high[1] + area , bar_index , high[1] + area , force_overlay = true , color = sell_col1 , style = line.style_dashed ) label.new(bar_index-1, high[1] + area , color = sell_col1, style = label.style_label_down, force_overlay = true, size = size.tiny) if ta.crossover(high, sell_line.get_y1()) and barstate.isconfirmed label.new( bar_index-1 , sell_line.get_y1() , color = color.new(dn_color, 100) , style = label.style_label_center , force_overlay = true , size = size.large , text = "&#10006;" , textcolor = dn_color ) sell_line := line(na) switch not na(buy_line) => buy_line. set_x2(bar_index) not na(sell_line) => sell_line.set_x2(bar_index) plotshape(buy ? two_p[1] : na, "Buy", shape.circle, location.absolute, buy_col2, -1, size = size.small) plotshape(buy ? two_p[1] : na, "Buy", shape.circle, location.absolute, buy_col1, -1, size = size.tiny) plotshape(sell ? two_p[1] : na, "Sell", shape.circle, location.absolute, sell_col2, -1, size = size.small) plotshape(sell ? two_p[1] : na, "Sell", shape.circle, location.absolute, sell_col1, -1, size = size.tiny) p11 = plot(1, color = color.new(chart.fg_color, 80)) plot(0.5, color = color.new(chart.fg_color, 50)) p00 = plot(0, color = color.new(bar_index % 2 == 0 ? chart.fg_color : na, 0)) plot(-0.5, color = color.new(chart.fg_color, 50)) p_1 = plot(-1, color = color.new(chart.fg_color, 80)) fill(p11, p00, 2, -1, color.new(chart.fg_color, 80), na) fill(p_1, p00, 1, -2, na, color.new(chart.fg_color, 80)) p1 = plot(two_p, color = color, linewidth = 1) p2 = plot(two_pp, display = display.none) fill(p1, p2, two_p, two_pp, color, na) // }
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-03-24 09:52:35

안녕하세요 예스스탁입니다. input : length(20); input : disp_lvl(true); input : up_color(Cyan); input : dn_color(Violet); #var buy_line = line(na) #var sell_line = line(na) var : sma1(0),sma_n1(0),area(0); sma1 = ma(close, 25); sma_n1 = ((close - sma1) - ma(close - sma1, 25)) / std(close - sma1, 25); area = ma(high-low, 100); var : smooth1(nan); var : smooth2(nan); var : alpha(0); alpha = 2.0 / (length + 1); if IsNaN(smooth1) ==true Then smooth1 = sma_n1; else smooth1 = (1 - alpha) * smooth1 + alpha * sma_n1; if IsNan(smooth2) == true Then smooth2 = smooth1; else smooth2 = (1 - alpha) * smooth2 + alpha * smooth1; var : two_p(0),two_pP(0); two_p = smooth2; two_pp = two_p[4]; Plot1(two_p); Plot2(two_pp); plot3(1,"1",Gray); plot4(0.5,"0.5",Gray); plot5(0,"0",Black); plot6(-0.5,"-0.5",Gray); plot7(-1,"-1",Gray); var : B(false),S(False); var : buy_line(0),btl(0),btx1(0),btx2(0); var : sell_line(0),stl(0),stx1(0),stx2(0); var : btx3(0),btx4(0),stx3(0),stx4(0); B = CrossUp(two_p, two_pp) and two_p < 0; S = CrossDown(two_p, two_pp) and two_p > 0; if B Then { buy_line = Low[1]-area; btl = TL_New(sDate[1],sTime[1],buy_line,sDate,sTime,buy_line); TL_SetColor(btl,up_color); btx1 = text_new(sDate[1],sTime[1],buy_line,"▲"); Text_SetStyle(btx1,2,0); Text_SetColor(btx1,up_color); btx3 = text_new_self(sDate[1],sTime[1],two_p,"●"); Text_SetStyle(btx3,2,2); Text_SetColor(btx3,up_color); btx4 = text_new_self(sDate[1],sTime[1],two_p,"○"); Text_SetStyle(btx4,2,2); Text_SetColor(btx4,up_color); Text_SetSize(btx4,20); } Else { if buy_line > 0 Then TL_SetEnd(btl,sDate,sTime,buy_line); } if CrossDown(low, buy_line) then { TL_SetEnd(btl,sDate[1],sTime[1],buy_line[1]); btx2 = text_new(sDate[1],sTime[1],buy_line[1],"X"); Text_SetStyle(btx2,2,0); Text_SetColor(btx2,up_color); buy_line = 0; } if S Then { sell_line = high[1] + area; stl = TL_New(sDate[1],sTime[1],sell_line,sDate,sTime,sell_line); TL_SetColor(stl,dn_color); stx1 = text_new(sDate[1],sTime[1],sell_line,"▼"); Text_SetStyle(stx1,2,1); Text_SetColor(stx1,dn_color); stx3 = text_new_self(sDate[1],sTime[1],two_p,"●"); Text_SetStyle(stx3,2,2); Text_SetColor(stx3,dn_color); stx4 = text_new_self(sDate[1],sTime[1],two_p,"○"); Text_SetStyle(stx4,2,2); Text_SetColor(stx4,dn_color); Text_SetSize(stx4,20); } Else { if sell_line > 0 Then TL_SetEnd(stl,sDate,sTime,sell_line); } if CrossUp(high, sell_line) Then { TL_SetEnd(stl,sDate[1],sTime[1],sell_line[1]); stx2 = text_new(sDate[1],sTime[1],sell_line[1],"X"); Text_SetStyle(stx2,2,1); Text_SetColor(Stx2,dn_color); sell_line = 0; } 즐거운 하루되세요 > 삼손감자 님이 쓴 글입니다. > 제목 : 지표 변환 부탁드립니다. > // This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International // https://creativecommons.org/licenses/by-nc-sa/4.0/ // &#169; BigBeluga //@version=6 indicator("Two-Pole Oscillator [BigBeluga]", max_labels_count = 500, max_lines_count = 500) // INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ int length = input.int(20, minval=1, title="Filter Length") bool disp_lvl = input.bool(true, "Levels") color up_color = input.color(#55ffda, "", inline = "color") color dn_color = input.color(#8c5bff, "", inline = "color") var buy_line = line(na) var sell_line = line(na) // } // CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ float sma1 = ta.sma(close, 25) float sma_n1 = ((close - sma1) - ta.sma(close - sma1, 25)) / ta.stdev(close - sma1, 25) float area = ta.sma(high-low, 100) // Two-pole smooth filter function f_two_pole_filter(source, length) => var float smooth1 = na var float smooth2 = na alpha = 2.0 / (length + 1) if na(smooth1) smooth1 := source else smooth1 := (1 - alpha) * smooth1 + alpha * source if na(smooth2) smooth2 := smooth1 else smooth2 := (1 - alpha) * smooth2 + alpha * smooth1 // Oscillator two_p = f_two_pole_filter(sma_n1, length) two_pp = two_p[4] // Colors color buy_col1 = color.from_gradient(two_p, -1, 0.5, up_color, na) color buy_col2 = color.from_gradient(two_p, -1, 0.5, color.new(up_color, 50), na) color sell_col1 = color.from_gradient(two_p, -0.5, 1, na, dn_color) color sell_col2 = color.from_gradient(two_p, -0.5, 1, na, color.new(dn_color, 50)) color color = two_p > two_pp ? color.from_gradient(two_p, -1,1, up_color, color.new(up_color, 0)) : color.from_gradient(two_p, -1,1,color.new(dn_color, 0), dn_color) // Signals bool buy = ta.crossover(two_p, two_pp) and two_p < 0 and barstate.isconfirmed bool sell = ta.crossunder(two_p, two_pp) and two_p > 0 and barstate.isconfirmed // } // PLOT ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ if buy //and two_p < -0.5 sell_line := line(na) if disp_lvl buy_line := line.new( bar_index-1 , low[1] - area , bar_index , low[1] - area , force_overlay = true , color = buy_col1 , style = line.style_dashed ) label.new(bar_index-1, low[1] - area , color = buy_col1, style = label.style_label_up, force_overlay = true, size = size.tiny) if ta.crossunder(low, buy_line.get_y1()) and barstate.isconfirmed label.new( bar_index-1 , buy_line.get_y1() , color = color.new(up_color, 100) , style = label.style_label_center , force_overlay = true , size = size.large , text = "&#10006;" , textcolor = up_color ) buy_line := line(na) if sell //and two_p > 0.5 buy_line := line(na) if disp_lvl sell_line := line.new( bar_index-1 , high[1] + area , bar_index , high[1] + area , force_overlay = true , color = sell_col1 , style = line.style_dashed ) label.new(bar_index-1, high[1] + area , color = sell_col1, style = label.style_label_down, force_overlay = true, size = size.tiny) if ta.crossover(high, sell_line.get_y1()) and barstate.isconfirmed label.new( bar_index-1 , sell_line.get_y1() , color = color.new(dn_color, 100) , style = label.style_label_center , force_overlay = true , size = size.large , text = "&#10006;" , textcolor = dn_color ) sell_line := line(na) switch not na(buy_line) => buy_line. set_x2(bar_index) not na(sell_line) => sell_line.set_x2(bar_index) plotshape(buy ? two_p[1] : na, "Buy", shape.circle, location.absolute, buy_col2, -1, size = size.small) plotshape(buy ? two_p[1] : na, "Buy", shape.circle, location.absolute, buy_col1, -1, size = size.tiny) plotshape(sell ? two_p[1] : na, "Sell", shape.circle, location.absolute, sell_col2, -1, size = size.small) plotshape(sell ? two_p[1] : na, "Sell", shape.circle, location.absolute, sell_col1, -1, size = size.tiny) p11 = plot(1, color = color.new(chart.fg_color, 80)) plot(0.5, color = color.new(chart.fg_color, 50)) p00 = plot(0, color = color.new(bar_index % 2 == 0 ? chart.fg_color : na, 0)) plot(-0.5, color = color.new(chart.fg_color, 50)) p_1 = plot(-1, color = color.new(chart.fg_color, 80)) fill(p11, p00, 2, -1, color.new(chart.fg_color, 80), na) fill(p_1, p00, 1, -2, na, color.new(chart.fg_color, 80)) p1 = plot(two_p, color = color, linewidth = 1) p2 = plot(two_pp, display = display.none) fill(p1, p2, two_p, two_pp, color, na) // }