图表程序化,不支持锁仓,要遵循"先平后开"原则
请根据以下顺序书写
平空
开多
平多
开空
在平仓反手的地方,一定要参考2楼的次序
可调整成如下。
平空
开多
可以改为以下,优于两个最小变动价位,来增加成交的几率
//注意:模式选用固定时间间隔
ma5:ma(c,5);
c1:=ref(c,1);
c2:=ref(c,2);
//平空开多----(K线走完)上穿ma5
pkkd:=c1>ref(ma5,1) and c2<ref(ma5,2);//上穿ma5这里用 上个周期小于ma5,本周期大于ma5来限定.
//平多开空----(K线走完)下穿ma5
pdkk:=c1<ref(ma5,1) and c2>ref(ma5,2);
if pkkd then
begin
sellshort(holding < 0, 1, market);//平空
buy(holding = 0, 1, market);//开多
end
if pdkk then
begin
sell(holding > 0, 1, market);//平多
buyshort(holding = 0, 1, market);//开空
end
if h-enterprice>1 and holding>0 then 多赢:sell(1,1,market);
if enterprice-low>1 and holding<0 then 空赢:sellshort(1,1,market);