资源加载中... loading...

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)
        }
    })
}

相关内容

更多内容