커뮤니티

수고하십니다

프로필 이미지
비듬싸순
2024-12-27 01:44:43
644
글번호 186664
답변완료

첨부 이미지

올해도 수고 많으셨습니다 새해에복많이 받으시고 행복한 한해 되세요 변환 부탁드려요 길면 채널만이라도 부탁드립니다 indicator("Future Trend Channel [ChartPrime]", overlay = true, max_lines_count = 500) // --------------------------------------------------------------------------------------------------------------------} // &#120400;&#120398;&#120384;&#120397; &#120388;&#120393;&#120395;&#120400;&#120399;&#120398; // --------------------------------------------------------------------------------------------------------------------{ int length = input.int(100, "Trend Length") float multi = input.float(3, "Channel Width", step = 0.1) int extend = input.int(50, "Index of future price") color color_up = input.color(#16d897, "Up", inline = "Colors") color color_dn = input.color(#da853f, "Dn", inline = "Colors") float atr = ta.highest(ta.atr(200), 100) // UDT ------------------------------>> type channel line line_mid1 = na line line_mid2 = na line line_top1 = na line line_top2 = na line line_low1 = na line line_low2 = na var c = channel.new(line(na), line(na), line(na), line(na), line(na), line(na)) // --------------------------------------------------------------------------------------------------------------------} // &#120388;&#120393;&#120383;&#120388;&#120382;&#120380;&#120399;&#120394;&#120397; &#120382;&#120380;&#120391;&#120382;&#120400;&#120391;&#120380;&#120399;&#120388;&#120394;&#120393;&#120398; // --------------------------------------------------------------------------------------------------------------------{ future_price(x1,x2,y1,y2,index)=> float slope = (y2-y1)/(x2-x1) float future_price = y1 + slope * (index - x1) style = switch y1 > y2 =>label.style_label_lower_left =>label.style_label_upper_left label.new(index, future_price, text = str.tostring(future_price, "Future Price: ₩n #.#"), color = color.new(chart.fg_color, 80), textcolor = chart.fg_color, style = style) trend(length)=> var trend = bool(na) float sma = ta.sma(close, length) float upper = sma + atr float lower = sma - atr bool signal_up = ta.crossover(close, upper) bool signal_dn = ta.crossunder(close, lower) if signal_up trend := true if signal_dn trend := false trend bool trend = trend(length) remove_lines(trend)=> if trend and not trend[1] c.line_mid2 := line(na) c.line_top2 := line(na) c.line_low2 := line(na) if not trend and trend[1] c.line_mid1 := line(na) c.line_top1 := line(na) c.line_low1 := line(na) color_lines(line_m, line_t, line_l, color, label)=> var color_lines = color if color == color_up ? line_m.get_y1() <= line_m.get_y2() : line_m.get_y1() >= line_m.get_y2() color_lines := color line_m.set_color(color_lines) line_l.set_color(color_lines) line_t.set_color(color_lines) line_m.set_style(line.style_solid) line_t.set_style(line.style_solid) line_l.set_style(line.style_solid) label.set_color(label, color_lines) if color == color_up ? line_m.get_y1() >= line_m.get_y2() : line_m.get_y1() <= line_m.get_y2() color_lines := chart.fg_color line_m.set_color(color_lines) line_t.set_color(color_lines) line_l.set_color(color_lines) line_m.set_style(line.style_dashed) line_t.set_style(line.style_dashed) line_l.set_style(line.style_dashed) label.set_color(label, color.new(color_lines, 100)) label.set_size(label, size.tiny) linefill.new(line_l, line_t, color.new(color_lines, 90)) draw_channel(trend)=> var label_up = label(na) var label_dn = label(na) var label_m = label(na) series float src = hl2 series float low_src = src - atr * multi series float high_src = src + atr * multi // -> New Lines if trend and not trend[1] label_up := label.new(bar_index, low_src, style = label.style_diamond) c.line_mid1 := line.new(bar_index, src, bar_index, src) c.line_top1 := line.new(bar_index, high_src, bar_index, high_src) c.line_low1 := line.new(bar_index, low_src, bar_index, low_src) c.line_mid2.set_xy2(bar_index, src) c.line_top2.set_xy2(bar_index, high_src) c.line_low2.set_xy2(bar_index, low_src) if not trend and trend[1] label_dn := label.new(bar_index, high_src, style = label.style_diamond) c.line_mid2 := line.new(bar_index, src, bar_index+2, src) c.line_top2 := line.new(bar_index, high_src, bar_index, high_src) c.line_low2 := line.new(bar_index, low_src, bar_index, low_src) c.line_mid1.set_xy2(bar_index, src) c.line_top1.set_xy2(bar_index, high_src) c.line_low1.set_xy2(bar_index, low_src) // Extend if trend label.delete(label_m) c.line_mid2.set_extend(extend.none) c.line_top2.set_extend(extend.none) c.line_low2.set_extend(extend.none) c.line_mid1.set_extend(extend.right) c.line_top1.set_extend(extend.right) c.line_low1.set_extend(extend.right) c.line_mid1.set_xy2(bar_index, ta.sma(src, 20)) c.line_top1.set_xy2(bar_index, ta.sma(high_src, 20)) c.line_low1.set_xy2(bar_index, ta.sma(low_src, 20)) label_m := future_price(c.line_mid1.get_x1(), c.line_mid1.get_x2(), c.line_mid1.get_y1(), c.line_mid1.get_y2(), bar_index+extend) if not trend label.delete(label_m) c.line_mid1.set_extend(extend.none) c.line_top1.set_extend(extend.none) c.line_low1.set_extend(extend.none) c.line_mid2.set_extend(extend.right) c.line_top2.set_extend(extend.right) c.line_low2.set_extend(extend.right) c.line_mid2.set_xy2(bar_index, ta.sma(src, 20)) c.line_top2.set_xy2(bar_index, ta.sma(high_src, 20)) c.line_low2.set_xy2(bar_index, ta.sma(low_src, 20)) label_m := future_price(c.line_mid2.get_x1(), c.line_mid2.get_x2(), c.line_mid2.get_y1(), c.line_mid2.get_y2(), bar_index+extend) color_lines(c.line_mid1, c.line_top1, c.line_low1, color_up, label_up) color_lines(c.line_mid2, c.line_top2, c.line_low2, color_dn, label_dn) remove_lines(trend) // --------------------------------------------------------------------------------------------------------------------} // &#120401;&#120388;&#120398;&#120400;&#120380;&#120391;&#120388;&#120405;&#120380;&#120399;&#120388;&#120394;&#120393; // --------------------------------------------------------------------------------------------------------------------{ draw_channel(trend) // --------------------------------------------------------------------------------------------------------------------}
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2024-12-27 13:53:27

안녕하세요 예스스탁입니다. 올려주신 내용은 작성해 보는데 시간이 많이 걸리는 내용입니다. 업무상 일정시간 이상 요구되는 내용은 답변이 어렵습니다. 도움을 드리지 못해 죄송합니다. 즐거운 하루되세요 > 비듬싸순 님이 쓴 글입니다. > 제목 : 수고하십니다 > 올해도 수고 많으셨습니다 새해에복많이 받으시고 행복한 한해 되세요 변환 부탁드려요 길면 채널만이라도 부탁드립니다 indicator("Future Trend Channel [ChartPrime]", overlay = true, max_lines_count = 500) // --------------------------------------------------------------------------------------------------------------------} // &#120400;&#120398;&#120384;&#120397; &#120388;&#120393;&#120395;&#120400;&#120399;&#120398; // --------------------------------------------------------------------------------------------------------------------{ int length = input.int(100, "Trend Length") float multi = input.float(3, "Channel Width", step = 0.1) int extend = input.int(50, "Index of future price") color color_up = input.color(#16d897, "Up", inline = "Colors") color color_dn = input.color(#da853f, "Dn", inline = "Colors") float atr = ta.highest(ta.atr(200), 100) // UDT ------------------------------>> type channel line line_mid1 = na line line_mid2 = na line line_top1 = na line line_top2 = na line line_low1 = na line line_low2 = na var c = channel.new(line(na), line(na), line(na), line(na), line(na), line(na)) // --------------------------------------------------------------------------------------------------------------------} // &#120388;&#120393;&#120383;&#120388;&#120382;&#120380;&#120399;&#120394;&#120397; &#120382;&#120380;&#120391;&#120382;&#120400;&#120391;&#120380;&#120399;&#120388;&#120394;&#120393;&#120398; // --------------------------------------------------------------------------------------------------------------------{ future_price(x1,x2,y1,y2,index)=> float slope = (y2-y1)/(x2-x1) float future_price = y1 + slope * (index - x1) style = switch y1 > y2 =>label.style_label_lower_left =>label.style_label_upper_left label.new(index, future_price, text = str.tostring(future_price, "Future Price: ₩n #.#"), color = color.new(chart.fg_color, 80), textcolor = chart.fg_color, style = style) trend(length)=> var trend = bool(na) float sma = ta.sma(close, length) float upper = sma + atr float lower = sma - atr bool signal_up = ta.crossover(close, upper) bool signal_dn = ta.crossunder(close, lower) if signal_up trend := true if signal_dn trend := false trend bool trend = trend(length) remove_lines(trend)=> if trend and not trend[1] c.line_mid2 := line(na) c.line_top2 := line(na) c.line_low2 := line(na) if not trend and trend[1] c.line_mid1 := line(na) c.line_top1 := line(na) c.line_low1 := line(na) color_lines(line_m, line_t, line_l, color, label)=> var color_lines = color if color == color_up ? line_m.get_y1() <= line_m.get_y2() : line_m.get_y1() >= line_m.get_y2() color_lines := color line_m.set_color(color_lines) line_l.set_color(color_lines) line_t.set_color(color_lines) line_m.set_style(line.style_solid) line_t.set_style(line.style_solid) line_l.set_style(line.style_solid) label.set_color(label, color_lines) if color == color_up ? line_m.get_y1() >= line_m.get_y2() : line_m.get_y1() <= line_m.get_y2() color_lines := chart.fg_color line_m.set_color(color_lines) line_t.set_color(color_lines) line_l.set_color(color_lines) line_m.set_style(line.style_dashed) line_t.set_style(line.style_dashed) line_l.set_style(line.style_dashed) label.set_color(label, color.new(color_lines, 100)) label.set_size(label, size.tiny) linefill.new(line_l, line_t, color.new(color_lines, 90)) draw_channel(trend)=> var label_up = label(na) var label_dn = label(na) var label_m = label(na) series float src = hl2 series float low_src = src - atr * multi series float high_src = src + atr * multi // -> New Lines if trend and not trend[1] label_up := label.new(bar_index, low_src, style = label.style_diamond) c.line_mid1 := line.new(bar_index, src, bar_index, src) c.line_top1 := line.new(bar_index, high_src, bar_index, high_src) c.line_low1 := line.new(bar_index, low_src, bar_index, low_src) c.line_mid2.set_xy2(bar_index, src) c.line_top2.set_xy2(bar_index, high_src) c.line_low2.set_xy2(bar_index, low_src) if not trend and trend[1] label_dn := label.new(bar_index, high_src, style = label.style_diamond) c.line_mid2 := line.new(bar_index, src, bar_index+2, src) c.line_top2 := line.new(bar_index, high_src, bar_index, high_src) c.line_low2 := line.new(bar_index, low_src, bar_index, low_src) c.line_mid1.set_xy2(bar_index, src) c.line_top1.set_xy2(bar_index, high_src) c.line_low1.set_xy2(bar_index, low_src) // Extend if trend label.delete(label_m) c.line_mid2.set_extend(extend.none) c.line_top2.set_extend(extend.none) c.line_low2.set_extend(extend.none) c.line_mid1.set_extend(extend.right) c.line_top1.set_extend(extend.right) c.line_low1.set_extend(extend.right) c.line_mid1.set_xy2(bar_index, ta.sma(src, 20)) c.line_top1.set_xy2(bar_index, ta.sma(high_src, 20)) c.line_low1.set_xy2(bar_index, ta.sma(low_src, 20)) label_m := future_price(c.line_mid1.get_x1(), c.line_mid1.get_x2(), c.line_mid1.get_y1(), c.line_mid1.get_y2(), bar_index+extend) if not trend label.delete(label_m) c.line_mid1.set_extend(extend.none) c.line_top1.set_extend(extend.none) c.line_low1.set_extend(extend.none) c.line_mid2.set_extend(extend.right) c.line_top2.set_extend(extend.right) c.line_low2.set_extend(extend.right) c.line_mid2.set_xy2(bar_index, ta.sma(src, 20)) c.line_top2.set_xy2(bar_index, ta.sma(high_src, 20)) c.line_low2.set_xy2(bar_index, ta.sma(low_src, 20)) label_m := future_price(c.line_mid2.get_x1(), c.line_mid2.get_x2(), c.line_mid2.get_y1(), c.line_mid2.get_y2(), bar_index+extend) color_lines(c.line_mid1, c.line_top1, c.line_low1, color_up, label_up) color_lines(c.line_mid2, c.line_top2, c.line_low2, color_dn, label_dn) remove_lines(trend) // --------------------------------------------------------------------------------------------------------------------} // &#120401;&#120388;&#120398;&#120400;&#120380;&#120391;&#120388;&#120405;&#120380;&#120399;&#120388;&#120394;&#120393; // --------------------------------------------------------------------------------------------------------------------{ draw_channel(trend) // --------------------------------------------------------------------------------------------------------------------}