简体   繁体   English

在一个条件下最低,在另一个条件下最高

[英]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 .因此, newLLnewHH都是false As a result, you never update validHigh and validLow and they remain as na .因此,您永远不会更新validHighvalidLow并且它们保持为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.

相关问题 如何在pinescript中获得特定时间范围的最高点和最低点 - How to get the highest high and the lowest low of specific timeframe in pinescript PineScript Highest-High 和 Lowest-Low 显示 Current-High 和 Current-Low - PineScript Highest-High and Lowest-Low showing Current-High and Current-Low 如何获得(条件)之前的蜡烛高低 - How to get (condition) previous candle high and low 获取先前条件蜡烛的高点和低点 - Get high and low of previous condition candle 在每个最后的移动平均线交叉(如 ZigZag)中获得最高点和最低点 - Get Highest high and lowest low in every last Moving Average Cross like ZigZag 如何在松脚本交易视图中获得最高价,最低价和收盘价 - How to get highest high, lowest low and close of a session in pine script tradingview 我怎样才能 plot 在最后一个最高点和最后一个最低点之间划一条线? - How can I plot a line between last highest high and last lowest low? 如何在特定时间内; plot Pine 脚本中的最高高和最低低 - How to within a specific time; plot the highest high and the lowest low in Pine script 根据之前最低低/最高高的止损设置止盈 - Set take profit based on stop loss of previous lowest low/highest high PineScript 'ta.lowest' 和 'ta.highest' 在 'if' 条件下显示错误值 - PineScript 'ta.lowest' and 'ta.highest' shows wrong value when in 'if' condition
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM