繁体   English   中英

当我的布尔标准得到满足时,如何获得柱的收盘价?

[英]How to get close price of bar when my boolean criteria is met?

我创建了一些在图表上创建形状的标准; 现在我需要知道下一根蜡烛的收盘价是否高于出现我的callSignal形状的蜡烛的收盘价。

当前收到此错误,这是有道理的:

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];

这是我的代码:

// ... //
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)

我不知道如何将close合并到我的callWL变量中,或者我是否只需要进一步修改它。

这是一个示例脚本,每当价格从下方穿过 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM