将松树脚本策略转换为研究



我想将TradingView松树脚本"价格通道策略"转换为研究。 有人可以帮忙吗?

代码如下:

//@version=4
strategy("ChannelBreakOutStrategy", overlay=true)
length = input(title="Length", type=input.integer, minval=1, maxval=1000, defval=5)
upBound = highest(high, length)
downBound = lowest(low, length)
if (not na(close[length]))
strategy.entry("ChBrkLE", strategy.long, stop=upBound + syminfo.mintick, comment="ChBrkLE")
strategy.entry("ChBrkSE", strategy.short, stop=downBound - syminfo.mintick, comment="ChBrkSE")
strategy.exit("long_tsl", "ChBrkLE", trail_points = 4000, trail_offset = 1500)
strategy.exit("short_tsl", "ChBrkSE", trail_points = 4000, trail_offset = 1500)

主要是,您必须将单词strategy更改为代码顶部的study。 您还必须删除strategy.entry/exit呼叫,因为这些呼叫在study中是不允许的。 有关更多信息,请参阅此处:https://marketscripters.com/pine-script-strategy-vs-study/

最新更新