以下为金字塔股指期货策略源码,可否增加一个条件,下午14:57分(收盘前三分钟)无条件清仓,谢谢
input:S(1,1,1,1);
TYP:=(((HIGH + LOW) + (2 * CLOSE)) / 4);
龙线:=EMA(TYP,66);
CYC:=(BARSLAST((DATE <> REF(DATE,1))) + 1);
昨高:=CALLSTOCK(STKLABEL,VTHIGH,6,-(0.01));
昨低:=CALLSTOCK(STKLABEL,VTLOW,6,0.01);
昨收:=CALLSTOCK(STKLABEL,vtCLOSE,6,-(0.01));
开盘价:=VALUEWHEN((CYC = 1),OPEN);
HH:=HHV(昨高,1);
HC:=HHV(昨收,1);
LC:=LLV(昨收,1);
LL:=LLV(昨低,1);
VARIABLE:SS:=1;
VARIABLE:NUM:=0;
IF (SS = S) THEN
BEGIN
NUM:=0;
END
IF (SS = 1) THEN
BEGIN
NUM:=1;
END
IF ((TIME >= 93000) AND (TIME < 150000)) THEN
BEGIN
SS:=1;
END
开多1:=(CROSS(LOW,昨高) OR CROSS(LOW,昨低));
开空1:=(CROSS(昨低,HIGH) OR CROSS(昨高,HIGH));
压力1:=IF(BARSLAST(开空1),REF(HIGH,BARSLAST(开空1)),drawnull);
支撑1:=IF(BARSLAST(开多1),REF(LOW,BARSLAST(开多1)),drawnull);
开多2:=(CROSS(龙线,压力1) OR CROSS(龙线,支撑1));
开空2:=(CROSS(压力1,龙线) OR CROSS(支撑1,龙线));
开多3:=(开多1 OR 开多2);
开空3:=(开空1 OR 开空2);
时间:=TIME;
HQT1:=BARSLAST(CROSS((开空3 = 0),0.1));
LQT1:=BARSLAST(CROSS((开多3 = 0),0.1));
多:=(LQT1 = 5);
空:=(HQT1 = 5);
IF (空 AND (TIME < 143000)) THEN
BEGIN
SELL(1,HOLDING,market);
IF (HOLDING = 0) THEN
BEGIN
BUYSHORT(1,S,market);
IF (NUM = 1) THEN
BEGIN
SS:=(SS + 1);
END
ELSE
BEGIN
IF (NUM = 0) THEN
BEGIN
SS:=(SS - 1);
END
END
END
END
IF (多 AND (TIME < 143000)) THEN
BEGIN
SELLSHORT(1,HOLDING,market);
IF (HOLDING = 0) THEN
BEGIN
BUY(1,S,market);
IF (NUM = 1) THEN
BEGIN
SS:=(SS + 1);
END
ELSE
BEGIN
IF (NUM = 0) THEN
BEGIN
SS:=(SS - 1);
END
END
END
END
持仓:HOLDING,COLORYELLOW;
压力2:=(昨高 - 5);
支撑2:=(昨低 + 5);
PD:=CROSS(HIGH,压力2);
PK:=CROSS(支撑2,LOW);
平空:SELLSHORT(PK,1,thisclose);
平多:SELL(PD,1,thisclose);
总盈利:GROSSPROFIT,COLORRED;
总亏损:GROSSLOSS,COLORGREEN;
连亏:MAXSEQLOSS;
连赢:MAXSEQWIN;
盈亏比:PAYOFFRATE;
最大连亏:SEQLOSS;
最大连赢:SEQWIN;
IF (TIME > 143000) THEN
BEGIN
SELL(1,HOLDING,market);
SELLSHORT(1,HOLDING,market);
END
0;
{
KD:=; //开多条件
PD:=; //平多条件
KK:=; //开空条件
PK:=; //平空条件
平空:SELLSHORT(PK,1,THISCLOSE); //平空信号
开多:BUY(KD AND HOLDING=0,1,THISCLOSE); //开多信号
平多:SELL(PD,1,THISCLOSE); //平多信号
开空:BUYSHORT(KK AND HOLDING=0,1,THISCLOSE); //开空信号
}
{
信号语句排列规则——先平后开
“费率设置”按钮——用于合理设置模型“费率”,以便在图形上正确输出如下帐户信息:
持仓:holding,linethick0;
资产:asset,noaxis;
可用现金:cash(0),linethick0;
您可以在查看菜单->交易系统模板 中设置自己需要的模板
}