Pine 脚本 - 如何识别最后一根柱的价格

发布于 2025-01-17 20:55:43 字数 481 浏览 0 评论 0原文

我正在使用Pinescript绘制交易中的支持和阻力框。目前,我绘制的所有盒子都只有一种/相同的颜色。我想将所有盒子标记在当前的询问/投标价格上方,而低于当前的询问/出价价格为绿色。有什么想法吗?

这些是当前绘制框的值。

boxLeft := bar_index-1
boxTop := open[1]
boxBottom := close[1]
boxRight := bar_index +25 // extending the box up to 25 candles from starting position

box.new(boxLeft, boxTop, boxRight, boxBottom, bgcolor=color.rgb(56,79,67,50), border_color=color.rgb(150,200,150,10))

我需要根据当前的询问/投标动态更改bgcolor,这应该适用于图表上的所有图纸。

I'm drawing support and resistance boxes in TradingView using pinescript. Currently all the boxes that I draw are just of one/same color. I want to mark all boxes above the current ask/bid price as Red and the ones that are below the current ask/bid price as Green. Any ideas?

These are the values for drawing the box currently.

boxLeft := bar_index-1
boxTop := open[1]
boxBottom := close[1]
boxRight := bar_index +25 // extending the box up to 25 candles from starting position

box.new(boxLeft, boxTop, boxRight, boxBottom, bgcolor=color.rgb(56,79,67,50), border_color=color.rgb(150,200,150,10))

I need to dynamically change the bgcolor based on the current ask/bid, and this should be applicable for all the drawings on the chart.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦途 2025-01-24 20:55:43

您可以尝试以下代码:

colorr = boxBottom > close ? color.green : boxTop < close ? color.red : color.blue

box.new(boxLeft, boxTop, boxRight, boxBottom, bgcolor=colorr, border_color=colorr)

you may try with the code below:

colorr = boxBottom > close ? color.green : boxTop < close ? color.red : color.blue

box.new(boxLeft, boxTop, boxRight, boxBottom, bgcolor=colorr, border_color=colorr)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文