[英]lowest low on a condition and highest high on another condition
I can't see why this script is not finding anything to plot.我不明白为什么这个脚本没有找到 plot 的任何内容。
The idea is to plot the lowest low only if it fullfils a condition, and also plot the highest high only if it fullfills a different condition.这个想法是 plot 只有在满足一个条件时才达到最低低点,并且 plot 只有在满足不同条件时才达到最高点。
These conditions respectively are a retracement larger than the excursion of a mirror length prior to the lowest low, and likewise for the highest high, a retracement larger than the excursion of a mirror length prior to the highest high.这些条件分别是在最低低点之前大于镜面长度偏移的回撤,同样对于最高高点,在最高高点之前大于镜面长度偏移的回撤。
//@version=5
indicator(title="Highest Low Since Lowest Low", shorttitle='HLsLL', overlay=true)
length = input.int(defval = 500, title = "length")
var float lowestLow = na
lowestLow := ta.lowest(length)
var float highestHigh = na
highestHigh := ta.highest(length)
twiceLengthLL = 2 * ta.barssince(low == lowestLow)
twiceLengthHH = 2 * ta.barssince(high == highestHigh)
preLow = low[twiceLengthLL]
preHigh = high[twiceLengthHH]
bool retraceLL = low - lowestLow >= preLow - lowestLow
bool retraceHH = highestHigh - high >= highestHigh - preHigh
bool newLL = ta.barssince(lowestLow) < ta.barssince(highestHigh)
bool newHH = ta.barssince(lowestLow) > ta.barssince(highestHigh)
var float validLow = na
if retraceLL and newLL
validLow := math.min(validLow, low)
var float validHigh = na
if retraceHH and newHH
validHigh := math.max(validHigh, high)
colorVH = color.new(color.silver, 0)
plotVH = plot(series=validHigh, title='Highest High', color=colorVH, linewidth=1, style=plot.style_line, editable=true)
colorVL = color.new(color.yellow, 0)
plotVL = plot(series=validLow, title='Valid Low', color=colorVL, linewidth=1, style=plot.style_line, editable=true)
// end of script
The following code does not make any sense.以下代码没有任何意义。
bool newLL = ta.barssince(lowestLow) < ta.barssince(highestHigh)
bool newHH = ta.barssince(lowestLow) > ta.barssince(highestHigh)
ta.barssince()
expects a condition as an argument but you are just passing a variable of type series
. ta.barssince()
需要一个条件作为参数,但您只是传递了一个series
类型的变量。
lowestLow := ta.lowest(length)
highestHigh := ta.highest(length)
Since you are not passing a condition, both ta.barssince(lowestLow)
and ta.barssince(highestHigh)
return 0
.由于您没有通过条件,因此
ta.barssince(lowestLow)
和ta.barssince(highestHigh)
返回0
。 So, both newLL
and newHH
are false
.因此,
newLL
和newHH
都是false
。 As a result, you never update validHigh
and validLow
and they remain as na
.因此,您永远不会更新
validHigh
和validLow
并且它们保持为na
。 So, no plots.所以,没有情节。
I changed the code in order to pass a condition to ta.barssince but the script is still not finding anything to plot:我更改了代码以便将条件传递给 ta.barssince,但脚本仍然没有找到 plot 的任何内容:
bool newLL = ta.barssince(low == lowestLow) < ta.barssince(high == highestHigh)
bool newHH = ta.barssince(low == lowestLow) > ta.barssince(high == highestHigh)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.