커뮤니티

수식수정요청

프로필 이미지
한아나
2025-02-21 16:02:25
354
글번호 188435
답변완료
수고 많습니다 이베스트때 가입 LS증권에 사용 하고자 합니다 트레이딩뷰 지표입니다 indicator("오실레이터", max_labels_count = 500, max_lines_count = 500) // ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ int &#160; length &#160; = input.int(50, minval=1, title="Filter Length") bool &#160;disp_lvl = input.bool(true, "Levels") color up_color = input.color(color.rgb(70, 236, 200), "", inline = "color") color dn_color = input.color(#fc6c37, "", inline = "color") var buy_line = line(na) var sell_line = line(na) // } // ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ float sma1 &#160; = ta.sma(close, 25) float sma_n1 = ((close - sma1) - ta.sma(close - sma1, 25)) / ta.stdev(close - sma1, 25) float area &#160; = ta.sma(high-low, 100) // Two-pole smooth filter function f_two_pole_filter(source, length) => &#160; &#160; var float smooth1 = na &#160; &#160; var float smooth2 = na &#160; &#160; alpha = 2.0 / (length + 1) &#160; &#160; if na(smooth1) &#160; &#160; &#160; &#160; smooth1 := source &#160; &#160; else &#160; &#160; &#160; &#160; smooth1 := (1 - alpha) * smooth1 + alpha * source &#160; &#160; if na(smooth2) &#160; &#160; &#160; &#160; smooth2 := smooth1 &#160; &#160; else &#160; &#160; &#160; &#160; smooth2 := (1 - alpha) * smooth2 + alpha * smooth1 // Osc two_p = f_two_pole_filter(sma_n1, length) two_pp = two_p[4] // Colors color buy_col1 &#160;= color.from_gradient(two_p, -1, 0.5, up_color, na) color buy_col2 &#160;= 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 &#160; &#160; = two_p > two_pp &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; ? color.from_gradient(two_p, -1,1, up_color, color.new(up_color, 0)) &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; : color.from_gradient(two_p, -1,1,color.new(dn_color, 0), dn_color) // Signals bool buy &#160;= 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 // } //――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ if buy //and two_p < -0.5 &#160; &#160; sell_line := line(na) &#160; &#160; if disp_lvl &#160; &#160; &#160; &#160; buy_line := line.new( &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;bar_index-1 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, low[1] - area &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, bar_index &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, low[1] - area &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, force_overlay = true &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, color = buy_col1 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, style = line.style_dashed &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;) &#160; &#160; label.new(bar_index-1, low[1] - area &#160; &#160; &#160; &#160; &#160; &#160; &#160;, 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 &#160; &#160; label.new( &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;bar_index-1 &#160; &#160; &#160; &#160; &#160; &#160; &#160;, buy_line.get_y1() &#160; &#160; &#160; &#160; &#160; &#160; &#160;, color = color.new(up_color, 100) &#160; &#160; &#160; &#160; &#160; &#160; &#160;, style = label.style_label_center &#160; &#160; &#160; &#160; &#160; &#160; &#160;, force_overlay = true &#160; &#160; &#160; &#160; &#160; &#160; &#160;, size = size.large &#160; &#160; &#160; &#160; &#160; &#160; &#160;, text = "&#10006;" &#160; &#160; &#160; &#160; &#160; &#160; &#160;, textcolor = up_color &#160; &#160; &#160; &#160; &#160; &#160; &#160;) &#160; &#160; buy_line := line(na) if sell //and two_p > 0.5 &#160; &#160; buy_line := line(na) &#160; &#160; if disp_lvl &#160; &#160; &#160; &#160; sell_line := line.new( &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;bar_index-1 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, high[1] + area &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, bar_index &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, high[1] + area &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, force_overlay = true &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, color = sell_col1 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, style = line.style_dashed &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;) &#160; &#160; label.new(bar_index-1, high[1] + area &#160; &#160; &#160; &#160; &#160; &#160; &#160;, 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 &#160; &#160; label.new( &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;bar_index-1 &#160; &#160; &#160; &#160; &#160; &#160; &#160;, sell_line.get_y1() &#160; &#160; &#160; &#160; &#160; &#160; &#160;, color = color.new(dn_color, 100) &#160; &#160; &#160; &#160; &#160; &#160; &#160;, style = label.style_label_center &#160; &#160; &#160; &#160; &#160; &#160; &#160;, force_overlay = true &#160; &#160; &#160; &#160; &#160; &#160; &#160;, size = size.large &#160; &#160; &#160; &#160; &#160; &#160; &#160;, text = "&#10006;" &#160; &#160; &#160; &#160; &#160; &#160; &#160;, textcolor = dn_color &#160; &#160; &#160; &#160; &#160; &#160; &#160;) &#160; &#160; sell_line := line(na) switch &#160; &#160; not na(buy_line) &#160;=> buy_line. set_x2(bar_index) &#160; &#160; 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.white) p00 = plot(0, color = color.new(bar_index % 2 == 0 ? chart.fg_color : na, 0)) plot(-0.5, color = color.white) 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-02-21 17:38:43

안녕하세요 예스스탁입니다. 표시 기능이 트레이딩뷰와 다른부분이 있고 제공되지 않는 기능도 있어 비슷하게 표시되게 작성해 드립니다. input : length(50); input : disp_lvl(true); input : up_color(Cyan); input : dn_color(Red); var : sma1(0),sma_n1(0),area(0); var : smooth1(nan),smooth2(nan),alpha(0); var : two_p(0),two_pp(0),tx1(0),tx2(0); sma1 = ma(c,25); sma_n1 = ((close - sma1) - ma(close - sma1, 25)) / std(close - sma1, 25); area = ma(high-low, 100); 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; two_p = smooth2; two_pp = two_p[4]; plot1(1, "1",Gray); plot2(0.5,"0.5",Gray); plot3(0,"0.5",Gray); plot4(-0.5,"-0.5",Gray); plot5(-1,"-1.0",Gray); plot6(two_p,"two_p",IFf(two_p > two_pp,up_color,dn_color)); plot7(two_pp,"two_pp",Blue); if CrossUp(two_p, two_pp) and two_p < 0 Then { tx1 = Text_New_Self(sDate,sTime,two_p,"●"); Text_SetStyle(tx1,2,2); Text_SetColor(tx1,up_color); tx2 = Text_New(sDate,sTime,L,"▲"); Text_SetStyle(tx2,2,0); Text_SetColor(tx2,up_color); } if CrossDown(two_p, two_pp) and two_p > 0 Then { tx1 = Text_New_Self(sDate,sTime,two_p,"●"); Text_SetStyle(tx1,2,2); Text_SetColor(tx1,dn_color); tx2 = Text_New(sDate,sTime,H,"▼"); Text_SetStyle(tx2,2,1); Text_SetColor(tx2,dn_color); } 즐거운 하루되세요 > 한아나 님이 쓴 글입니다. > 제목 : 수식수정요청 > 수고 많습니다 이베스트때 가입 LS증권에 사용 하고자 합니다 트레이딩뷰 지표입니다 indicator("오실레이터", max_labels_count = 500, max_lines_count = 500) // ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ int &#160; length &#160; = input.int(50, minval=1, title="Filter Length") bool &#160;disp_lvl = input.bool(true, "Levels") color up_color = input.color(color.rgb(70, 236, 200), "", inline = "color") color dn_color = input.color(#fc6c37, "", inline = "color") var buy_line = line(na) var sell_line = line(na) // } // ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ float sma1 &#160; = ta.sma(close, 25) float sma_n1 = ((close - sma1) - ta.sma(close - sma1, 25)) / ta.stdev(close - sma1, 25) float area &#160; = ta.sma(high-low, 100) // Two-pole smooth filter function f_two_pole_filter(source, length) => &#160; &#160; var float smooth1 = na &#160; &#160; var float smooth2 = na &#160; &#160; alpha = 2.0 / (length + 1) &#160; &#160; if na(smooth1) &#160; &#160; &#160; &#160; smooth1 := source &#160; &#160; else &#160; &#160; &#160; &#160; smooth1 := (1 - alpha) * smooth1 + alpha * source &#160; &#160; if na(smooth2) &#160; &#160; &#160; &#160; smooth2 := smooth1 &#160; &#160; else &#160; &#160; &#160; &#160; smooth2 := (1 - alpha) * smooth2 + alpha * smooth1 // Osc two_p = f_two_pole_filter(sma_n1, length) two_pp = two_p[4] // Colors color buy_col1 &#160;= color.from_gradient(two_p, -1, 0.5, up_color, na) color buy_col2 &#160;= 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 &#160; &#160; = two_p > two_pp &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; ? color.from_gradient(two_p, -1,1, up_color, color.new(up_color, 0)) &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; : color.from_gradient(two_p, -1,1,color.new(dn_color, 0), dn_color) // Signals bool buy &#160;= 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 // } //――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ if buy //and two_p < -0.5 &#160; &#160; sell_line := line(na) &#160; &#160; if disp_lvl &#160; &#160; &#160; &#160; buy_line := line.new( &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;bar_index-1 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, low[1] - area &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, bar_index &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, low[1] - area &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, force_overlay = true &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, color = buy_col1 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, style = line.style_dashed &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;) &#160; &#160; label.new(bar_index-1, low[1] - area &#160; &#160; &#160; &#160; &#160; &#160; &#160;, 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 &#160; &#160; label.new( &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;bar_index-1 &#160; &#160; &#160; &#160; &#160; &#160; &#160;, buy_line.get_y1() &#160; &#160; &#160; &#160; &#160; &#160; &#160;, color = color.new(up_color, 100) &#160; &#160; &#160; &#160; &#160; &#160; &#160;, style = label.style_label_center &#160; &#160; &#160; &#160; &#160; &#160; &#160;, force_overlay = true &#160; &#160; &#160; &#160; &#160; &#160; &#160;, size = size.large &#160; &#160; &#160; &#160; &#160; &#160; &#160;, text = "&#10006;" &#160; &#160; &#160; &#160; &#160; &#160; &#160;, textcolor = up_color &#160; &#160; &#160; &#160; &#160; &#160; &#160;) &#160; &#160; buy_line := line(na) if sell //and two_p > 0.5 &#160; &#160; buy_line := line(na) &#160; &#160; if disp_lvl &#160; &#160; &#160; &#160; sell_line := line.new( &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;bar_index-1 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, high[1] + area &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, bar_index &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, high[1] + area &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, force_overlay = true &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, color = sell_col1 &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;, style = line.style_dashed &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;) &#160; &#160; label.new(bar_index-1, high[1] + area &#160; &#160; &#160; &#160; &#160; &#160; &#160;, 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 &#160; &#160; label.new( &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;bar_index-1 &#160; &#160; &#160; &#160; &#160; &#160; &#160;, sell_line.get_y1() &#160; &#160; &#160; &#160; &#160; &#160; &#160;, color = color.new(dn_color, 100) &#160; &#160; &#160; &#160; &#160; &#160; &#160;, style = label.style_label_center &#160; &#160; &#160; &#160; &#160; &#160; &#160;, force_overlay = true &#160; &#160; &#160; &#160; &#160; &#160; &#160;, size = size.large &#160; &#160; &#160; &#160; &#160; &#160; &#160;, text = "&#10006;" &#160; &#160; &#160; &#160; &#160; &#160; &#160;, textcolor = dn_color &#160; &#160; &#160; &#160; &#160; &#160; &#160;) &#160; &#160; sell_line := line(na) switch &#160; &#160; not na(buy_line) &#160;=> buy_line. set_x2(bar_index) &#160; &#160; 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.white) p00 = plot(0, color = color.new(bar_index % 2 == 0 ? chart.fg_color : na, 0)) plot(-0.5, color = color.white) 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) // }