等级: 免费版
- 注册:
- 2024-1-6
- 曾用名:
|
买开仓价A:=open+1*mindiff;
买止损价A:=N5K最低点;
买止盈价A:=open+4*mindiff;
卖开仓价A:=open-1*mindiff;
卖止损价A:=N5K最高点;
卖止盈价A:=open-4*mindiff;
//*************** 4. 后台交易执行 ********************
//****持仓管理*****
globalvariable:B_01:=0,B_opn_01:=0,B_tkp_01:=0,B_stp_01:=0,B_stp_brk_01:=0,B_idx_01:=0,
s_01:=0,s_opn_01:=0,s_tkp_01:=0,s_stp_01:=0,s_stp_brk_01:=0,s_idx_01:=0;
R_C1:=REF(C,1);
//*************** 多头 后台********************
//****平仓*****
//@多单:止盈
if b_01=1 and close>=b_tkp_01 and tbuyholdingex('','',1)>0 then
begin
DA盈:tsell(1,1,lmt,close);
b_01:=0;
end
//@多单:价格limitr 止损
if b_01=1 AND R_C1<B_STP_01 and tbuyholdingex('','',1)>0 then
begin
DA损:tsell(1,1,lmt,close);
b_01:=0;
end
//@多单:开仓
if BS买开执行A组 and b_01=0 and tbuyholdingex('','',2)=0 and remainingtime(closetime(0))>15*60 then
begin
DA:tbuy(1,1,lmt,买开仓价A);
b_01:=1;
b_opn_01:=买开仓价A;
b_tkp_01:=买止盈价A;
b_stp_01:=买止损价A;
b_idx_01:=barpos;
end
//*************** 空头 ********************
//****平仓*****
//@空单:止盈
if s_01=1 and close<=s_tkp_01 and tsellholdingex('','',1)>0 then
begin
KA盈:tsellshort(1,1,lmt,close);
s_01:=0;
end
//@空单:limitr价格止损
if s_01=1 AND R_C1>S_STP_01 and tsellholdingex('','',1)>0 then
begin
KA损:tsellshort(1,1,lmt,open);
s_01:=0;
end
//@空单:开仓
if BS卖开执行A组 and s_01=0 and tsellholdingex('','',2)=0 and remainingtime(closetime(0))>15*60 then // and TJ位置卖A
begin
KA:tbuyshort(BS卖开执行A组,1,lmt,卖开仓价A);
s_01:=1;
s_opn_01:=卖开仓价A;
s_tkp_01:=卖止盈价A;
s_stp_01:=卖止损价A;
s_idx_01:=barpos;
end
//2. 收盘前2分钟自动全部平仓,
if remainingtime(closetime(0))<2*60 then begin
tsellshort(tsellholdingex('','',1)>0,tsellholdingex('','',1),mkt);
tsell(tbuyholdingex('','',1)>0,tbuyholdingex('','',1),mkt);
end
//3. 5分钟后撤单 买开或者卖开5分钟不成交, 那么撤掉报出的买开或者卖开的报价
if TSUBMITEX(1 ,'' ,'' )>5*60 then
begin
TCANCEL(1,1);
tbuy(1,1,mkt);
END
LJ:STRCAT(STRCAT('C:\调试日志\',STKLABEL),'.TXT');
IF ISLASTBAR THEN BEGIN
DEBUGFILE(LJ,'多头持仓='&NUMTOSTR(TBUYHOLDINGEX('','',2),0)&' 空头持仓='&NUMTOSTR(TSELLHOLDINGEX('','',2),0)&' 最新价='&NUMTOSTR(C,2)&' 前收='&NUMTOSTR(R_C1,2),1);
DEBUGFILE(LJ,'开多条件1='&NUMTOSTR(BS买开执行A组,0)&' 开多条件2='&NUMTOSTR(BS买开执行B组,0)&' 开多标记1='&NUMTOSTR(B_01,0)&' 开多标记2='&NUMTOSTR(B_02,0),1);
DEBUGFILE(LJ,'短线买开仓价A='&NUMTOSTR(B_OPN_01,2)&' 短线买止盈价A='&NUMTOSTR(B_TKP_01,2)&' 短线买止损价A='&NUMTOSTR(B_STP_01,2),1);
DEBUGFILE(LJ,'短线买开仓价B='&NUMTOSTR(B_OPN_02,2)&' 短线买止盈价B='&NUMTOSTR(B_TKP_02,2)&' 短线买止损价B='&NUMTOSTR(B_STP_02,2),1);
DEBUGFILE(LJ,'短线卖开仓价A='&NUMTOSTR(S_OPN_01,2)&' 短线卖止盈价A='&NUMTOSTR(S_TKP_01,2)&' 短线卖止损价A='&NUMTOSTR(S_STP_01,2),1);
DEBUGFILE(LJ,'短线卖开仓价B='&NUMTOSTR(S_OPN_02,2)&' 短线卖止盈价B='&NUMTOSTR(S_TKP_02,2)&' 短线卖止损价B='&NUMTOSTR(S_STP_02,2),1);
DEBUGFILE(LJ,'-------------------------------------------------------',1);
END
|
|