-- 作者:infocell
-- 发布时间:2015/3/3 14:37:06
-- 模拟帐号无法开仓问题
启动以后,我输入的参数满足条件,也开了仓了,但模拟帐号中没有开单记录,消息框也有输出开仓,不过文件写入也有问题,没有输出开仓,很奇怪。
请帮忙看一下。
INPUT:Buy_START(9330,1,15000,1),Buy_STEP(30,1,500,1),Buy_END(9390,1,15000,1),Buy_SS(1,1,6,1);
INPUT:MAX_hold(10,1,30,1); INPUT:NMIN(2,1,100,1);//;,X(20,1,100,1),SS(1,1,10000,1);
VARIABLE:Num_p0=(Buy_END-Buy_START)/Buy_STEP+1; VARIABLE:SNum_p0=(Sell_END-Sell_START)/Sell_STEP+1; VARIABLE:I_tmp=0,S_tmp=0,S_tmp1=0; VARIABLE:Buy_point[Num_p0]=0;//买点 VARIABLE:B_NUM=0;//买的总量的标记 VARIABLE:Is_debug=1,Is_log=1;
开仓时间:=TIME>085300 AND TIME<150000-NMIN*100;//开仓时间:=TIME>OPENTIME(1)-200 AND TIME<150000-NMIN*100; 平仓时间:=TIME>=150000-NMIN*100; Ttmp:=TIME; Ttmp1:=150000-NMIN*100; {NMIN为参数,CLOSETIME(0)-NMIN*100表示 收盘时间-提前N分钟 N由NMIN控制} 开多平空条件:=开仓时间; 开空平多条件:=开仓时间;
FOR I_tmp=1 TO Num_p0 DO BEGIN IF Buy_point[I_tmp]<=0 THEN Buy_point[I_tmp]:=Buy_START+(I_tmp-1)*Buy_STEP;
END;
FOR I_tmp=1 TO Num_p0 DO BEGIN
IF B_flag[I_tmp]<=0 AND B_NUM<MAX_hold and ABS(holding)<MAX_hold THEN BEGIN
IF 开空平多条件 AND OPEN>=Buy_point[I_tmp] THEN BEGIN b_tmpp:=Buy_SS; //开单量不能超过最大MAX_hold IF b_tmpp+ABS(holding)>MAX_hold THEN b_tmpp:=ABS(MAX_hold-ABS(holding)); IF b_tmpp+B_NUM>MAX_hold THEN b_tmpp:=ABS(MAX_hold-B_NUM); S_tmp:=HOLDING; //开空 IF b_tmpp>0 AND b_tmpp<ABS(MAX_hold) THEN BEGIN 开空:buyshort(1,b_tmpp,MARKET);//LIMITR,OPEN);//MARKET);//limitr,X周期低点); B_NUM:=B_NUM+1; IF Is_debug=1 THEN MSGOUT(TRUE,\'持仓补仓数:\'&numtostr(tmpppp,0)&\',成交价:\'&numtostr(ENTERPRICE,0)&\',持仓:\'&numtostr(HOLDING,0)&\',浮动盈亏:\'&numtostr(OPENPROFIT,0)&\',总买单数:\'&numtostr(B_NUM,0)&\',资产:\'&numtostr(ASSET,0)); IF Is_log=1 THEN DEBUGFILE(\'C:\\myTEST.TXT\',\'持仓补仓数:\'&numtostr(tmpppp,0)&\',成交价:\'&numtostr(ENTERPRICE,0)&\',持仓:\'&numtostr(HOLDING,0)&\',浮动盈亏:\'&numtostr(OPENPROFIT,0)&\',总买单数:\'&numtostr(B_NUM,0)&\',资产:%.0f\',asset);
END
END
|
-- 作者:infocell
-- 发布时间:2015/3/3 14:57:56
--
老师,我实在不明白,如果buyshort不执行,那怎么会到MSGOUT这句话呢?
这句话是我用来调试看有没有执行buyshort的。
您说的开仓条件是指前面的if里面的条件,还是别的触发条件?
开空:buyshort(1,b_tmpp,MARKET);//LIMITR,OPEN);//MARKET);//limitr,X周期低点); B_NUM:=B_NUM+1; IF Is_debug=1 THEN MSGOUT(TRUE,\'持仓补仓数:\'&numtostr(tmpppp,0)&\',成交价:\'&numtostr(ENTERPRICE,0)&\',持仓:\'&numtostr(HOLDING,0)&\',浮动盈亏:\'&numtostr(OPENPROFIT,0)&\',总买单数:\'&numtostr(B_NUM,0)&\',资产:\'&numtostr(ASSET,0));
|
-- 作者:infocell
-- 发布时间:2015/3/3 15:07:37
--
不好意思,这个是我没贴全的问题?这个可以编译了,帮忙看一下。谢谢
INPUT:Buy_START(9330,1,15000,1),Buy_STEP(30,1,500,1),Buy_END(9390,1,15000,1),Buy_SS(1,1,6,1);
INPUT:MAX_hold(10,1,30,1); INPUT:NMIN(2,1,100,1);//;,X(20,1,100,1),SS(1,1,10000,1);
VARIABLE:Num_p0=(Buy_END-Buy_START)/Buy_STEP+1; VARIABLE:B_flag[Num_p0]=00;//?òμ?±ê?? VARIABLE:Num_p0=(Buy_END-Buy_START)/Buy_STEP+1; //VARIABLE:SNum_p0=(Sell_END-Sell_START)/Sell_STEP+1; VARIABLE:I_tmp=0,S_tmp=0,S_tmp1=0; VARIABLE:Buy_point[Num_p0]=0;//?òμ? VARIABLE:B_NUM=0;//?òμ?×üá?μ?±ê?? VARIABLE:Is_debug=1,Is_log=1;
?a2?ê±??:=TIME>085300 AND TIME<150000-NMIN*100;//?a2?ê±??:=TIME>OPENTIME(1)-200 AND TIME<150000-NMIN*100; ??2?ê±??:=TIME>=150000-NMIN*100; Ttmp:=TIME; Ttmp1:=150000-NMIN*100; {NMIN?a2?êy£?CLOSETIME(0)-NMIN*100±íê? ê??ìê±??-ìá?°N·??ó NóéNMIN????} ?a?à????ì??t:=?a2?ê±??; ?a?????àì??t:=?a2?ê±??;
FOR I_tmp=1 TO Num_p0 DO BEGIN IF Buy_point[I_tmp]<=0 THEN Buy_point[I_tmp]:=Buy_START+(I_tmp-1)*Buy_STEP;
END;
FOR I_tmp=1 TO Num_p0 DO BEGIN
IF B_flag[I_tmp]<=0 AND B_NUM<MAX_hold and ABS(holding)<MAX_hold THEN BEGIN
IF ?a?????àì??t AND OPEN>=Buy_point[I_tmp] THEN BEGIN b_tmpp:=Buy_SS; //?aμ¥á?2??ü3?1y×?′óMAX_hold IF b_tmpp+ABS(holding)>MAX_hold THEN b_tmpp:=ABS(MAX_hold-ABS(holding)); IF b_tmpp+B_NUM>MAX_hold THEN b_tmpp:=ABS(MAX_hold-B_NUM); S_tmp:=HOLDING; //?a?? IF b_tmpp>0 AND b_tmpp<ABS(MAX_hold) THEN BEGIN ?a??:buyshort(1,b_tmpp,MARKET);//LIMITR,OPEN);//MARKET);//limitr,X?ü?úμíμ?); B_NUM:=B_NUM+1; IF Is_debug=1 THEN MSGOUT(TRUE,\'3?2?212?êy:\'&numtostr(b_tmpp,0)&\',3é????:\'&numtostr(ENTERPRICE,0)&\',3?2?:\'&numtostr(HOLDING,0)&\',???ˉóˉ?÷:\'&numtostr(OPENPROFIT,0)&\',×ü?òμ¥êy:\'&numtostr(B_NUM,0)&\',×ê2ú:\'&numtostr(ASSET,0)); IF Is_log=1 THEN DEBUGFILE(\'C:\\myTEST.TXT\',\'3?2?212?êy:\'&numtostr(b_tmpp,0)&\',3é????:\'&numtostr(ENTERPRICE,0)&\',3?2?:\'&numtostr(HOLDING,0)&\',???ˉóˉ?÷:\'&numtostr(OPENPROFIT,0)&\',×ü?òμ¥êy:\'&numtostr(B_NUM,0)&\',×ê2ú:%.0f\',asset);
END end end END
|