簡體   English   中英

將 v2 轉換為 v5

[英]Convert v2 to v5

這是指標代碼,我希望將其轉換為 V4 或 V5,我面臨將其轉換為所需版本的問題。 有人能幫助我嗎?

//@version=2
study(title="STUDY",overlay = true, shorttitle="STUDY")
src = close, len = input(25, minval=1, title="Length")
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))

//input
myPeriod = input(defval=7, type=integer, title="Period")
myThresholdUp = input(defval=50, type=float, title="Upper Threshold")
myThresholdDn = input(defval=50, type=float, title="Lower Threshold")
myAlgoFlipToggle = input(defval=false, type=bool, title="Imverse Algorthim")
myLineToggle = input(defval=true, type=bool, title="Show Lines")
myLabelToggle = input(defval=true, type=bool, title="Show Labels")
myRSI=rsi(close, myPeriod)

購買 = myAlgoFlipToggle ? 下降(myRSI,1)和交叉(myRSI,myThresholdDn):上升(myRSI,1)和交叉(myRSI,myThresholdUp)賣= myAlgoFlipToggle? 上升(myRSI,1)和交叉(myRSI,myThresholdUp):下降(myRSI,1)和交叉(myRSI,myThresholdDn)myPosition = buy==1? 0 : 賣出==1 或 myPosition[1]==1 ? 1:0 趨勢顏色 = 購買? 紅:賣? 綠色:不

您必須將 ta 前綴放在所有與時間序列相關的函數(如 rma、交叉、下降、上升、變化)之前。 您必須在 max 和 min 等數學函數之前放置數學前綴。 您必須在紅色和綠色等顏色之前使用顏色前綴。 您必須在輸入后使用 int 、 float 等后綴

//@version=5
indicator(title="STUDY",overlay = true, shorttitle="STUDY")
src = close
len = input.int(25, minval=1, title="Length")
up = ta.rma(math.max(ta.change(src), 0), len)
down = ta.rma(-math.min(ta.change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))

//input
myPeriod = input.int(7, title="Period")
myThresholdUp = input.float(defval=50.0, title="Upper Threshold")
myThresholdDn = input.float(defval=50.0, title="Lower Threshold")
myAlgoFlipToggle = input.bool(defval=false, title="Imverse Algorthim")
myLineToggle = input.bool(defval=true, title="Show Lines")
myLabelToggle = input.bool(defval=true,  title="Show Labels")
myRSI=ta.rsi(close, myPeriod)

buy = myAlgoFlipToggle ? ta.falling(myRSI,1) and ta.cross(myRSI, myThresholdDn) : ta.rising(myRSI, 1) and ta.cross(myRSI,myThresholdUp) 
sell = myAlgoFlipToggle ? ta.rising(myRSI, 1) and ta.cross(myRSI,myThresholdUp) : ta.falling(myRSI,1) and ta.cross(myRSI, myThresholdDn) 
var myPosition=0
myPosition := buy==1 ? 0 : sell==1 or myPosition[1]==1 ? 1 : 0 
trendColor = buy ? color.red : sell ? color.green : na
plot(myPosition)

首先從@version=2 轉換為@version=3:您只需更改v-num 然后編譯腳本,pinescript 編譯器會告訴您要更改的內容。

然后在保存列表中選擇“轉換為版本 5”。 從 v3 到 v5,它是自動化的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM