移动平均线开始

问题描述 投票:0回答:1

是否有一个 pine 脚本 v5 可以突出显示回顾蜡烛或“x”移动平均线的垂直线。例如,使用 50MA,图表将突出显示第 50 根蜡烛,以表示 50MA 的开始。

//@版本=5 指标(“突出显示第 50 根蜡烛”,overlay = true)

// 定义要突出显示的蜡烛索引 highlightCandleIndex = 49 // 第 50 个蜡烛索引是 49(从零开始的索引)

//检查当前柱索引是否与highlightCandleIndex匹配 高亮条件 = bar_index == 高亮蜡烛索引

//确定高亮颜色 highlightColor = color.new(color.yellow, 50) // 黄色,不透明度 50%

// 绘制第 50 根蜡烛的亮点 plotshape(系列=highlightCondition,颜色=highlightColor,样式=shape.triangleup,位置=location.belowbar)

//根据需要绘制其他指标或数据

pine-script-v5 moving-average
1个回答
0
投票

是的,你可以做到。使用标签和历史引用运算符

indicator("My script", overlay = true)
var label start = na
ma = ta.sma(close,50)

if barstate.islast
    (start[1]).delete()
    start := label.new(bar_index[49], ma[49], style = label.style_xcross, size = size.tiny)

plot(ma)
© www.soinside.com 2019 - 2024. All rights reserved.