英文:
Connect the high value of all the candles with a specific condition
问题
我想要搜索一个高于前一根蜡烛和后一根蜡烛的蜡烛。例如,假设我们有三根蜡烛的高点值:high[0]
,high[1]
和high[2]
。
条件是 high[0]<high[1] And high[1]>high[2]
。然后,所有符合这个条件的蜡烛高点值将使用plot命令连接在一起。我的代码是连接了在具有这个条件的蜡烛之后的所有蜡烛。
//@version=5
indicator("My script", overlay = true)
plot(high<high[1] and high[1]>high[2] ? high[1] : na)
英文:
At the first I want to search for a candle that its high value is higher than previous and next candle. For example, suppose we have three candle's high value: high[0]
, high[1]
and high[2]
.
The condition is high[0]<high[1] And high[1]>high[2]
. Then all the candles's high with this condition connect to each other with plot command. My code is connected all the candles after the candle that has this condition.
//@version=5
indicator("My script" , overlay = true)
plot(high<high[1] and high[1]>high[2] ? high[1] : na)
答案1
得分: 1
当你找到一个新的枢轴点时,应从上一个枢轴点绘制线,并将新的枢轴点记录为上一个枢轴点。
一个工作示例:
//@version=5
indicator("My script", overlay = true)
var LastPivot = high
var LastPivotIndex = bar_index
if high < high[1] and high[1] > high[2]
line.new(bar_index[1], high[1], LastPivotIndex, LastPivot, color=color.red, width=2)
LastPivot := high[1]
LastPivotIndex := bar_index[1]
英文:
When you find a new pivot, you should draw the line from the last pivot, and record the new pivot as the last pivot.
A working example :
//@version=5
indicator("My script", overlay = true)
var LastPivot = high
var LastPivotIndex = bar_index
if high < high[1] and high[1] > high[2]
line.new(bar_index[1], high[1], LastPivotIndex, LastPivot, color=color.red, width=2)
LastPivot := high[1]
LastPivotIndex := bar_index[1]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论