超级趋势策略

supertrend
创建日期: 2022-04-27 18:21:50 最后修改: 2024-08-30 18:24:36
复制: 938 点击次数: 36551
10
关注
491
关注者

应平台用户要求, FMZ正在兼容TradingView的Pine语言函数库, 现已进入稳定版本

  • 语法完全兼容到v5版本
  • ta库所有指标完全实现
  • math库完全实现
  • string库完全实现
  • array库完全实现
  • input输入参数自动识别到界面
  • request.security对heikinashi的支持
  • strategy库实现(支持止损/止盈/跟踪止盈/条件单等完整支持)
  • plot/plotchar/plotshape/plotcandle/alert/alertcondition 等兼容

对语言的函数完全支持是一个持续努力的过程, 此公开版本为方便用户测试提前公开

后期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()
相关推荐
更多内容
全部留言
avatar of Stalker
Stalker
支持同币种,不同交易所比对同步吗?例如exchange[0].Sell ? exchaneg[1].Sell : na
2022-11-18 18:20:18
avatar of 栩笨笨
栩笨笨
pine脚本能实现微信通知功能吗
2022-07-22 10:52:37
avatar of wang3602000
wang3602000
python 在发明者学的 PINE 暂时没太看懂 他们都说PINE比PYTHON简单 , 呜呜 多币种的超级趋势 好写吗 我想以多币种的超级趋势为基础 ,添加自己脑袋里的东西 不知道怎么做
2022-06-30 18:19:35
avatar of wang3602000
wang3602000
请问 这个策略如何转换成多币种的
2022-06-30 18:17:36
avatar of xaifer48
xaifer48
能出个Pine语言的教程么
2022-06-24 23:10:26
avatar of lefarcen
lefarcen
牛牛牛
2022-05-12 15:12:15
avatar of 夏天不打你
夏天不打你
这个下单数量也是通过strategy.entry的qty参数调整吗?
2022-05-10 11:50:24
avatar of Zer3192
Zer3192
发明者越来越强大了
2022-05-08 19:25:14
avatar of xunfeng91
xunfeng91
牛逼v5,这策略可以直接上实盘了
2022-04-30 12:45:46
avatar of 发明者量化
发明者量化
https://www.fmz.com/doc/9315#request.security 可以比对K线,深度没法比对
2022-11-18 23:43:44
avatar of 发明者量化
发明者量化
当然可以 runtime.log 后面加 @ 不过现在只能通知到app了, 微信通知已经下了
2022-08-03 11:24:39
avatar of 发明者量化
发明者量化
Pine不支持多币种,一个策略只支持一个币种
2022-07-11 19:10:39
avatar of 发明者量化
发明者量化
正在录制,目前可以先看文档 https://www.fmz.com/doc/9315
2022-06-25 19:31:53
avatar of 发明者量化
发明者量化
是的,默认不指定的话就是界面选项里的参数
2022-05-10 13:24:53