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