pine-script - 在松树脚本上创建情节而不是标签
问题描述
这是枢轴点交易视图的默认脚本
//@version=4
study("Pivot Points High Low", shorttitle="Pivots HL", overlay=true)
lenH = input(title="Length High", type=input.integer, defval=10, minval=1)
lenL = input(title="Length Low", type=input.integer, defval=10, minval=1)
fun(src, len, isHigh, _style, _yloc, _color) =>
p = nz(src[len])
isFound = true
for i = 0 to len - 1
if isHigh and src[i] > p
isFound := false
if not isHigh and src[i] < p
isFound := false
for i = len + 1 to 2 * len
if isHigh and src[i] >= p
isFound := false
if not isHigh and src[i] <= p
isFound := false
if isFound
label.new(bar_index[len], p, tostring(p), style=_style, yloc=_yloc, color=_color)
fun(high, lenH, true, label.style_labeldown, yloc.abovebar, color.lime)
fun(low, lenL, false, label.style_labelup, yloc.belowbar, color.red)
如何将标签更改为绘图?
解决方案
好的。翻译困难。
//@version=4
study("Help (Pivot Points High Low)", shorttitle="Pivots HL", overlay=true)
lenH = input(title="Length High", type=input.integer, defval=10, minval=1)
lenL = input(title="Length Low", type=input.integer, defval=10, minval=1)
//fun(src, len, isHigh, _style, _yloc, _color) =>
fun(src, len, isHigh) =>
p = nz(src[len])
isFound = true
for i = 0 to len - 1
if isHigh and src[i] > p
isFound := false
if not isHigh and src[i] < p
isFound := false
for i = len + 1 to 2 * len
if isHigh and src[i] >= p
isFound := false
if not isHigh and src[i] <= p
isFound := false
if isFound
// label.new(bar_index[len], p, tostring(p), style=_style, yloc=_yloc, color=_color)
p
plotH = fun(high, lenH, true) //, label.style_label_down, yloc.abovebar, color.lime)
plotL = fun(low, lenL, false) //, label.style_label_up, yloc.belowbar, color.red)
plot(plotH, color=color.lime, linewidth=3, style=plot.style_circles, offset=-lenH)
plot(plotL, color=color.red, linewidth=3, style=plot.style_circles, offset=-lenL)
推荐阅读
- python - Flask / Gcloud 错误“内容必须通过 HTTPS 提供”
- c++ - vs 代码无法遵循相关的 gcc 构建错误链接
- node.js - NodeJS-Heroku 加载图片资源失败:服务器响应状态为 502 (Bad Gateway)
- javascript - Find the clients' IP address using an ExpressJS app
- node.js - 为 npx create-react-app 创建文件的问题
- jquery - Kendo-UI Router 无限路由
- spring - PropertyPlaceholderConfigurer 与 xml 配置中的配置文件
- javascript - 如何从多个输入中获取价值并使其成为一个输入?
- homebrew - SwiftGen 在启动时“杀死:9”,因为“代码签名无效”,但前提是通过 Homebrew 安装
- java - 当 BigDecimal 类型先除法再乘法时,为什么结果与预期不同。JAVA