连接所有蜡烛的高价,具有特定条件。

huangapple go评论51阅读模式
英文:

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]&lt;high[1] And high[1]&gt;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(&quot;My script&quot; , overlay = true)
plot(high&lt;high[1] and high[1]&gt;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(&quot;My script&quot;, overlay = true)

var LastPivot = high
var LastPivotIndex = bar_index
if high &lt; high[1] and high[1] &gt; high[2]
    line.new(bar_index[1], high[1], LastPivotIndex, LastPivot, color=color.red, width=2)
    LastPivot := high[1]
    LastPivotIndex := bar_index[1]

Gives :
连接所有蜡烛的高价,具有特定条件。

huangapple
  • 本文由 发表于 2023年5月28日 03:10:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76348595.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定