我正在尝试将我的pine脚本版本2指示器转换为版本4,因此我发布了它,但是它使用了一个自我引用变量,它们在版本3中删除了它。要求解它页面我将在底部链接,但我无法弄清楚如何正确包装它。如果有人可以帮助我包装这个公式,将不胜感激。先感谢您。
这是代码。自我引用变量在第33行(BSSUM)上,并将第9行作为其公式的一部分。
// © OasisTrading
//@version=4
study("Rotation Factor: Buy/Sell Pressure", shorttitle="Rotation Factor")
interval = security(syminfo.tickerid, input("1D", title="Reset Interval"), time)
newSession = iff(change(interval), 1, 0)
one = (high > high[1]) and (low > low[1])
two = (high < high[1]) and (low < low[1])
three = (high > high[1]) and (low < low[1])
four = (high < high[1]) and (low > low[1])
five = (high == high[1]) and (low > low[1])
six = (high > high[1]) and (low == low[1])
seven = (high < high[1]) and (low == low[1])
eight = (high == high[1]) and (low < low[1])
//formula
onex = +2
twox = -2
threex = 0
fourx = 0
fivex = +1
sixx = +1
sevenx = -1
eightx = -1
formula = (high > high[1]) and (low > low[1]) ? onex : (high < high[1]) and (low < low[1]) ? twox : (high > high[1]) and (low < low[1]) ? threex : (high < high[1]) and (low > low[1]) ? fourx : (high == high[1]) and (low > low[1]) ? fivex : (high > high[1]) and (low == low[1]) ? sixx : (high < high[1]) and (low == low[1]) ? sevenx : (high == high[1]) and (low < low[1]) ? eightx : 0
BuySell = sum(formula, 1)
BSsum : iff(newSession, BuySell, BSsum[1]+BuySell)
Kolor1 = (BSsum > 0)==true
Kolor2 = (BSsum < 0)==true
plot(BSsum, style=plot.style_columns, color=Kolor1?color.green:Kolor2?color.red:na, linewidth=3, transp=0, title="Buy/Sell Pressure")```
I'm trying to convert my Pine script version 2 indicator to version 4 so I publish it, but it uses a self-referencing variable which they got rid of in version 3. To solve it it needs to be wrapped as stated in the reference page I will link at the bottom, but I cant figure out how to properly wrap it. If anyone could help me wrap this formula it would be greatly appreciated. Thank you in advance. https://www.tradingview.com/pine-script-docs/en/v5/migration_guides/To_Pine_version_3.html#
Here is the code. The self-referencing variable is on line 33 (BSsum) and uses line 9 as part of its formula.
// © OasisTrading
//@version=4
study("Rotation Factor: Buy/Sell Pressure", shorttitle="Rotation Factor")
interval = security(syminfo.tickerid, input("1D", title="Reset Interval"), time)
newSession = iff(change(interval), 1, 0)
one = (high > high[1]) and (low > low[1])
two = (high < high[1]) and (low < low[1])
three = (high > high[1]) and (low < low[1])
four = (high < high[1]) and (low > low[1])
five = (high == high[1]) and (low > low[1])
six = (high > high[1]) and (low == low[1])
seven = (high < high[1]) and (low == low[1])
eight = (high == high[1]) and (low < low[1])
//formula
onex = +2
twox = -2
threex = 0
fourx = 0
fivex = +1
sixx = +1
sevenx = -1
eightx = -1
formula = (high > high[1]) and (low > low[1]) ? onex : (high < high[1]) and (low < low[1]) ? twox : (high > high[1]) and (low < low[1]) ? threex : (high < high[1]) and (low > low[1]) ? fourx : (high == high[1]) and (low > low[1]) ? fivex : (high > high[1]) and (low == low[1]) ? sixx : (high < high[1]) and (low == low[1]) ? sevenx : (high == high[1]) and (low < low[1]) ? eightx : 0
BuySell = sum(formula, 1)
BSsum : iff(newSession, BuySell, BSsum[1]+BuySell)
Kolor1 = (BSsum > 0)==true
Kolor2 = (BSsum < 0)==true
plot(BSsum, style=plot.style_columns, color=Kolor1?color.green:Kolor2?color.red:na, linewidth=3, transp=0, title="Buy/Sell Pressure")```
发布评论
评论(1)
它不必包装,如果要在
Security()
中传递这些可变变量,则必须包装函数内部的变量。您的变量基于Security
的数据,但并未传递给它。要使脚本在v4中工作,您需要首先声明变量,然后通过
:=
操作员分配新值:It doesn't have to be wrapped, wrapping variables inside functions is necessary if you want to pass these mutable variables inside the
security()
. Your variable is based on data fromsecurity
, but it isn't passed to it.To make the script work in v4, you need to first declare the variable, and then assign it a new value via the
:=
operator: