等级: 免费版
- 注册:
- 2021-11-11
- 曾用名:
|

楼主 |
发表于 2022-7-19 14:11
|
显示全部楼层
KD:=buycond; //开多条件
PD:=sellcond; //平多条件
KK:=buyshortcond; //开空条件
PK:=sellshortcond; //平空条件
VARIABLE:maxprofit=0;//声明全局变量dprofit 为多单最大盈利,kprofit为空单最大盈利
dprofit:=(hhv(h,enterbars)-avgenterprice);//多单最大盈利
kprofit:=(avgenterprice-llv(l,enterbars));//空单最大盈利
开多:BUY(KD AND HOLDING=0,1,THISCLOSE); //开多信号
多单止损: IF l<buystoploss THEN BEGIN
SELL(1,HOLDING,MARKET);//多单止损
END
if holding>0 then begin
maxprofit:=dprofit;
buyprofit:=c-enterbars;//持多仓盈利点数
if maxprofit>=11 then begin sell(buyprofit<=1,holding,market);
end //如果最大盈利点数达到11点,利润回吐到1个点时平仓
if maxprofit>=21 then begin sell(buyprofit<=11,holding,market);
end //如果最大盈利点数达到21点,利润回吐到11个点时平仓
end
平多:SELL(PD,1,THISCLOSE);//正常平多信号
开空:BUYSHORT(KK AND HOLDING=0,1,THISCLOSE);//正常开空信号
空单止损: IF h>buyshortstoploss or c-AVGENTERPRICE>10*MINDIFF THEN BEGIN
SELLshort(1,HOLDING,MARKET);
END//空单止损
if holding<0 then begin
maxprofit:=kprofit;
buyshortprofit:=c-enterbars;//持多仓盈利点数
if maxprofit>=11 then begin sellshort(buyshortprofit<=1,holding,market);
end //如果最大盈利点数达到11点,利润回吐到1个点时平仓
if maxprofit>=21 then begin sellshort(buyshortprofit<=11,holding,market);
end //如果最大盈利点数达到21点,利润回吐到11个点时平仓
end
平空:SELLSHORT(PK,1,THISCLOSE); //正常平空信号
持仓:holding,linethick0;
资产:asset,noaxis;
可用现金:cash(0),linethick0; |
|