简体   繁体   English

Pine-Script:从已知范围中[仅]选择一个小节

[英]Pine-Script: Select one bar [only] from a known range

I want to highlight which bar has a bigger close within a range.我想突出显示范围内哪个柱的收盘价更大。 The range would be all bars that are above a SMA line.范围将是 SMA 线上方的所有柱线。

It's a bit difficult to explan and the following image explains what I want to achieve:解释起来有点困难,下图解释了我想要实现的目标:

在此处输入图片说明

I have manually highlighted (in "yellow") the start end of the range, which is where the SMA cross up and down ocurred.我已手动突出显示(以“黄色”)范围的起始端,即 SMA 上下交叉的位置。 From within that range, I would like to highly the bar with a bigger close (in the image the one with the "blue" arrow)在这个范围内,我想用更大的收盘价来高价(图中带有“蓝色”箭头的那个)

Is that possible to be done in Pine?这可以在 Pine 中完成吗? Because I can know if the current bar is the higher one from the start of the range and I can display an "arrow" on that bar, but later a new bar will appear with higher close so I will put another "arrow", having several arrows within the specific range.因为我可以知道当前柱是否是范围开始时较高的柱,并且我可以在该柱上显示“箭头”,但稍后会出现一个新柱,收盘价更高,因此我将放置另一个“箭头”,具有特定范围内的几个箭头。

Thanks!谢谢!

You need to define a label once, and then move it with label.set_x() when a higher close occurs.您需要定义一次标签,然后在更高的收盘label.set_x()发生时使用label.set_x()移动它。
Example: How to change a label's price coordinate in TradingView Pine Script?示例:如何在 TradingView Pine Script 中更改标签的价格坐标?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM