跨周期均线交易

EMA
创建日期: 2022-05-05 21:49:48 最后修改: 2022-05-06 16:47:08
复制: 8 点击次数: 1321
10
关注
488
关注者

[trans]演示Pine语言如何跨周期调用

策略源码
/*backtest
start: 2021-05-04 00:00:00
end: 2022-05-03 23:59:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Bitfinex","currency":"BTC_USD"}]
*/
strategy("multiple timeframe trading")

expr = ta.ema(close, 5)
hVal = request.security(syminfo.tickerid, '60', expr)

plot(expr, timeframe.period)
plot(hVal, '1hour')

// 5 hour vs 5 days
if hVal > expr
    strategy.entry("long", strategy.long)
else
    strategy.entry("short", strategy.short)
相关推荐
更多内容