簡體   English   中英

將 Pine 腳本 v1 轉換為 v4

[英]Convert Pine Script v1 to v4

請看下面我在交易視圖中找到的指標。 我的目標是將其與其他指標結合起來制定交易策略。 由於其他指標是使用 Pine Script 第 4 版制作的,因此我需要確保該指標與第 4 版兼容。當我在頂部添加 //@version=4 時,它會出錯。 好像有什么不對勁。 有人可以幫我解決這個問題嗎?

非常感謝!

//@version=1

study(title="Bar Color", overlay = true)
src = close, len = input(11)
p1= ema(src,len)


ut   = close > p1 and close[1] > p1 
dt = close < p1 and close[1] < p1

uc = close > close[1] or high > high[1] and low > low[1]
dc = close < close[1] or high < high[1] and low < low[1]


showbar = (ut and uc) ? #00FFFF :
   (ut and dc) ? #00FFFF :
   (dt and dc) ? #FF0066 :
   (dt and uc) ? #FF0066 :
   na

barcolor(color=showbar)

嘗試使用第 15 行作為一行

//@version=4

study(title="Bar Color", overlay = true)
src = close, len = input(11)
p1= ema(src,len)


ut   = close > p1 and close[1] > p1 
dt = close < p1 and close[1] < p1

uc = close > close[1] or high > high[1] and low > low[1]
dc = close < close[1] or high < high[1] and low < low[1]


showbar = (ut and uc) ? #00FFFF :   (ut and dc) ? #00FFFF :   (dt and dc) ? #FF0066 :   (dt and uc) ? #FF0066 :   na

barcolor(color=showbar)

暫無
暫無

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

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