应平台用户要求, FMZ正在兼容TradingView的Pine语言函数库, 现已进入稳定版本
对语言的函数完全支持是一个持续努力的过程, 此公开版本为方便用户测试提前公开
后期FMZ会进行持续不段的增加完善对TradingView的Pine语言的函数库支持, 有需求可以本策略留言
注: 如果遇到变量未定义证明尚不支持此属性可删除相关调用, 或发工单联系技术人员解决
/*backtest
start: 2022-08-17 08:00:00
end: 2024-08-29 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/
strategy("supertrend", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 50)
[supertrend, direction] = ta.supertrend(input(5, "factor"), input.int(10, "atrPeriod"))
plot(direction < 0 ? supertrend : na, "Up direction", color = color.green, style=plot.style_linebr)
plot(direction > 0 ? supertrend : na, "Down direction", color = color.red, style=plot.style_linebr)
if direction < 0
if supertrend > supertrend[2]
strategy.entry("entry long", strategy.long)
else if strategy.position_size < 0
strategy.close_all()
else if direction > 0
if supertrend < supertrend[3]
strategy.entry("entry short", strategy.short)
else if strategy.position_size > 0
strategy.close_all()