本文介绍了尝试将 pinescript 代码转换为版本 4 时出现无法调用带有参数错误的“abs"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将 pinescript 代码转换为版本 4.代码如下
I am trying to convert a pinescript code into version 4. The code is below
Early = abs((close[3] > open[3] and close[2] > open[2] and close[1] > open[1] and close < open) or (close[3] > open[3] and close[2] > open[2] and close[1] < open[1] and close > open) or (close[3] > open[3] and close[2] < open[2] and close[1] > open[1] and close > open) or (close[3] < open[3] and close[2] > open[2] and close[1] > open[1] and close > open) or (close[3] > open[3] and close[2] > open[2] and close[1] > open[1] and close > open))*(low*.9999525)
EarlyD = abs((close[3] < open[3] and close[2] < open[2] and close[1] < open[1] and close > open) or (close[3] < open[3] and close[2] < open[2] and close[1] > open[1] and close < open) or (close[3] < open[3] and close[2] > open[2] and close[1] < open[1] and close < open) or (close[3] > open[3] and close[2] < open[2] and close[1] < open[1] and close < open) or (close[3] < open[3] and close[2] < open[2] and close[1] < open[1] and close < open))*(high*1.00009525)
EarlyTd = abs(close > TL(low, 16) and close < l)*(low*.9999525)
EarlyTu = abs(close < TH(high, 16) and close > h)*(high*1.00009525)
我收到以下错误:
line 113: Cannot call 'abs' with arguments (series[bool]); available overloads: abs(integer) => integer; abs(input integer) => input integer; abs(const integer) => const integer; abs(float) => float; abs(input float) => input float; abs(const float) => const float; abs(series[float]) => series[float];
line 114: Cannot call 'abs' with arguments (series[bool]); available overloads: abs(integer) => integer; abs(input integer) => input integer; abs(const integer) => const integer; abs(float) => float; abs(input float) => input float; abs(const float) => const float; abs(series[float]) => series[float];
line 113: Cannot call 'operator *' with arguments (series[bool], series[float]); available overloads: *(const integer, const integer) => const integer; *(const float, const float) => const float; *(input integer, input integer) => input integer; *(input float, input float) => input float; *(integer, integer) => integer; *(float, float) => float; *(series[integer], series[integer]) => series[integer]; *(series[float], series[float]) => series[float];
line 115: Cannot call 'operator *' with arguments (series[bool], series[float]); available overloads: *(const integer, const integer) => const integer; *(const float, const float) => const float; *(input integer, input integer) => input integer; *(input float, input float) => input float; *(integer, integer) => integer; *(float, float) => float; *(series[integer], series[integer]) => series[integer]; *(series[float], series[float]) => series[float];
推荐答案
您可能正在寻找更多类似的东西.您无法对带有数值的布尔表达式进行操作,因此我们在这里分两步进行:首先定义条件(布尔值),然后使用它们构建价格.
You're probably looking for something more like this. You can't operate on boolean expressions with numerical values, so here we do it in two steps: first we define our conditions (the boolean values), then we build prices using them.
// #1: Build boolean conditions.
EarlyU = (close[3] > open[3] and close[2] > open[2] and close[1] > open[1] and close < open)
or (close[3] > open[3] and close[2] > open[2] and close[1] < open[1] and close > open)
or (close[3] > open[3] and close[2] < open[2] and close[1] > open[1] and close > open)
or (close[3] < open[3] and close[2] > open[2] and close[1] > open[1] and close > open)
or (close[3] > open[3] and close[2] > open[2] and close[1] > open[1] and close > open)
EarlyD = (close[3] < open[3] and close[2] < open[2] and close[1] < open[1] and close > open)
or (close[3] < open[3] and close[2] < open[2] and close[1] > open[1] and close < open)
or (close[3] < open[3] and close[2] > open[2] and close[1] < open[1] and close < open)
or (close[3] > open[3] and close[2] < open[2] and close[1] < open[1] and close < open)
or (close[3] < open[3] and close[2] < open[2] and close[1] < open[1] and close < open)
EarlyTd = close > TL(low, 16) and close < l
EarlyTu = close < TH(high, 16) and close > h
// #2: Build prices.
EarlyUVal = EarlyU ? low * 0.9999525 : na
EarlyDVal = EarlyD ? low * 0.9999525 : na
EarlyTdVal = EarlyTd ? high * 1.00009525 : na
EarlyTuVal = EarlyTu ? high * 1.00009525 : na
这篇关于尝试将 pinescript 代码转换为版本 4 时出现无法调用带有参数错误的“abs"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!