等级: 新手上路
- 注册:
- 2021-6-25
- 曾用名:
|
//全局变量
VARIABLE: kd_sign=0;
VARIABLE: pd_sign=0;
VARIABLE: kk_sign=0;
VARIABLE: pk_sign=0;
VARIABLE: LOGFILEPATH='D:\\TB\TTRADE\TEST.log';
VARIABLE: act_sign='D:\\TB\TTRADE\TEST.txt';
INPUT:n(5,1,100),m(10,2,100);
ma5:ma(HIGH,n);
ma10:ma(HIGH,m);
//5均线上穿10均线,开多、平空
dd:=CROSS(ma5,ma10);
//看多
if dd then
begin
if islastbar then
BEGIN
DEBUGFILE(LOGFILEPATH,STKLABEL()&',dd:'&numtostr(dd,0)&',curprice:'&numtostr(close,2)&',ma5:'&numtostr(ma5,2)&',ma10:'&numtostr(ma10,2)&',hoding:%.0f',holding); //写日志-看多条件
DEBUGFILE(LOGFILEPATH,STKLABEL()&',pk_sign:'&numtostr(pk_sign,0)&',kd_sign:'&numtostr(kd_sign,0)&',pd_sign:'&numtostr(pd_sign,0)&',kk_sign:'&numtostr(kk_sign,2)&',hoding:%.0f',holding); //写日志-看全局变量
END
//平空
IF HOLDING<0 THEN
BEGIN
if islastbar and pk_sign=0 then
BEGIN
DEBUGFILE(act_sign,','&STKLABEL()&',closeshort,'&'CALLPRICE='&numtostr(close,2),0);//输出平空信号
pk_sign:=1;
kk_sign:=0;
DEBUGFILE(LOGFILEPATH,'after send_close_short_sign'&',pk_sign:'&numtostr(pk_sign,0)&',kd_sign:'&numtostr(kd_sign,0)&',pd_sign:'&numtostr(pd_sign,0)&',kk_sign:'&numtostr(kk_sign,2)&',hoding:%.0f',holding); //写日志-看全局变量
END
SELLSHORT(HOLDING<0,0,THISCLOSE);
if HOLDING=0 and ISLASTBAR THEN
DEBUGFILE(LOGFILEPATH,','&STKLABEL()&',close_short,'&'CLOSESHORT_PRICE='&numtostr(EXITPRICE(),2)&',holding:%.0f',holding);//写日志-平空价格
END
// 开多
IF HOLDING=0 THEN
BEGIN
if islastbar and kd_sign=0 then
BEGIN
DEBUGFILE(act_sign,','&STKLABEL()&',openlong,'&'CALLPRICE='&numtostr(close,2),0);//输出开多信号
kd_sign:=1;
pd_sign:=0;
DEBUGFILE(LOGFILEPATH,'after send_open_long_sign'&',pk_sign:'&numtostr(pk_sign,0)&',kd_sign:'&numtostr(kd_sign,0)&',pd_sign:'&numtostr(pd_sign,0)&',kk_sign:'&numtostr(kk_sign,2)&',hoding:%.0f',holding); //写日志-看全局变量
END
buy(holding=0,1,THISCLOSE);
if HOLDING>0 and islastbar then
DEBUGFILE(LOGFILEPATH,','&STKLABEL()&',openlong,'&'OPENLONG_PRICE='&numtostr(ENTERPRICE,2)&',holding:%.0f',holding);//写日志-开多价格
END
end
//5日均线下破10日均线,平多、开空
kk:=CROSS(ma10,ma5);
//看空
if kk then
begin
if islastbar then
BEGIN
DEBUGFILE(LOGFILEPATH,STKLABEL()&',kk:'&numtostr(kk,0)&',curprice:'&numtostr(close,2)&',ma5:'&numtostr(ma5,2)&',ma10:'&numtostr(ma10,2)&',hoding:%.0f',holding); //写日志-看空条件
DEBUGFILE(LOGFILEPATH,STKLABEL()&',pk_sign:'&numtostr(pk_sign,0)&',kd_sign:'&numtostr(kd_sign,0)&',pd_sign:'&numtostr(pd_sign,0)&',kk_sign:'&numtostr(kk_sign,2)&',hoding:%.0f',holding); //写日志-看全局变量
END
//平多
IF HOLDING>0 THEN
BEGIN
if islastbar and pd_sign=0 then
BEGIN
DEBUGFILE(act_sign,','&STKLABEL()&',closelong,'&'CALLPRICE='&numtostr(close,2),0);//输出平多信号
pd_sign:=1;
kd_sign:=0;
DEBUGFILE(LOGFILEPATH,'after send_close_long_sign'&',pk_sign:'&numtostr(pk_sign,0)&',kd_sign:'&numtostr(kd_sign,0)&',pd_sign:'&numtostr(pd_sign,0)&',kk_sign:'&numtostr(kk_sign,2)&',hoding:%.0f',holding); //写日志-看全局变量
END
sell(holding>0,0,THISCLOSE);
if HOLDING=0 and ISLASTBAR then
DEBUGFILE(LOGFILEPATH,','&STKLABEL()&',closelong,'&'CLOSE_LONG_PRICE='&numtostr(EXITPRICE(),2)&',holding:%.0f',holding);//写日志-平多价格
END
//开空
if holding=0 then
BEGIN
if islastbar and kk_sign=0 then
BEGIN
DEBUGFILE(act_sign,','&STKLABEL()&',openshort,'&'CALLPRICE='&numtostr(close,2),0);//输出开空信号
kk_sign:=1;
pk_sign:=0;
DEBUGFILE(LOGFILEPATH,'after send_open_short_sign'&',pk_sign:'&numtostr(pk_sign,0)&',kd_sign:'&numtostr(kd_sign,0)&',pd_sign:'&numtostr(pd_sign,0)&',kk_sign:'&numtostr(kk_sign,2)&',hoding:%.0f',holding); //写日志-看全局变量
END
buyshort(holding=0,1,THISCLOSE);
if HOLDING<0 and islastbar then
DEBUGFILE(LOGFILEPATH,','&STKLABEL()&',open_short,'&'OPEN_SHORT_PRICE='&numtostr(ENTERPRICE,2)&',holding:%.0f',holding);//写日志-开空价格
END
end
持仓:holding,linethick0; |
|