커뮤니티

TradingView의 수식을 yestrader로 변환을 했는데 수정을 부탁합니다

프로필 이미지
고도산
2025-03-02 20:27:48
479
글번호 188704
답변완료
첨부와 같이 변환을 했는데 만족스럽지 못합니다. 수정을 부탁합니다. // &#169; BigBeluga //@version=6 indicator('Range Breakout [BigBeluga]', overlay = true, max_lines_count = 4, max_labels_count = 500) // INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ int length = 100 // Length of the line extension float multi = input.float(4, 'Channel Width', step = 0.1) // Multiplier for channel width bool show_x = input.bool(false, "Show X signals") bool filter_sig = input.bool(false, "Filter Signals by Trends", "If True indicator filters ▲▼ based on channels breakout condition. If channel is bullish with green circle only ▲ displayed if bearish with red only ▼ signals displayed") color color1 = input.color(#ffff00, "", inline = "col", group = "OB/OS") color color3 = input.color(color.lime, "", inline = "col", group = "OB/OS") bool gradient = input.bool(true, "Gradient", inline = "ll", group = "OB/OS") int transp = input.int(80, "", inline = "ll", group = "OB/OS") color color2 = chart.fg_color // Mid line color // Initialize Variables var float value = na var float value_upper = na var float value_lower = na var float value_upper_mid = na var float value_lower_mid = na var bool trend = false var count = 0 // } // CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ float atr = ta.sma(ta.atr(200), 100) * multi // ATR-based channel width // Initialize channel values if bar_index == 301 value := hl2 value_upper := hl2 + atr value_lower := hl2 - atr value_upper_mid := math.avg(value, value_upper) value_lower_mid := math.avg(value, value_lower) value_lower_mid // Check for crossovers bool cross_upper = ta.crossover(low, value_upper) and barstate.isconfirmed bool cross_lower = ta.crossunder(high, value_lower) and barstate.isconfirmed // Count bars outside the channel if low > value_upper or high < value_lower count := count + 1 count // Reset channel values on crossover or after 100 bars if cross_upper or cross_lower or count == 100 count := 0 value := hl2 value_upper := hl2 + atr value_lower := hl2 - atr value_upper_mid := math.avg(value, value_upper) value_lower_mid := math.avg(value, value_lower) value_lower_mid bool chage = not(value != value[1]) bool buy_ = ta.crossover(low, value_lower_mid) and low[10] > value_lower_mid and barstate.isconfirmed and chage bool sell_ = ta.crossunder(high, value_upper_mid) and high[10] < value_upper_mid and barstate.isconfirmed and chage bool fakeout_up = ta.crossunder(high, value_upper) and barstate.isconfirmed and chage bool fakeout_dn = ta.crossover(low, value_lower) and barstate.isconfirmed and chage // } // PLOT ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ // Plot and fill lines p1 = plot(value_upper != value_upper[1] ? na : value_upper, color = color1, linewidth = 1, style = plot.style_linebr) p0 = plot(bar_index % 2 == 0 ? value : na, color = color2, style = plot.style_linebr) p2 = plot(value_lower != value_lower[1] ? na : value_lower, color = color3, linewidth = 1, style = plot.style_linebr) upper_mid = math.avg(value_upper, value) lower_mid = math.avg(value_lower, value) p01 = plot(upper_mid != upper_mid[1] ? na : upper_mid, color = color.new(color2, 50), style = plot.style_linebr) p02 = plot(lower_mid != lower_mid[1] ? na : lower_mid, color = color.new(color2, 50), style = plot.style_linebr) fill(p1, p01, value_upper, value, color.new(value_upper != value_upper[1] ? na : color1, transp), color.new(value_upper != value_upper[1] ? na : color1, gradient ? 100 : transp)) fill(p2, p02, value, value_lower, color.new(value_upper != value_upper[1] ? na : color3, gradient ? 100 : transp), color.new(value_upper != value_upper[1] ? na : color3, transp)) // Plot cross signals if cross_upper trend := true label.new(bar_index - 1, value_upper[1], text = '▲', textcolor = color1, style = label.style_label_center, color = color(na), size = size.large, tooltip = "Bullish Break") if cross_lower trend := false label.new(bar_index - 1, value_lower[1], text = '▼', textcolor = color3, style = label.style_label_center, color = color(na), size = size.large, tooltip = "Bearish Break") if buy_ and (filter_sig ? trend : true) label.new(bar_index - 1, low[1], text = '▲', textcolor = color1, style = label.style_label_up, color = color(na), size = size.normal) if sell_ and (filter_sig ? not trend : true) label.new(bar_index - 1, high[1], text = '▼', textcolor = color3, style = label.style_label_down, color = color(na), size = size.normal) if fakeout_up and show_x label.new(bar_index - 1, high[1], text = 'X', textcolor = color3, style = label.style_label_down, color = color(na), size = size.normal) if fakeout_dn and show_x label.new(bar_index - 1, low[1], text = 'X', textcolor = color1, style = label.style_label_up, color = color(na), size = size.normal) // }
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-03-04 15:57:58

안녕하세요 예스스탁입니다. input : length(100); input : multi(4); input : show_x(false); input : filter_sig(false); input : color1(Green); input : color3(Red); input : color2(Black); input : gradient(true); input : transp(80); var : value(nan); var : value_upper(nan); var : value_lower(nan); var : value_upper_mid(nan); var : value_lower_mid(nan); var : trend(False); var : count(0); var : alpha(0),sum(0), A(0); alpha = 1/200; sum = iff(IsNaN(sum[1]) == true , ma(TrueRange, length) , alpha * TrueRange + (1 - alpha) * IFf(IsNaN(sum[1])==true,0,sum[1])); A = ma(sum, 100) * multi; // Initialize channel values if index == 301 Then { value = (h+l)/2; value_upper = (h+l)/2 + A; value_lower = (h+l)/2 - A; value_upper_mid = avg(value, value_upper); value_lower_mid = avg(value, value_lower); } var : cross_upper(False),cross_lower(False); cross_upper = CrossUp(low, value_upper); cross_lower = CrossDown(high, value_lower); if low > value_upper or high < value_lower Then count = count + 1; if cross_upper or cross_lower or count == 100 Then { count = 0; value = (h+l)/2; value_upper = (h+l)/2 + A; value_lower = (h+l)/2 - A; value_upper_mid = avg(value, value_upper); value_lower_mid = avg(value, value_lower); } var : chage(False),buy_(false),sell_(False),fakeout_up(False),fakeout_dn(False); chage = !(value != value[1]); buy_ = CrossUp(low, value_lower_mid) and low[10] > value_lower_mid and chage; sell_ = CrossDown(high, value_upper_mid) and high[10] < value_upper_mid and chage; fakeout_up = CrossDown(high, value_upper) and chage; fakeout_dn = crossup(low, value_lower) and chage; if value_upper != value_upper[1] Then NoPlot(1); Else Plot1(value_upper,"value_upper",color1); if value_upper != value_upper[1] Then NoPlot(2); Else plot2(value,"value_mid"); if value_lower != value_lower[1] Then NoPlot(3); Else plot3(value_lower,"value_lower",color3); var : upper_mid(0),lower_mid(0); upper_mid = avg(value_upper, value); lower_mid = avg(value_lower, value); if upper_mid != upper_mid[1] Then NoPlot(4); Else plot4(upper_mid,"upper_mid",color1); if lower_mid != lower_mid[1] Then NoPlot(5); Else plot5(lower_mid,"lower_mid",color1); var : tx(0); if cross_upper Then { tx = Text_New(sDate,sTime,L,"▲"); Text_SetStyle(tx,2,0); Text_SetColor(tx,color1); } if cross_lower Then { tx = Text_New(sDate,sTime,H,"▼"); Text_SetStyle(tx,2,1); Text_SetColor(tx,color3); } 즐거운 하루되세요 > 고도산 님이 쓴 글입니다. > 제목 : TradingView의 수식을 yestrader로 변환을 했는데 수정을 부탁합니다 > 첨부와 같이 변환을 했는데 만족스럽지 못합니다. 수정을 부탁합니다. // &#169; BigBeluga //@version=6 indicator('Range Breakout [BigBeluga]', overlay = true, max_lines_count = 4, max_labels_count = 500) // INPUTS ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ int length = 100 // Length of the line extension float multi = input.float(4, 'Channel Width', step = 0.1) // Multiplier for channel width bool show_x = input.bool(false, "Show X signals") bool filter_sig = input.bool(false, "Filter Signals by Trends", "If True indicator filters ▲▼ based on channels breakout condition. If channel is bullish with green circle only ▲ displayed if bearish with red only ▼ signals displayed") color color1 = input.color(#ffff00, "", inline = "col", group = "OB/OS") color color3 = input.color(color.lime, "", inline = "col", group = "OB/OS") bool gradient = input.bool(true, "Gradient", inline = "ll", group = "OB/OS") int transp = input.int(80, "", inline = "ll", group = "OB/OS") color color2 = chart.fg_color // Mid line color // Initialize Variables var float value = na var float value_upper = na var float value_lower = na var float value_upper_mid = na var float value_lower_mid = na var bool trend = false var count = 0 // } // CALCULATIONS――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ float atr = ta.sma(ta.atr(200), 100) * multi // ATR-based channel width // Initialize channel values if bar_index == 301 value := hl2 value_upper := hl2 + atr value_lower := hl2 - atr value_upper_mid := math.avg(value, value_upper) value_lower_mid := math.avg(value, value_lower) value_lower_mid // Check for crossovers bool cross_upper = ta.crossover(low, value_upper) and barstate.isconfirmed bool cross_lower = ta.crossunder(high, value_lower) and barstate.isconfirmed // Count bars outside the channel if low > value_upper or high < value_lower count := count + 1 count // Reset channel values on crossover or after 100 bars if cross_upper or cross_lower or count == 100 count := 0 value := hl2 value_upper := hl2 + atr value_lower := hl2 - atr value_upper_mid := math.avg(value, value_upper) value_lower_mid := math.avg(value, value_lower) value_lower_mid bool chage = not(value != value[1]) bool buy_ = ta.crossover(low, value_lower_mid) and low[10] > value_lower_mid and barstate.isconfirmed and chage bool sell_ = ta.crossunder(high, value_upper_mid) and high[10] < value_upper_mid and barstate.isconfirmed and chage bool fakeout_up = ta.crossunder(high, value_upper) and barstate.isconfirmed and chage bool fakeout_dn = ta.crossover(low, value_lower) and barstate.isconfirmed and chage // } // PLOT ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――{ // Plot and fill lines p1 = plot(value_upper != value_upper[1] ? na : value_upper, color = color1, linewidth = 1, style = plot.style_linebr) p0 = plot(bar_index % 2 == 0 ? value : na, color = color2, style = plot.style_linebr) p2 = plot(value_lower != value_lower[1] ? na : value_lower, color = color3, linewidth = 1, style = plot.style_linebr) upper_mid = math.avg(value_upper, value) lower_mid = math.avg(value_lower, value) p01 = plot(upper_mid != upper_mid[1] ? na : upper_mid, color = color.new(color2, 50), style = plot.style_linebr) p02 = plot(lower_mid != lower_mid[1] ? na : lower_mid, color = color.new(color2, 50), style = plot.style_linebr) fill(p1, p01, value_upper, value, color.new(value_upper != value_upper[1] ? na : color1, transp), color.new(value_upper != value_upper[1] ? na : color1, gradient ? 100 : transp)) fill(p2, p02, value, value_lower, color.new(value_upper != value_upper[1] ? na : color3, gradient ? 100 : transp), color.new(value_upper != value_upper[1] ? na : color3, transp)) // Plot cross signals if cross_upper trend := true label.new(bar_index - 1, value_upper[1], text = '▲', textcolor = color1, style = label.style_label_center, color = color(na), size = size.large, tooltip = "Bullish Break") if cross_lower trend := false label.new(bar_index - 1, value_lower[1], text = '▼', textcolor = color3, style = label.style_label_center, color = color(na), size = size.large, tooltip = "Bearish Break") if buy_ and (filter_sig ? trend : true) label.new(bar_index - 1, low[1], text = '▲', textcolor = color1, style = label.style_label_up, color = color(na), size = size.normal) if sell_ and (filter_sig ? not trend : true) label.new(bar_index - 1, high[1], text = '▼', textcolor = color3, style = label.style_label_down, color = color(na), size = size.normal) if fakeout_up and show_x label.new(bar_index - 1, high[1], text = 'X', textcolor = color3, style = label.style_label_down, color = color(na), size = size.normal) if fakeout_dn and show_x label.new(bar_index - 1, low[1], text = 'X', textcolor = color1, style = label.style_label_up, color = color(na), size = size.normal) // }