[英]How to get close price of bar when my boolean criteria is met?
I've created some criteria that creates a shape on the chart;我创建了一些在图表上创建形状的标准; now I need to know if the close price of the next candle is higher than the close price of the candle where my
callSignal
shape occurs.现在我需要知道下一根蜡烛的收盘价是否高于出现我的
callSignal
形状的蜡烛的收盘价。
Currently getting this error, which makes sense:当前收到此错误,这是有道理的:
line 177: Cannot call 'operator <' with arguments (series[bool], series[bool]); available overloads: <(float, float) => bool; <(input float, input float) => input bool; <(const float, const float) => const bool; <(float, series[float]) => series[bool]; <(series[float], float) => series[bool]; <(series[float], series[float]) => series[bool];
Here is my code:这是我的代码:
// ... //
expiryLength = 1
callSignal = Cond1[1] ? na : Cond1 and rightTime? Cond1 : na
putSignal = Cond1[2] ? na : Cond2 and rightTime? Cond1 : na
plotshape(callSignal, style=shape.triangleup, location=location.belowbar, size=size.tiny)
plotshape(putSignal, style=shape.triangledown, location=location.abovebar, size=size.tiny)
// This is the part I am struggling with... //
callWL = callSignal[expiryLength] < callSignal
plotshape(callWL, size=size.large)
I don't know how to incorporate close
within my callWL
variable, or if I just need to rework this further.我不知道如何将
close
合并到我的callWL
变量中,或者我是否只需要进一步修改它。
Here's a sample script that generates call entries whenever price crosses SMA 30 from below and after expiryLength bars, plots a shape for gain/loss.这是一个示例脚本,每当价格从下方穿过 SMA 30 时以及在到期长度条之后生成看涨条目,绘制收益/损失形状。
//@version=4
study("Call lookback", overlay=true)
_expiryLength = input(title="Expire length in bars", type=input.integer, defval=10, minval=1)
_callSma = input(title="Call entry SMA period", type=input.integer, defval=30, minval=1)
_callSignal = false
// Make call entries
_callSignal := crossover(close, sma(close, _callSma))
plotshape(_callSignal?close:na, style=shape.triangleup, location=location.belowbar, size=size.tiny)
// Lookback for call entry and draw a symbol for gain/loss
_callWL = _callSignal[_expiryLength]
_color = close > close[_expiryLength]?color.green:color.red
plotshape(_callWL?close:na, color=_color, size=size.tiny)
plot(sma(close, _callSma))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.