等级: 专业版
- 注册:
- 2021-5-20
- 曾用名:
|
GLOBALVARIABLE:zs=c,maxhl=c;
//顾比倒数线
DISTL:=NEWLBARS(L,1);
DISTH:=NEWHBARS(H,1);
HI20:=REF(HHV(H,20),1);
LO20:=REF(LLV(L,20),1);
GBD1:=REF(L,DISTL);
GBD2:=REF(GBD1,DISTL);
GBD:=IF(GBD2>0,MAX(LLV(L,20),GBD2),LLV(L,20));
GBG1:=REF(H,DISTH);
GBG2:=REF(GBG1,DISTH);
GBG:=IF(GBG2>0,MIN(HHV(H,20),GBG2),HHV(H,20));
//SAR指标
Sar1:=SAR(10,2,20){,CIRCLEDOT};
//MACD指标
DIFF := EMA(CLOSE,12) - EMA(CLOSE,26);
DEA := EMA(DIFF,9);
MACD := 2*(DIFF-DEA);
//交易条件
con1:any(ref(Sar1>high,1) and Sar1<high,3)=1; //最近3周期,有SAR向上突破K线
con2:any(cross(diff,dea),3)=1 and diff<5; //最近3周期,MACD在0线附近金叉
//下单模块
//止盈止损平仓:下破移动止损线后离场
if tholding>0 and c<zs then tsell(1,100,mkt);
//成本止损
zsc:c<tavgenterpriceex2('','',0)*0.96;
if tholding>0 and zsc then tsell(1,100,mkt);
//开多仓:SAR向上突破K线,MACD在0线附近金叉
if con1 and con2 and ttotaldaytrade<1 then
begin
tbuy(tbuyholding(1)=0,100,mkt);
zs:=gbd; //调用顾比倒数线做为止损
maxhl:=h; //记录当时的高点
end
if tholding>0 and h>maxhl then //创新高后,重新定位离场位,以实现浮动止损
begin
zs:=gbd;
maxhl:=h;
end
止损线:zs,colorred;
老师,这段程序这样改成后台对吗?为什么图表显示下破止损线很多了,可后台并不执行呢?是全局变量设置的问题吗?谢谢!
|
|