pinescript 中的版本 1 到版本 5

问题描述 投票:0回答:2

我正在尝试将下面的固定脚本从版本 1 转换为版本 5。我陷入了突出显示的步骤。我需要版本 5 中的此代码,因为我必须将此代码与另一个版本 5 代码合并。谁能帮我将下面的代码转换为版本 5。谢谢


Factor=input(3, minval=1,maxval = 100)
Pd=input(7, minval=1,maxval = 100)


Up=hl2-(Factor*atr(Pd))
Dn=hl2+(Factor*atr(Pd))


//Need help in the below part
**TrendUp=close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up
TrendDown=close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn
Trend = close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1)
Tsl = Trend==1? TrendUp: TrendDown**

linecolor = Trend == 1 ? green : red

plot(Tsl, color = linecolor , style = line , linewidth = 2,title = "SuperTrend")

plotshape(cross(close,Tsl) and close>Tsl , "Up Arrow", shape.triangleup,location.belowbar,green,0,0)
plotshape(cross(Tsl,close) and close<Tsl , "Down Arrow", shape.triangledown , location.abovebar, red,0,0)

plotarrow(Trend == 1 and Trend[1] == -1 ? Trend : na, title="Up Entry Arrow", colorup=lime, maxheight=60, minheight=50, transp=0)
plotarrow(Trend == -1 and Trend[1] == 1 ? Trend : na, title="Down Entry Arrow", colordown=red, maxheight=60, minheight=50, transp=0)```
pine-script pine-script-v5
2个回答
0
投票

您需要了解的更改已在此处进行了解释。

基本上,您需要先声明变量。

//Need help in the below part
TrendUp = 0.0
TrendUp := close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up

TrendDown = 0.0
TrendDown := close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn

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

0
投票

如何从 v1 转换为 v5???,我还需要将指标从 v1 转换为 v5,但 pinescript 只能将 v3 转换为 v4,将 v4 转换为 v5

© www.soinside.com 2019 - 2024. All rights reserved.