本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator('Ultimate_Priceaction_Tool for INTRADAY by Chaitu50c', overlay = true)
//── Inputs ────────────────────────────────────────────────────────────────────
buffer = input.float(3.0, 'Match Buffer (pts)', step = 0.1)
breakoutBuffer = input.float(3.0, 'Base Breakout Buffer (pts)', step = 0.1)
maxBuffer = input.float(15.0, 'Max Breakout Buffer for thick lines (pts)', step = 0.1)
dashSkip = input.float(30.0, 'Trend Continuation lines Suppression Range (Dashed Lines)', step = 0.1)
resColor = input.color(color.red, 'Resistance Line Color')
supColor = input.color(color.green, 'Support Line Color')
baseWidth = input.int(2, 'Base Line Width', minval = 1)
widthStepBars = input.int(10, 'Bars per Width Increment', minval = 1)
maxDynamicWidth = input.int(10, 'Max Dynamic Width', minval = 1)
//── Pattern definitions ─────────────────────────────────────────────────────────
patGR = close[1] > open[1] and close < open and math.abs(close[1] - open) <= buffer
patRG = close[1] < open[1] and close > open and math.abs(close[1] - open) <= buffer
bodyPrev = math.abs(close[1] - open[1])
bodyCurr = math.abs(close - open)
twoBarRes = close[2] > open[2] and close[1] < open[1] and close[1] >= low[2] and close < low[2]
twoBarSup = close[2] < open[2] and close[1] > open[1] and close[1] <= high[2] and close > high[2]
//── Storage ────────────────────────────────────────────────────────────────────
var line resLine = na
var float resLevel = na
var bool resFirst = true
var int resCreatedAt = na
var line supLine = na
var float supLevel = na
var bool supFirst = true
var int supCreatedAt = na
var array<line> dashedSup = array.new_line()
var array<line> dashedRes = array.new_line()
//── Dynamic‐buffer vars ─────────────────────────────────────────────────────────
var float dynResBuf = breakoutBuffer
var float dynSupBuf = breakoutBuffer
//── Compute dynamic buffers & widths ────────────────────────────────────────────
if not na(resCreatedAt)
ageRes = bar_index - resCreatedAt
stepsRes = math.floor(ageRes / widthStepBars)
newWRes = math.min(baseWidth + stepsRes, maxDynamicWidth)
dynResBuf := math.min(breakoutBuffer + stepsRes, maxBuffer)
line.set_width(resLine, newWRes)
else
dynResBuf := breakoutBuffer
dynResBuf
if not na(supCreatedAt)
ageSup = bar_index - supCreatedAt
stepsSup = math.floor(ageSup / widthStepBars)
newWSup = math.min(baseWidth + stepsSup, maxDynamicWidth)
dynSupBuf := math.min(breakoutBuffer + stepsSup, maxBuffer)
line.set_width(supLine, newWSup)
else
dynSupBuf := breakoutBuffer
dynSupBuf
//── Session reset ───────────────────────────────────────────────────────────────
if ta.change(time('D')) != 0
if not na(resLine)
line.delete(resLine)
if not na(supLine)
line.delete(supLine)
resLine := na
resLevel := na
resFirst := true
resCreatedAt := na
supLine := na
supLevel := na
supFirst := true
supCreatedAt := na
// clear dashedSup
supCount = array.size(dashedSup)
if supCount > 0
for j = 0 to supCount - 1 by 1
idx = supCount - 1 - j
line.delete(array.get(dashedSup, idx))
array.remove(dashedSup, idx)
// clear dashedRes
resCount = array.size(dashedRes)
if resCount > 0
for j = 0 to resCount - 1 by 1
idx = resCount - 1 - j
line.delete(array.get(dashedRes, idx))
array.remove(dashedRes, idx)
//── Break/Delete main lines using dynamic buffers ──────────────────────────────
if not na(resLine) and close > resLevel + dynResBuf
line.delete(resLine)
resLine := na
resLevel := na
resLevel
if not na(supLine) and close < supLevel - dynSupBuf
line.delete(supLine)
supLine := na
supLevel := na
supLevel
//── Break/Delete dashed lines ──────────────────────────────────────────────────
supCount2 = array.size(dashedSup)
if supCount2 > 0
for j = 0 to supCount2 - 1 by 1
idx = supCount2 - 1 - j
l = array.get(dashedSup, idx)
lvl = line.get_y1(l)
if close < lvl - breakoutBuffer
line.delete(l)
array.remove(dashedSup, idx)
resCount2 = array.size(dashedRes)
if resCount2 > 0
for j = 0 to resCount2 - 1 by 1
idx = resCount2 - 1 - j
l = array.get(dashedRes, idx)
lvl = line.get_y1(l)
if close > lvl + breakoutBuffer
line.delete(l)
array.remove(dashedRes, idx)
//── Main resistance creation ───────────────────────────────────────────────────
if na(resLine)
if resFirst and patGR
resLevel := close[1]
resLine := line.new(bar_index, resLevel, bar_index + 1, resLevel, xloc.bar_index, extend = extend.both, color = resColor, width = baseWidth)
resCreatedAt := bar_index
resFirst := false
resFirst
else if patGR and bodyCurr > bodyPrev or twoBarRes
lvl = twoBarRes ? close[2] : close[1]
resLevel := lvl
resLine := line.new(bar_index, lvl, bar_index + 1, lvl, xloc.bar_index, extend = extend.both, color = resColor, width = baseWidth)
resCreatedAt := bar_index
resCreatedAt
//── Main support creation ──────────────────────────────────────────────────────
if na(supLine)
if supFirst and patRG
supLevel := close[1]
supLine := line.new(bar_index, supLevel, bar_index + 1, supLevel, xloc.bar_index, extend = extend.both, color = supColor, width = baseWidth)
supCreatedAt := bar_index
supFirst := false
supFirst
else if patRG and bodyCurr > bodyPrev or twoBarSup
lvl2 = twoBarSup ? close[2] : close[1]
supLevel := lvl2
supLine := line.new(bar_index, lvl2, bar_index + 1, lvl2, xloc.bar_index, extend = extend.both, color = supColor, width = baseWidth)
supCreatedAt := bar_index
supCreatedAt
//── Inside-range dashed lines ──────────────────────────────────────────────────
if not na(resLine) and not na(supLine)
lowLvl = math.min(resLevel, supLevel)
highLvl = math.max(resLevel, supLevel)
insideSup = patRG and bodyCurr > bodyPrev or twoBarSup
priceSup = twoBarSup ? close[2] : close[1]
skipSup = math.abs(priceSup - supLevel) <= dashSkip
if insideSup and priceSup > lowLvl and priceSup < highLvl and not skipSup
exists = false
supCount3 = array.size(dashedSup)
if supCount3 > 0
for j = 0 to supCount3 - 1 by 1
if math.abs(line.get_y1(array.get(dashedSup, j)) - priceSup) <= dashSkip
exists := true
exists
if not exists
dl = line.new(bar_index, priceSup, bar_index + 1, priceSup, xloc.bar_index, extend = extend.right, color = supColor, style = line.style_dashed, width = baseWidth)
array.push(dashedSup, dl)
insideRes = patGR and bodyCurr > bodyPrev or twoBarRes
priceRes = twoBarRes ? close[2] : close[1]
skipRes = math.abs(priceRes - resLevel) <= dashSkip
if insideRes and priceRes > lowLvl and priceRes < highLvl and not skipRes
exists2 = false
resCount3 = array.size(dashedRes)
if resCount3 > 0
for j = 0 to resCount3 - 1 by 1
if math.abs(line.get_y1(array.get(dashedRes, j)) - priceRes) <= dashSkip
exists2 := true
exists2
if not exists2
dl = line.new(bar_index, priceRes, bar_index + 1, priceRes, xloc.bar_index, extend = extend.right, color = resColor, style = line.style_dashed, width = baseWidth)
array.push(dashedRes, dl)