Apple Inc

缠论分析指标

159
//version=5
indicator("缠论分析指标", overlay=true)

// === 计算分型 ===
top_fractal = ta.highest(high, 3)[1] == high[1] and high[1] > high[0] and high[1] > high[2]
bottom_fractal = ta.lowest(low, 3)[1] == low[1] and low[1] < low[0] and low[1] < low[2]

// 画出分型信号
plotshape(top_fractal, location=location.abovebar, color=color.red, style=shape.triangleup, title="顶分型")
plotshape(bottom_fractal, location=location.belowbar, color=color.green, style=shape.triangledown, title="底分型")

// === 识别笔 ===
var float lastTop = na
var float lastBottom = na

if top_fractal
lastTop := high[1]
if bottom_fractal
lastBottom := low[1]

// 画出笔(顶底连接)
plot_pen_top = plot(lastTop, title="顶笔", color=color.red, linewidth=2, style=plot.style_stepline)
plot_pen_bottom = plot(lastBottom, title="底笔", color=color.green, linewidth=2, style=plot.style_stepline)

// === 计算中枢(简单版)===
var float zhongshu_top = na
var float zhongshu_bottom = na

if not na(lastTop) and not na(lastBottom)
zhongshu_top := math.min(lastTop, lastTop[1])
zhongshu_bottom := math.max(lastBottom, lastBottom[1])

// 先绘制中枢边界
plot_zhongshu_top = plot(zhongshu_top, title="中枢上沿", color=color.blue, linewidth=2)
plot_zhongshu_bottom = plot(zhongshu_bottom, title="中枢下沿", color=color.blue, linewidth=2)

// 使用 fill() 填充中枢区域
fill(plot1=plot_zhongshu_top, plot2=plot_zhongshu_bottom, color=color.blue, transp=80, title="中枢填充")

免责声明

这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。