//本方法利用全局变量来交换必要的数据,发出来切磋一下。并请提提建议。
//止损止赢部分的开、平仓条件
last_high_0:=EXTGBDATA('last_high');
last_low_0:=EXTGBDATA('last_low');
kc_price_0:=EXTGBDATA('kc_price');
tx_holding_0:=EXTGBDATA('tx_holding');
high_0:=high;
close_0:=close;
low_0:=low;
if tx_holding_0>0 and high_0>last_high_0 then EXTGBDATASET('last_high',high_0);
if tx_holding_0<0 and low_0<last_low_0 then EXTGBDATASET('last_low',low_0);
if last_high_0=kc_price_0 then last_high_0:=last_high_0+50;
if last_low_0 =kc_price_0 then last_low_0 :=last_low_0-50;
开多仓后最高涨幅:=(last_high_0-kc_price_0)/kc_price_0;
开多涨回撤比例限制:=1/sqrt(开多仓后最高涨幅*100+止赢系数);
开多涨回撤幅度限制:=(last_high_0-kc_price_0)*开多涨回撤比例限制;
开多涨回撤价格限制:=last_high_0-开多涨回撤幅度限制;
if 开多仓后最高涨幅<1.5% then 开多涨回撤价格限制:=last_high_0*(1-止损百分比);
pd_tj_多头止损:=tx_holding_0>0 and ( close_0<kc_price_0*(1-止损百分比) );
pd_tj_多头止赢:=tx_holding_0>0 and ( close_0<开多涨回撤价格限制 );
开空仓后最大跌幅:=(kc_price_0-last_low_0)/kc_price_0;
开空跌回撤比例限制:=1/sqrt(开空仓后最大跌幅*100+止赢系数);
开空跌回撤幅度限制:=(kc_price_0-last_low_0)*开空跌回撤比例限制;
开空跌回撤价格限制:=last_low_0+开空跌回撤幅度限制;
if 开空仓后最大跌幅<1.5% then 开空跌回撤价格限制:=last_low_0*(1+止损百分比);
pk_tj_空头止损:=tx_holding_0<0 and ( close_0>kc_price_0*(1+止损百分比) );
pk_tj_空头止赢:=tx_holding_0<0 and ( close_0>开空跌回撤价格限制 );
{平多}EXITLONG: pd_tj_多头止损 or pd_tj_多头止赢 ,ORDERQUEUE ; { ,TFILTER; }
{平空}EXITSHORT: pk_tj_空头止损 or pk_tj_空头止赢 ,ORDERQUEUE ; { ,TFILTER; }
{开多}ENTERLONG: KD_TJ ,ORDERQUEUE ; { ,TFILTER; }
{开空}ENTERSHORT: KK_TJ ,ORDERQUEUE ; { ,TFILTER; }
// 开多 保存全局变量
if ( KD_TJ and tx_holding_0<1 ) then
begin EXTGBDATASET('last_high',high_0);
EXTGBDATASET('last_low',low_0);
EXTGBDATASET('tx_holding',1);
EXTGBDATASET('kc_price',close_0);
end
// 开空 保存全局变量
if ( KK_TJ and tx_holding_0>-1 ) then
begin EXTGBDATASET('last_high',high_0);
EXTGBDATASET('last_low',low_0);
EXTGBDATASET('tx_holding',-1);
EXTGBDATASET('kc_price',close_0);
end
// 平多仓后保存全局变量
if (( pd_tj_多头止损 or pd_tj_多头止赢 ) and tx_holding_0>0 ) then
begin EXTGBDATASET('last_high',1);
EXTGBDATASET('last_low',1);
EXTGBDATASET('tx_holding',0);
EXTGBDATASET('kc_price',1);
end
// 平空仓后保存全局变量
if (( pk_tj_空头止损 or pk_tj_空头止赢 ) and tx_holding_0<0 ) then
begin EXTGBDATASET('last_high',1);
EXTGBDATASET('last_low',1);
EXTGBDATASET('tx_holding',0);
EXTGBDATASET('kc_price',1);
end
编译不通过, if 开多仓后最高涨幅<1.5% then 开多涨回撤价格限制:=last_high_0*(1-止损百分比); 提示无法识别算术计算式 |