pine-script - Pine Script - 向上和向下趋势的多色线
问题描述
下面的代码显示上升趋势和下降趋势的单色线。上升趋势和下降趋势之间也有一条连接线。有人可以帮我获得 2 条颜色线并删除上升趋势和下降趋势之间的连接线。更多细节可以在截图中找到。图片
//@version=4
study(title="Trend Line", shorttitle="Trend Line", overlay=true, resolution="")
length = input(20,"Entry Length", minval=1)
len2=input(10, "Exit Length", minval=1)
lower = lowest(length)
upper = highest(length)
up=highest(high,length)
down=lowest(low,length)
K1=barssince(high>=up[1])<=barssince(low<=down[1]) ? down : up
plot(K1, title="Trend Line", color=color.red, linewidth=2)
解决方案
我认为你需要这样的结果
//@version=4
study(title="Trend Line", shorttitle="Trend Line", overlay=true, resolution="")
length = input(20,"Entry Length", minval=1)
len2 = input(10, "Exit Length", minval=1)
lower = lowest(length)
upper = highest(length)
up = highest(high,length)
down = lowest(low,length)
K1 = barssince(high >= up[1])<=barssince(low <= down[1]) ? down : up
linecolor = (open > K1) and (open[1] > K1[1]) ? color.red : (open < K1) and (open[1] < K1[1]) ? color.green : na
plot(K1, title="Trend Line", style = plot.style_linebr, color=linecolor, linewidth=2)
推荐阅读
- c - 如何将 .txt 中的信息扫描到结构数组?
- asp.net-mvc - 该请求的 iis Web 事件表单身份验证失败。原因:提供的票证无效
- c - 使用旧的 gcc 编译器编译 .c 文件
- r - 下采样以均衡因子水平对的计数?
- hyperledger-fabric - 数据收集配置文件:配置文件必须在所有组织中都相同吗?
- r - 将xml格式转换为r中的数据框
- c# - DefaultHttpContext 在集成测试中测试身份验证
- c - 在 c 中使用套接字读取和显示内容
- python - 我如何在 Bokeh 中两次放置相同的 x 轴
- javascript - 在打印窗口中打开 Blob 文件