简体   繁体   English

我无法将此 pine 脚本从 @V2 转换为 @V5

[英]I am having trouble to convert this pine script from @V2 to @V5

strategy("Tradingview", overlay=true, default_qty_value=100)
res = input(title="Main SuperTrend Time Frame", type=resolution, defval="720")
Factor=input(2, minval=1,maxval = 100)
Pd=input(10, minval=1,maxval = 100)

tp = input(500,title="Take Profit")
sl = input(400,title="Stop Loss")


Up=hl2-(Factor*atr(Pd))
Dn=hl2+(Factor*atr(Pd))
MUp=security(tickerid,res,hl2-(Factor*atr(Pd)))
MDn=security(tickerid,res,hl2+(Factor*atr(Pd)))

Mclose=security(tickerid,res,close)

TrendUp=close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up
TrendDown=close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn

MTrendUp=Mclose[1]>MTrendUp[1]? max(MUp,MTrendUp[1]) : MUp
MTrendDown=Mclose[1]<MTrendDown[1]? min(MDn,MTrendDown[1]) : MDn

Trend = close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1)
Tsl = Trend==1? TrendUp: TrendDown

MTrend = Mclose > MTrendDown[1] ? 1: Mclose< MTrendUp[1]? -1: nz(MTrend[1],1)
MTsl = MTrend==1? MTrendUp: MTrendDown

linecolor = Trend == 1 ? green: red
plot(Tsl, color = linecolor , style = line , linewidth = 4,title = "SuperTrend")

Mlinecolor = MTrend == 1 ? black : red
plot(MTsl, color = Mlinecolor , style = line , linewidth = 4,title = "Main SuperTrend")

plotshape(cross(close,Tsl) and close>Tsl , "Up Arrow", shape.triangleup,location.belowbar,black,0,0)
 plotshape(cross(Tsl,close) and close<Tsl , "Down Arrow", shape.triangledown , location.abovebar,      black,0,0)
up = Trend == 1 and Trend[1] == -1 and MTrend == 1 
down = Trend == -1 and Trend[1] == 1 and MTrend == -1 



golong = Trend == 1 and Trend[1] == -1 and MTrend == 1 
goshort = Trend == -1 and Trend[1] == 1 and MTrend == -1

I have tried to convert this V2 version but still facing the errors` this is the code I have to convert.我已尝试转换此 V2 版本,但仍然面临错误`这是我必须转换的代码。

This error is occurring the most:此错误发生的次数最多:

Add to Chart operation failed, reason: line 12: 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 Add to Chart operation failed, reason: line 12: The arguments 'maxval', 'minval', and 'step' cannot be used with the input() function 可以使用input.int()或input.float()指定输入数据值范围的函数

Isn't the error message clear?错误信息不是很清楚吗?

You cannot use arguments like minval , maxval in input() function. You should use input.int() or input.float() .您不能像input() function 中的minvalmaxval那样使用 arguments。您应该使用input.int()input.float()

Factor=input.int(2, minval=1,maxval = 100)
Pd=input.int(10, minval=1,maxval = 100)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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