簡體   English   中英

如何轉換為 Pine Script v4 或 v5

[英]How to convert to Pine Script v4 or v5

我試圖在交易視圖上發布此腳本,但我不斷收到錯誤消息,指出我需要將其轉換為 pine 腳本 v4 或 v5 才能發布。 我嘗試將 //version=5 或 //version=4 添加到代碼的開頭,但我仍然沒有成功並最終得到錯誤代碼。

timeinrange(res, sess) => time(res, sess) != 0

// **** Checkboxes and custom Session
iKZNY = input(true, title="New York Kill Zone")
iOpenKZLondon = input(true, title="London Open Kill Zone")
iCloseKZLondon = input(true, title="London Close Kill Zone")
iAsiaKZ = input(true, title="Asia Kill Zone")
KZNY = input('1230-1430', type=session, title="New York Kill Zone")
LondonOpenKZ = input('0600-1000', type=session, title="London Open Kill Zone")
LondonCloseKZ = input('1500-1700', type=session, title="London Close Kill Zone")
AsiaKZ = input('2300-0300', type=session, title="Asia Kill Zone")

iRealOpenSessionAlertBar = input(true, title="Real Open Session Alert Bar")
NYOpenAlertBar = input('1330-1345', type=session, title="New York Open Session")
LondonOpenAlertBar = input('0700-0715', type=session, title="London Open Session")
LondonCloseAlertBar = input('1545-1600', type=session, title="London Close Session")
AsiaOpenAlertBar = input('0000-0015', type=session, title="Asia Open Session")

// **** Logic
sessToUse = iKZNY == 1 ? KZNY : '0000-0000'
sessToUse2 = iRealOpenSessionAlertBar == 1 ? NYOpenAlertBar : '0000-0000'
sessToUse3 = iOpenKZLondon == 1 ? LondonOpenKZ : '0000-0000'
sessToUse4 = iRealOpenSessionAlertBar == 1 ? LondonOpenAlertBar : '0000-0000'
sessToUse5 = iCloseKZLondon == 1 ? LondonCloseKZ : '0000-0000'
sessToUse6 = iRealOpenSessionAlertBar == 1 ? LondonCloseAlertBar : '0000-0000'
sessToUse7 = iAsiaKZ == 1 ? AsiaKZ : '0000-0000'
sessToUse8 = iRealOpenSessionAlertBar == 1 ? AsiaOpenAlertBar : '0000-0000'

// *** Apply custom rules
bgPlot = (iKZNY == 0 ? time(period) : time(period, sessToUse)) 
bgPlot2 = (iRealOpenSessionAlertBar == 0 ? time(period) : time(period, sessToUse2)) 
bgPlot3 = (iOpenKZLondon == 0 ? time(period) : time(period, sessToUse3)) 
bgPlot4 = (iRealOpenSessionAlertBar == 0 ? time(period) : time(period, sessToUse4)) 
bgPlot5 = (iCloseKZLondon == 0 ? time(period) : time(period, sessToUse5)) 
bgPlot6 = (iRealOpenSessionAlertBar == 0 ? time(period) : time(period, sessToUse6)) 
bgPlot7 = (iAsiaKZ == 0 ? time(period) : time(period, sessToUse7))
bgPlot8 = (iRealOpenSessionAlertBar == 0 ? time(period) : time(period, sessToUse8))

//**** Plot as background
bgcolor(iKZNY and bgPlot > 0 ? red : na, transp=90) 
bgcolor(iKZNY and iRealOpenSessionAlertBar and bgPlot2 > 0 ? red : na, transp=70) 
bgcolor(iOpenKZLondon and bgPlot3 > 0 ? green : na, transp=90) 
bgcolor(iOpenKZLondon and iRealOpenSessionAlertBar and bgPlot4 > 0 ? green : na, transp=70) 
bgcolor(iCloseKZLondon and bgPlot5 > 0 ? olive : na, transp=90) 
bgcolor(iCloseKZLondon and iRealOpenSessionAlertBar and bgPlot6 > 0 ? olive : na, transp=70) 
bgcolor(iAsiaKZ and bgPlot7 > 0 ? orange : na, transp=90) 
bgcolor(iAsiaKZ and iRealOpenSessionAlertBar and bgPlot8 > 0 ? orange : na, transp=70)```

添加//@version=5不會神奇地將腳本轉換為 v5。 自早期版本以來,許多內容已更改/重命名。

首先從//@version=3開始,然后在它工作時使用自動轉換器工具。

在此處輸入圖像描述

此外,這是您的遷移指南

暫無
暫無

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

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