[英]Need help converting Tradingview pine script from v2 to v5
我是 TradingView Pine 脚本的新手。 我正在寻求有关目前版本 2 上的 pine 脚本的帮助,但我正在尝试将其转换为版本 5 并且存在很多编译错误。
谁能帮我
我得到错误
第 15 行:未声明的标识符buying
; 第 19 行:未声明的标识符buying
; 第 24 行:未声明的标识符buying
; 第 25 行:未声明的标识符longCondition
; 第 28 行:未声明的标识符buying
; 第 29 行:未声明的标识符shortCondition
这是我要转换的脚本
//@version=2
strategy("TG Booster", shorttitle="TG Booster", overlay=false)
threshold = input(title="Price Difference Threshold", type=float, defval=0.004, step=0.001)
getDiff() =>
yesterday=security(tickerid, 'D', close[1])
today=security(tickerid, 'D', close)
delta=today-yesterday
percentage=delta/yesterday
closeDiff = getDiff()
buying = closeDiff > threshold ? true : closeDiff < -threshold ? false : buying[1]
hline(0, title="zero line")
bgcolor(buying ? yellow : purple, transp=25)
plot(closeDiff, color=silver, style=area, transp=75)
plot(closeDiff, color=black, title="prediction")
longCondition = buying
if longCondition
strategy.entry("Buy", strategy.long)
shortCondition = buying != true
if (shortCondition)
strategy.entry("Sell", strategy.short)
需要帮助将 Tradingview pine 脚本从版本 2 转换为版本 5
您不能声明变量“购买”并在创建之前询问购买的价值(购买 [1] 部分)。
转换后的脚本是:
//@version=5
strategy("TG Booster", shorttitle="TG Booster", overlay=false)
threshold = input.float(0.004, title="Price Difference Threshold", step=0.001)
getDiff() =>
yesterday=request.security(syminfo.tickerid, 'D', close[1])
today=request.security(syminfo.tickerid, 'D', close)
delta=today-yesterday
percentage=delta/yesterday
closeDiff = getDiff()
var bool buying = na
buying := closeDiff > threshold ? true : closeDiff < -threshold ? false : buying[1]
hline(0, title="zero line")
bgcolor(buying ? color.yellow : color.purple, transp=25)
plot(closeDiff, color=color.silver, style=plot.style_area , transp=75)
plot(closeDiff, color=color.black, title="prediction")
longCondition = buying
if longCondition
strategy.entry("Buy", strategy.long)
shortCondition = buying != true
if (shortCondition)
strategy.entry("Sell", strategy.short)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.