一分钟级别的策略,里面有调15分钟级别的指标
input:shakeRate(1,0.3,20,2);
orderNum:=ROUNDS(ASSET/200/c,0);
begintime:=(time>010300 and time<031000) or (time>130300 and time<184000);
endtime:=(time>032950 and time<033000) or (time>185950 and time<190000);
VARIABLE:cond:='none';
VARIABLE:pbxGoldPlus:='false';
VARIABLE:pbxDeadPlus:='false';
VARIABLE:pbxCond:='none';
VARIABLE:pbxCondPre:='none';
VARIABLE:outPrice:=0;
ma10:=ma(c,150);
last2h:=hhv(h,30);
last2l:=llv(l,30);
DIFF:=STKINDI('','MACD.DIFF',0,3);
DEA:=STKINDI('','MACD.DEA',0,3);
D1:STKINDI('','PBX.D1',0,3);
D2:STKINDI('','PBX.D2',0,3);
Z1:STKINDI('','PBX.Z1',0,3);
Z2:STKINDI('','PBX.Z2',0,3);
C1:STKINDI('','PBX.C1',0,3);
C2:STKINDI('','PBX.C2',0,3);
pbxGoldPlus:='false';
pbxDeadPlus:='false';
TR1:=STKINDI('','ATR.TR1',0,3);
ATR:=STKINDI('','ATR.ATR',0,3);
if HOLDING>0 and h>outPrice then outPrice:=h;
if HOLDING<0 and l<outPrice then outPrice:=l;
macdGoldPlus:=CROSS(DIFF,DEA);
macdDeadPlus:=CROSS(DEA,DIFF);
//多头仓位平仓
if HOLDING>0 and (macdDeadPlus or pbxDeadPlus='true' or endtime or c<ma10 or c<outPrice-2*ATR) then begin
SELL(1,HOLDING,MARKET);
end
//空头仓位平仓
if HOLDING<0 and (macdGoldPlus or pbxGoldPlus='true' or endtime or c>ma10 or c>outPrice+2*ATR) then begin
SELLSHORT(1,HOLDING,MARKET);
end
//开多
if HOLDING=0 and ((DIFF>DEA and pbxGoldPlus='true') or (macdGoldPlus='true' and pbxC))
and begintime and (c-last2l)*100/last2l<shakeRate then begin
BUY(1,orderNum,MARKET);
end
//开空
if HOLDING=0 and ((DIFF<DEA and pbxDeadPlus='true') or (macdDeadPlus='true' and pbxC))
and begintime and (last2h-c)*100/last2h<shakeRate then begin
BUYSHORT(1,orderNum,MARKET);
end
pbxCondPre:=pbxCond;
input:shakeRate(1,0.3,20,2);
orderNum:=ROUNDS(ASSET/200/c,0);
begintime:=(time>010300 and time<031000) or (time>130300 and time<184000);
endtime:=(time>032950 and time<033000) or (time>185950 and time<190000);
globalVARIABLE:cond:='none';
globalVARIABLE:pbxGoldPlus:='false';
globalVARIABLE:pbxDeadPlus:='false';
globalVARIABLE:pbxCond:='none';
globalVARIABLE:pbxCondPre:='none';
globalVARIABLE:outPrice:=0;
ma10:=ma(c,150);
last2h:=hhv(h,30);
last2l:=llv(l,30);
DIFF:=STKINDI('','MACD.DIFF',0,3);
DEA:=STKINDI('','MACD.DEA',0,3);
D1:STKINDI('','PBX.D1',0,3);
D2:STKINDI('','PBX.D2',0,3);
Z1:STKINDI('','PBX.Z1',0,3);
Z2:STKINDI('','PBX.Z2',0,3);
C1:STKINDI('','PBX.C1',0,3);
C2:STKINDI('','PBX.C2',0,3);
pbxGoldPlus:='false';
pbxDeadPlus:='false';
TR1:=STKINDI('','ATR.TR1',0,3);
ATR:=STKINDI('','ATR.ATR',0,3);
if tbuyHOLDING(0)>0 and h>outPrice then outPrice:=h;
if tsellHOLDING(0)>0 and l<outPrice then outPrice:=l;
macdGoldPlus:=CROSS(DIFF,DEA);
macdDeadPlus:=CROSS(DEA,DIFF);
//多头仓位平仓
if tbuyHOLDING(0)>0 and (macdDeadPlus or pbxDeadPlus='true' or endtime or c<ma10 or c<outPrice-2*ATR) then begin
tSELL(1,0,mkT);
end
//空头仓位平仓
if tsellHOLDING(0)>0 and (macdGoldPlus or pbxGoldPlus='true' or endtime or c>ma10 or c>outPrice+2*ATR) then begin
tSELLSHORT(1,0,mkt);
end
//开多
if tbuyHOLDING(0)=0 and ((DIFF>DEA and pbxGoldPlus='true') or (macdGoldPlus='true' and pbxC))
and begintime and (c-last2l)*100/last2l<shakeRate then begin
tBUY(1,orderNum,mkt);
end
//开空
if tsellHOLDING(0)=0 and ((DIFF<DEA and pbxDeadPlus='true') or (macdDeadPlus='true' and pbxC))
and begintime and (last2h-c)*100/last2h<shakeRate then begin
tBUYSHORT(1,orderNum,mkt);
end
pbxCondPre:=pbxCond;
不会冲突,机制上和variable差不多,后台里面不会互相冲突
我把上面的这段代码加了一些日志打印,可是一出信号,为什么后台日志不是只打出一条,而是一秒内打出非常多条
//开空
if EXTGBDATA('PBMACD_MA_SELL')=0 and ((DIFF<DEA and pbxDeadPlus='true') or (macdDeadPlus='true' and pbxC))
and (last2h-c)*100/last2h<shakeRate then begin
TBUYSHORT(1,orderNum,mkt);
EXTGBDATASET('PBMACD_MA_SELL',orderNum);
DEBUGFILE2(logFilePath,'b_pbMacd_MA:甲醇开空',1,1);
DEBUGFILE2(logFilePath,'b_pbMacd_RB:数量=%.0f',orderNum,1);
cond:='buy';
outPrice:=l;
end
2016-11-10 21:50:01.855 b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.855 b_pbMacd_RB:数量=4
2016-11-10 21:50:01.855 b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.855 b_pbMacd_RB:数量=4
2016-11-10 21:50:01.855 b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.855 b_pbMacd_RB:数量=4
2016-11-10 21:50:01.855 b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.855 b_pbMacd_RB:数量=4
2016-11-10 21:50:01.855 b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.855 b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871 b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.871 b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871 b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.871 b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871 b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.871 b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871 b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.871 b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871 b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.871 b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871 b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.871 b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871 b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.871 b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871 b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.871 b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871 b_pbMacd_MA:甲醇开空
2016-11-10 21:50:01.871 b_pbMacd_RB:数量=4
2016-11-10 21:50:01.871 b_pbMacd_MA:甲醇开空
因为你用的是debugfile2,这个是逐k打印的,后台监控了多少根k线,那么每来一笔行情就会输出对应的多少条件信息
你要用debugfile来输出