老师,您好:
初次学习程序化交易,想老师帮写一个交易公式,以便参考学习编写方式和方法,以及公式的基本结构。
策略一:以小时图为交易周期,小时图收盘价大于周线开盘价时平空买多,小时图收盘价保持在周线开盘价以上时持多;
小时图收盘价小于周线开盘价时平多卖空,收盘价保持在周线开盘价以下时持空;连续交易
策略二:以小时图为交易周期,小时图收盘价大于60均线平空买多;小时图小于60均线时平多卖空。连续交易
1.
week_c:CALLSTOCK('',vtOPEN,7,0);//调用周期数据
sellshort(c>WEEK_C and holding<0,1,market);//平空
buy(c>WEEK_C and holding=0,1,market);//开多
sell(c< WEEK_C and holding>0,holding,market);//平多
buyshort(c<WEEK_C and holding<0,1,market);//开空
2.
ma60:ma(c,60);
平多开空:c<ma60;
平空开多:c>ma60;
sellshort(平空开多 and holding<0,1,market);
buy(平空开多 and holding=0,1,market);
sell(平多开空 and holding>0,holding,market);
buyshort(平多开空 and holding<0,1,market);