Untitled
//@version=5 indicator('RSN_TRENDLINES', overlay = true, max_lines_count = 500) // Kalan kod aynı şekilde devam ediyor import HoanGhetti/SimpleTrendlines/4 as tl input_len = input.int(defval = 20, title = 'Pivot Length', minval = 1) input_pivotType = 'Normal' // Değeri doğrudan atayın input_repaint = true input_targets = false // Sabit olarak tanımlayın, input yerine input_bearC = input.color(defval = color.red, title = 'Bear', group = 'Stil', inline = 'grup1') input_bullC = input.color(defval = color.green, title = 'Bull', group = 'Stil', inline = 'grup1') input_extend = extend.none input_style = line.style_dotted input_tstyle = line.style_dashed input_override = false input_useSrc = true input_source = close pl = fixnan(ta.pivotlow(input_override ? input_source : low, input_pivotType == 'Normal' ? input_len : 1, input_len)) ph = fixnan(ta.pivothigh(input_override ? input_source : high, input_pivotType == 'Normal' ? input_len : 1, input_len)) pivot(float pType) => pivot = pType == pl ? pl : ph xAxis = ta.valuewhen(bool(ta.change(pivot)), bar_index, 0) - ta.valuewhen(bool(ta.change(pivot)), bar_index, 1) prevPivot = ta.valuewhen(bool(ta.change(pivot)), pivot, 1) pivotCond = bool(ta.change(pivot)) and (pType == pl ? pivot > prevPivot : pivot < prevPivot) // strictMode 'true' ve strictType için sabit değer kullanılıyor pData = tl.new(x_axis = xAxis, offset = input_len, strictMode = true, strictType = (pType == pl ? 0 : 1)) pData.drawLine(pivotCond, prevPivot, pivot, input_override ? input_source : na) pData breakout(tl.Trendline this, float pType) => var bool hasCrossed = false if bool(ta.change(this.lines.startline.get_y1())) hasCrossed := false hasCrossed this.drawTrendline(not hasCrossed) confirmation = not hasCrossed and (input_repaint ? not hasCrossed : barstate.isconfirmed) if (pType == pl ? (input_override and input_useSrc ? input_source : close) < this.lines.trendline.get_y2() : (input_override and input_useSrc ? input_source : close) > this.lines.trendline.get_y2()) and confirmation hasCrossed := true this.lines.startline.set_xy2(this.lines.trendline.get_x2(), this.lines.trendline.get_y2()) this.lines.trendline.set_xy2(na, na) this.lines.startline.copy() hasCrossed plData = pivot(pl) phData = pivot(ph) style(tl.Trendline this, color col) => this.lines.startline.set_color(col) this.lines.trendline.set_color(col) this.lines.startline.set_width(2) this.lines.trendline.set_width(2) this.lines.trendline.set_style(input_style) this.lines.trendline.set_extend(input_extend) style(plData, input_bearC) style(phData, input_bullC) cu = breakout(plData, pl) co = breakout(phData, ph) plotshape(ta.change(cu) and cu ? plData.lines.startline.get_y2() : na, title = 'Trend Aşağı Kırıldı', style = shape.labeldown, color = input_bearC, textcolor = color.white, location = location.absolute) plotshape(ta.change(co) and co ? phData.lines.startline.get_y2() : na, title = 'Trend Yukarı Kırıldı', style = shape.labelup, color = input_bullC, textcolor = color.white, location = location.absolute) alertcondition(ta.change(cu) and cu, 'Trend Aşağı Kırıldı') alertcondition(ta.change(co) and co, 'Trend Yukarı Kırıldı') // Target Levels [v4 Update] phData_target = tl.new(phData.values.changeInX) plData_target = tl.new(plData.values.changeInX) phData_target.drawLine(bool(ta.change(phData.values.y1)) and input_targets, phData.values.y2, phData.values.y2) plData_target.drawLine(bool(ta.change(plData.values.y1)) and input_targets, plData.values.y2, plData.values.y2) target_style(tl.Trendline this, color col) => this.lines.startline.set_style(input_tstyle) this.lines.trendline.set_style(input_tstyle) this.lines.startline.set_color(col) this.lines.trendline.set_color(col) target_style(plData_target, input_bearC) target_style(phData_target, input_bullC) breakout(phData_target, ph) breakout(plData_target, pl)
Leave a Comment