等级: 机构版
- 注册:
- 2021-5-20
- 曾用名:
|
楼主 |
发表于 2021-8-11 14:58
|
显示全部楼层
您好,
下面是一个5分钟金叉买入代码,如果买入条件满足了,想在下一根K线开始后的10秒钟,执行指令,该怎么编呢?多谢指导!
variable:B[1]:=(1);
variable:lots=0;
dif:=Stkindiex('','macd.diff(26,12,9)',0,2,0,0),nodraw;
dea:=Stkindiex('','macd.dea(26,12,9)',0,2,0,0),nodraw;
CON_BUY1:=CROSS(dif,dea);
CON_SELL:=CROSS(dea,dif);
KDuo:=CON_BUY1 AND NOT(CON_SELL); //开多条件
PDuo:=CON_SELL AND NOT(CON_BUY1);//平多条件
IF PDuo AND lots>0 THEN begin
平多:=Sell(1,B[1],NEXTOPEN);
lots:=0;
END
IF KDuo and lots=0 THEN
begin
开多:=Buy(1,B[1],NEXTOPEN);
lots:=B[1];
end
持仓:lots,linethick0;
资产:=asset-10000000,colorred,noaxis;
最大回撤:=MaxDrawDown,nodraw;
盈亏比:=资产/最大回撤,nodraw; |
|