- 策略广场
- CTA策略模板
CTA策略模板
Author:
扫地僧, Date: 2021-11-05 10:42:31
Tags:
商品期货趋势震荡多品种
/*backtest
start: 2019-05-01 09:00:00
end: 2020-06-21 15:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}]
*/
function main() {
$.CTA("rb000/rb888", function(st) {
var r = st.records
var mp = st.position.amount
if (r.length < 20) {
return
}
var cross = _Cross(TA.MA(r, short), TA.MA(r, 20));
if (mp <= 0 && cross > 2) {
return 1 * (mp < 0 ? 2 : 1)
}
if (mp >= 0 && cross < -2) {
return -1 * (mp > 0 ? 2 : 1)
}
})
}
template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6