//@version=6 indicator("RaXtFX_SRTP.pv02", overlay=true, max_labels_count=500, max_bars_back=1000) // ============================================================================ // SECTION 1 — Pivot Points High Low (original: //@version=6) // ============================================================================ phlColorGroupTitle = "PHL — Colors" // پارامترهای عددی به ثابت تبدیل شدند phL_leftLenH = 20 phL_rightLenH = 20 phL_leftLenL = 20 phL_rightLenL = 20 // پارامترهای رنگ قابل تنظیم باقی ماندند phL_textColorH = input.color(color.black, "Pivot High Text", inline="Pivot High", group=phlColorGroupTitle) phL_labelColorH = input.color(color.white, "Pivot High Label", inline="Pivot High", group=phlColorGroupTitle) phL_textColorL = input.color(color.black, "Pivot Low Text", inline="Pivot Low", group=phlColorGroupTitle) phL_labelColorL = input.color(color.white, "Pivot Low Label", inline="Pivot Low", group=phlColorGroupTitle) // شکل و اندازه به ثابت تبدیل شدند phL_markerShape = "Triangle" phL_markerSize = "Tiny" phL_ph = ta.pivothigh(phL_leftLenH, phL_rightLenH) phL_pl = ta.pivotlow(phL_leftLenL, phL_rightLenL) phL_markerSizeVal = size.tiny phL_shapeHigh = shape.triangledown phL_shapeLow = shape.triangleup phL_isTri = true phL_isCir = false phL_isTiny = true phL_isSmall = false phL_isNormal = false plotshape(phL_isTri and phL_isTiny ? phL_ph : na, title="Pivot High Tri Tiny", style=shape.triangledown, size=size.tiny, location=location.abovebar, color=phL_labelColorH, offset=-phL_rightLenH) plotshape(phL_isTri and phL_isTiny ? phL_pl : na, title="Pivot Low Tri Tiny", style=shape.triangleup, size=size.tiny, location=location.belowbar, color=phL_labelColorL, offset=-phL_rightLenL) // ============================================================================ // SECTION 2 — Support and Resistance Levels with Breaks // ============================================================================ srColorGroupTitle = "SR — Colors" // پارامترهای رنگ قابل تنظیم SR_resistanceColor = input.color(#FF0000, "Resistance", group=srColorGroupTitle) SR_supportColor = input.color(#233dee, "Support", group=srColorGroupTitle) // پارامترهای عددی به ثابت تبدیل شدند SR_toggleBreaks = true SR_leftBars = 20 SR_rightBars = 20 SR_volumeThresh = 20 SR_pivotHigh = ta.pivothigh(SR_leftBars, SR_rightBars) SR_pivotLow = ta.pivotlow(SR_leftBars, SR_rightBars) // Resistance line var line SR_highLine = na var float SR_highLevel = na var bool SR_highBroken = false if not na(SR_pivotHigh) SR_highLevel := SR_pivotHigh SR_highBroken := false SR_highLine := line.new(bar_index - SR_rightBars, SR_highLevel, bar_index, SR_highLevel, color=SR_resistanceColor, width=3) else if not na(SR_highLine) and not (SR_toggleBreaks and SR_highBroken) line.set_x2(SR_highLine, bar_index) line.set_y2(SR_highLine, SR_highLevel) if not na(SR_highLevel) and high > SR_highLevel SR_highBroken := true // Support line var line SR_lowLine = na var float SR_lowLevel = na var bool SR_lowBroken = false if not na(SR_pivotLow) SR_lowLevel := SR_pivotLow SR_lowBroken := false SR_lowLine := line.new(bar_index - SR_rightBars, SR_lowLevel, bar_index, SR_lowLevel, color=SR_supportColor, width=3) else if not na(SR_lowLine) and not (SR_toggleBreaks and SR_lowBroken) line.set_x2(SR_lowLine, bar_index) line.set_y2(SR_lowLine, SR_lowLevel) if not na(SR_lowLevel) and low < SR_lowLevel SR_lowBroken := true // Volume SR_short = ta.ema(volume, 5) SR_long = ta.ema(volume, 10) SR_osc = 100 * (SR_short - SR_long) / SR_long SR_crossUnderLow = ta.crossunder(close, SR_lowLevel) SR_crossOverHigh = ta.crossover(close, SR_highLevel) alertcondition(SR_crossUnderLow and SR_osc > SR_volumeThresh, title="Support Broken", message="Support Broken") alertcondition(SR_crossOverHigh and SR_osc > SR_volumeThresh, title="Resistance Broken", message="Resistance Broken") // ============================================================================ // SECTION 3 — Trendline Pivots // ============================================================================ tlGroupTitle = "TL — Colors" // پارامترهای رنگ قابل تنظیم TL_dtlColor = input.color(color.red, 'Down Trend Line Color', inline='0', group=tlGroupTitle) TL_utlColor = input.color(color.green, 'Up Trend Line Color', inline='1', group=tlGroupTitle) TL_pastColor = input.color(color.orange, 'Crossed Line Color', inline='2', group=tlGroupTitle) TL_crossDown = input.color(color.red, 'Cross Below Color', inline='5', group=tlGroupTitle) TL_crossUp = input.color(color.lime, 'Cross Above Color', inline='5', group=tlGroupTitle) // پارامترهای عددی به ثابت تبدیل شدند TL_extendLine = false TL_onlyLast = false TL_hideCrossed = false TL_showCross = false TL_maxLines = 4 TL_crossSrc = 'Close' TL_maxLineLen = 252 TL_pivLen = 20 TL_isLog = false TL_maxLinesEff = TL_hideCrossed ? 0 : TL_maxLines type TLPivot string pivType int x1 float y1 int x2 float y2 var line[] TL_dtlArray = array.new_line() var line[] TL_utlArray = array.new_line() TL_createLine(ptype, x1, y1, x2, y2) => piv = TLPivot.new(ptype, x1, y1, x2, y2) trendline = line.new(x1, y1, x2, y2, extend=TL_extendLine ? extend.right : extend.none, color=ptype == 'ph' ? TL_dtlColor : TL_utlColor, width=2) if ptype == 'ph' TL_dtlArray.unshift(trendline) else if ptype == 'pl' TL_utlArray.unshift(trendline) piv TL_getSlope(ln) => slopePh = (line.get_y2(ln) - line.get_y1(ln)) / (line.get_x2(ln) - line.get_x1(ln)) extendedPh = line.get_y2(ln) - slopePh * (line.get_x2(ln) - bar_index) extendedPh TL_getSlopeLog(ln) => slopePh = (math.log(line.get_y2(ln)) - math.log(line.get_y1(ln))) / (line.get_x2(ln) - line.get_x1(ln)) extendedPh = math.exp(math.log(line.get_y2(ln)) - slopePh * (line.get_x2(ln) - bar_index)) extendedPh TL_ph = ta.pivothigh(high, TL_pivLen, TL_pivLen) TL_pl = ta.pivotlow(low, TL_pivLen, TL_pivLen) var int TL_utlX1 = na, var float TL_utlY1 = na var int TL_utlX2 = na, var float TL_utlY2 = na var int TL_dtlX2 = na, var float TL_dtlY2 = na var int TL_dtlX1 = na, var float TL_dtlY1 = na if not na(TL_pl) TL_utlX1 := TL_utlX2 TL_utlY1 := TL_utlY2 TL_utlX2 := bar_index[TL_pivLen] TL_utlY2 := low[TL_pivLen] if TL_utlY1 < TL_utlY2 TL_createLine('pl', TL_utlX1, TL_utlY1, TL_utlX2, TL_utlY2) if not na(TL_ph) TL_dtlX1 := TL_dtlX2 TL_dtlY1 := TL_dtlY2 TL_dtlX2 := bar_index[TL_pivLen] TL_dtlY2 := high[TL_pivLen] if TL_dtlY1 > TL_dtlY2 TL_createLine('ph', TL_dtlX1, TL_dtlY1, TL_dtlX2, TL_dtlY2) for l in TL_utlArray src = TL_crossSrc == 'Close' ? close : low first = l == TL_utlArray.get(0) extended = not TL_isLog ? TL_getSlope(l) : TL_getSlopeLog(l) l.set_xy2(bar_index, extended) if l.get_x2() - l.get_x1() > TL_maxLineLen l.delete() if src > line.get_price(l, bar_index) and not first and TL_onlyLast l.delete() var line[] tempUtl = array.new_line(TL_maxLinesEff / 2) var label[] tempUL = array.new_label(TL_maxLinesEff / 2) if src < line.get_price(l, bar_index) newLine = line.new(line.get_x1(l), line.get_y1(l), line.get_x2(l), line.get_y2(l), color=TL_pastColor, style=line.style_dashed, width=1) crossLabel = TL_showCross ? label.new(bar_index, low, ' ', yloc=yloc.belowbar, color=TL_crossDown, style=label.style_xcross, size=size.tiny) : na alert(str.tostring(syminfo.ticker) + ' crossing below trendline', alert.freq_once_per_bar) line.delete(l) tempUtl.unshift(newLine) tempUL.unshift(crossLabel) if tempUtl.size() > (TL_maxLinesEff / 2) line.delete(tempUtl.pop()) label.delete(tempUL.pop()) for l in TL_dtlArray first = l == TL_dtlArray.get(0) src = TL_crossSrc == 'Close' ? close : high extended = not TL_isLog ? TL_getSlope(l) : TL_getSlopeLog(l) l.set_xy2(bar_index, extended) if l.get_x2() - l.get_x1() > TL_maxLineLen l.delete() if src < line.get_price(l, bar_index) and not first and TL_onlyLast l.delete() var line[] tempDtl = array.new_line(TL_maxLinesEff / 2) var label[] tempDL = array.new_label(TL_maxLinesEff / 2) if src > line.get_price(l, bar_index) newLine = line.new(line.get_x1(l), line.get_y1(l), line.get_x2(l), line.get_y2(l), color=TL_pastColor, style=line.style_dashed, width=1) crossLabel = TL_showCross ? label.new(bar_index, high, '', yloc=yloc.abovebar, style=label.style_xcross, color=TL_crossUp, size=size.tiny) : na alert(str.tostring(syminfo.ticker) + ' crossing above trendline', alert.freq_once_per_bar) line.delete(l) tempDtl.unshift(newLine) tempDL.unshift(crossLabel) if tempDtl.size() > (TL_maxLinesEff / 2) line.delete(tempDtl.pop()) label.delete(tempDL.pop())