如何将V4研究代码转换为V5以将其添加到指标中?
我有一个我在V5 Pinescript上运行的指标,我想添加这个用V4 Pinescript编写的一个指标:
//@version=4
study("Tweezer and Kangaroo Tail", overlay = true)
enable_tweezer = input(defval = true, title = "Enable Tweezer")
maxrate = input(defval = 150., title = "Max Rate % Between Wick Sizes") / 100.
leveldiff = input(defval = 20., title = "Max Difference in level %") / 100.
prd =input(defval = 5, title = "Highest/Lowest Period")
apartprd = input(defval = 12, title = "Max Distance between Tweezers", minval = 1)
colup = input(defval = color.lime, title = "Color", inline = "col")
coldn = input(defval = color.red, title = "", inline = "col")
topwick = high - max(close, open)
bottomwick = min(close, open) - low
body = abs(close - open)
ishb = highestbars(prd) == 0
islb = lowestbars(prd) == 0
aparttweezers_top(len)=>
ret = 0
if topwick > 0
for x = 1 to apartprd
if nz(topwick[x]) == 0
break
if (max(topwick, topwick[x]) / min(topwick, topwick[x])) <= maxrate and abs(high - high[x]) < max(topwick, topwick[x]) * leveldiff and ishb[x]
ret := x
break
else
if high[x] >= high
ret := 0
break
ret
aparttweezers_bottom(len)=>
ret = 0
if bottomwick > 0
for x = 1 to apartprd
if nz(bottomwick[x]) == 0
break
if (max(bottomwick, bottomwick[x]) / min(bottomwick, bottomwick[x])) <= maxrate and abs(low - low[x]) < max(bottomwick, bottomwick[x]) * leveldiff and islb[x]
ret := x
break
else
if low[x] <= low
ret := 0
break
ret
top_tweezer = enable_tweezer and aparttweezers_top(apartprd)
bottom_tweezer = enable_tweezer and aparttweezers_bottom(apartprd)
plotshape(top_tweezer, text = "T", style = shape.labeldown, location = location.abovebar, color = coldn, textcolor = color.white)
plotshape(bottom_tweezer, text = "T", style = shape.labelup, location = location.belowbar, color = colup, textcolor = color.black)
// KANGAROO TAIL
enable_kangaroo_tail = input(defval = true, title = "Enable Kangaroo Tail")
prd1 = input(defval = 20, title="Period for Room", minval = 2, maxval = 50)
prd2 = input(defval = 8, title="Minimum Period for Room", minval = 2, maxval = 50)
atrmult = input(defval = 5, title="ATR Factor for Room Height", minval = 2, maxval = 30)
wickmult = input(defval = 3., title = "Wick/Body Rate", minval = 1)
wickmultavg = input(defval = 2., title = "Wick/Average_Wick Rate", minval = 1)
float ph = highestbars(high, prd1) == 0 ? high : na
float pl = lowestbars(low, prd1) == 0 ? low : na
var dir = 0
dir := iff(ph and na(pl), 1, iff(pl and na(ph), -1, dir))
var max_array_size = 4
var zigzag = array.new_float(4, 0.)
add_to_zigzag(value, bindex)=>
array.unshift(zigzag, bindex)
array.unshift(zigzag, value)
array.pop(zigzag)
array.pop(zigzag)
update_zigzag(value, bindex)=>
if array.size(zigzag) == 0
add_to_zigzag(value, bindex)
else
if (dir == 1 and value > array.get(zigzag, 0)) or (dir == -1 and value < array.get(zigzag, 0))
array.set(zigzag, 0, value)
array.set(zigzag, 1, bindex)
0.
dirchanged = change(dir)
if ph or pl
if dirchanged
add_to_zigzag(dir == 1 ? ph : pl, bar_index)
else
update_zigzag(dir == 1 ? ph : pl, bar_index)
averagetopwicksize = sma(topwick, 50)
topkangaroo = enable_kangaroo_tail and dir == 1 and topwick >= body * wickmult and close <= low + (high - low) / 3 and open <= low + (high - low) / 3 and
open < high[1] and open > low[1] and close < high[1] and close > low[1] and topwick >= wickmultavg * averagetopwicksize and body > 0 and
ph and array.get(zigzag, 0) == high and array.get(zigzag, 0) - array.get(zigzag, 2) > atr(50) * atrmult and array.get(zigzag, 1) - array.get(zigzag, 3) > prd2
bottomkangaroo = enable_kangaroo_tail and dir == -1 and bottomwick >= body * wickmult and close >= high - (high - low) / 3 and open >= high - (high - low) / 3 and
open < high[1] and open > low[1] and close < high[1] and close > low[1] and bottomwick >= wickmultavg * averagetopwicksize and body > 0 and
pl and array.get(zigzag, 0) == low and array.get(zigzag, 2) - array.get(zigzag, 0) > atr(50) * atrmult and array.get(zigzag, 1) - array.get(zigzag, 3) > prd2
plotshape(topkangaroo, text = "K", style = shape.labeldown, location = location.abovebar, color = coldn, textcolor = color.white)
plotshape(bottomkangaroo, text = "K", style = shape.labelup, location = location.belowbar, color = colup, textcolor = color.black)
alertcondition(topkangaroo, title='Kangaroo Tail Bearish', message='Kangaroo Tail Bearish')
alertcondition(bottomkangaroo, title='Kangaroo Tail Bullish', message='Kangaroo Tail Bullish')
alertcondition(top_tweezer, title='Tweezers Bearish', message='Tweezers Bearish')
alertcondition(bottom_tweezer, title='Tweezers Bullish', message='Tweezers Bullish')
可以将其转换吗?我试图删除研究行,但它给了我这个错误:
第266行:参数“ maxval”,“ minval”和“ step”,不能与input()函数一起使用。您可以使用input.int.int()或input.float()函数来指定一系列输入数据值。
I have an indicator I built running on V5 pinescript and I want to add this one which is written in V4 pinescript:
//@version=4
study("Tweezer and Kangaroo Tail", overlay = true)
enable_tweezer = input(defval = true, title = "Enable Tweezer")
maxrate = input(defval = 150., title = "Max Rate % Between Wick Sizes") / 100.
leveldiff = input(defval = 20., title = "Max Difference in level %") / 100.
prd =input(defval = 5, title = "Highest/Lowest Period")
apartprd = input(defval = 12, title = "Max Distance between Tweezers", minval = 1)
colup = input(defval = color.lime, title = "Color", inline = "col")
coldn = input(defval = color.red, title = "", inline = "col")
topwick = high - max(close, open)
bottomwick = min(close, open) - low
body = abs(close - open)
ishb = highestbars(prd) == 0
islb = lowestbars(prd) == 0
aparttweezers_top(len)=>
ret = 0
if topwick > 0
for x = 1 to apartprd
if nz(topwick[x]) == 0
break
if (max(topwick, topwick[x]) / min(topwick, topwick[x])) <= maxrate and abs(high - high[x]) < max(topwick, topwick[x]) * leveldiff and ishb[x]
ret := x
break
else
if high[x] >= high
ret := 0
break
ret
aparttweezers_bottom(len)=>
ret = 0
if bottomwick > 0
for x = 1 to apartprd
if nz(bottomwick[x]) == 0
break
if (max(bottomwick, bottomwick[x]) / min(bottomwick, bottomwick[x])) <= maxrate and abs(low - low[x]) < max(bottomwick, bottomwick[x]) * leveldiff and islb[x]
ret := x
break
else
if low[x] <= low
ret := 0
break
ret
top_tweezer = enable_tweezer and aparttweezers_top(apartprd)
bottom_tweezer = enable_tweezer and aparttweezers_bottom(apartprd)
plotshape(top_tweezer, text = "T", style = shape.labeldown, location = location.abovebar, color = coldn, textcolor = color.white)
plotshape(bottom_tweezer, text = "T", style = shape.labelup, location = location.belowbar, color = colup, textcolor = color.black)
// KANGAROO TAIL
enable_kangaroo_tail = input(defval = true, title = "Enable Kangaroo Tail")
prd1 = input(defval = 20, title="Period for Room", minval = 2, maxval = 50)
prd2 = input(defval = 8, title="Minimum Period for Room", minval = 2, maxval = 50)
atrmult = input(defval = 5, title="ATR Factor for Room Height", minval = 2, maxval = 30)
wickmult = input(defval = 3., title = "Wick/Body Rate", minval = 1)
wickmultavg = input(defval = 2., title = "Wick/Average_Wick Rate", minval = 1)
float ph = highestbars(high, prd1) == 0 ? high : na
float pl = lowestbars(low, prd1) == 0 ? low : na
var dir = 0
dir := iff(ph and na(pl), 1, iff(pl and na(ph), -1, dir))
var max_array_size = 4
var zigzag = array.new_float(4, 0.)
add_to_zigzag(value, bindex)=>
array.unshift(zigzag, bindex)
array.unshift(zigzag, value)
array.pop(zigzag)
array.pop(zigzag)
update_zigzag(value, bindex)=>
if array.size(zigzag) == 0
add_to_zigzag(value, bindex)
else
if (dir == 1 and value > array.get(zigzag, 0)) or (dir == -1 and value < array.get(zigzag, 0))
array.set(zigzag, 0, value)
array.set(zigzag, 1, bindex)
0.
dirchanged = change(dir)
if ph or pl
if dirchanged
add_to_zigzag(dir == 1 ? ph : pl, bar_index)
else
update_zigzag(dir == 1 ? ph : pl, bar_index)
averagetopwicksize = sma(topwick, 50)
topkangaroo = enable_kangaroo_tail and dir == 1 and topwick >= body * wickmult and close <= low + (high - low) / 3 and open <= low + (high - low) / 3 and
open < high[1] and open > low[1] and close < high[1] and close > low[1] and topwick >= wickmultavg * averagetopwicksize and body > 0 and
ph and array.get(zigzag, 0) == high and array.get(zigzag, 0) - array.get(zigzag, 2) > atr(50) * atrmult and array.get(zigzag, 1) - array.get(zigzag, 3) > prd2
bottomkangaroo = enable_kangaroo_tail and dir == -1 and bottomwick >= body * wickmult and close >= high - (high - low) / 3 and open >= high - (high - low) / 3 and
open < high[1] and open > low[1] and close < high[1] and close > low[1] and bottomwick >= wickmultavg * averagetopwicksize and body > 0 and
pl and array.get(zigzag, 0) == low and array.get(zigzag, 2) - array.get(zigzag, 0) > atr(50) * atrmult and array.get(zigzag, 1) - array.get(zigzag, 3) > prd2
plotshape(topkangaroo, text = "K", style = shape.labeldown, location = location.abovebar, color = coldn, textcolor = color.white)
plotshape(bottomkangaroo, text = "K", style = shape.labelup, location = location.belowbar, color = colup, textcolor = color.black)
alertcondition(topkangaroo, title='Kangaroo Tail Bearish', message='Kangaroo Tail Bearish')
alertcondition(bottomkangaroo, title='Kangaroo Tail Bullish', message='Kangaroo Tail Bullish')
alertcondition(top_tweezer, title='Tweezers Bearish', message='Tweezers Bearish')
alertcondition(bottom_tweezer, title='Tweezers Bullish', message='Tweezers Bullish')
Would it be possible to convert it? I tried to delete the study line, but it gave me this error:
line 266: The arguments 'maxval', 'minval', and 'step' cannot be used with the input() function. You can use the input.int() or input.float() functions to specify a range of input data values.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以从菜单中使用自动转换器工具(“ 发布脚本”按钮旁边的三个点。
You can use the auto converter tool from the menu (three dots right next to the "Publish script" button.