
等级: 专业版
- 注册:
- 2022-1-11
- 曾用名:
|

楼主 |
发表于 2024-4-22 15:52
|
显示全部楼层
INPUT:M(35,5,300,30),N(2,0.1,10,0.1), trs(50,1,100,1) ;
VARIABLE:X:=50 ,LIQKA:=0,cond1:=0,cond2:=0, cond3:=0, cond4: =0, kcond1:=0, kcond2:=0, kcond3:=0, kcond4:=0 ,dliqpoint:=0 ,kliqpoint:=0 ;
VARIABLE:lowafterentry:=0,highafterentry:=0;
if ENTERBARS =0 then begin
highafterentry:= high;
lowafterentry:= low;
end
if ENTERBARS >0 then begin
highafterentry:= min(highafterentry,high); // 空头止损,更新最低的最高价
lowafterentry:= max(lowafterentry,low); // 多头止损,更新最高的最低价
end
ma1:= ma(Close,n*3);
MidLine := ma(Close,m);
Band:= std(Close,m);
UpLine:= MidLine + n * Band;
DownLine:= MidLine - n* Band;
cond1:=IIF(MidLine>ref(MidLine,1) and C>MidLine,MidLine,cond1); // 根据条件判断更新cond1的值
cond2:= IIF(UpLine>ref(UpLine,1) and H>UpLine ,UpLine,cond2); // 根据条件判断更新cond2的值
cond3:= IIF(DownLine<ref(DownLine,1) and L<DownLine ,DownLine,cond3); // 根据条件判断更新cond3的值
cond4:= IIF(ma1>ref(ma1,1) and C>ma1 ,ma1,cond4); // 根据条件判断更新cond4的值
kcond1:= IIF(MidLine<ref(MidLine,1) and C<MidLine,MidLine,kcond1); // 根据条件判断更新kcond1的值
kcond2:= IIF(UpLine>ref(UpLine,1) and H>UpLine ,UpLine,kcond2); // 根据条件判断更新kcond2的值
kcond3:= IIF(DownLine<ref(DownLine,1) and L<DownLine ,DownLine,kcond3); // 根据条件判断更新kcond3的值
kcond4:= IIF(ma1<ref(ma1,1) and C<ma1 ,ma1,kcond4); // 根据条件判断更新kcond4的值
BB1:=((C-DownLine)/(UpLine-DownLine)); //布林极限(BB)=(收盘价-布林下轨价格)/(布林上轨价格-布林下轨价格)
开多平空条件:= (ref(cond1,1) >ref(cond1,2) and ref(cond2,1) >ref(cond2,2) and ref(cond3,1) >ref(cond3,2) and ref(cond4,1) >ref(cond4,2)) ;//
开空平多条件:= (ref(kcond1,1)<ref(kcond1,2) and ref(kcond2,1)<ref(kcond2,2) and ref(kcond3,1)<ref(kcond3,2) and ref(kcond4,1)<ref(kcond4,2)) ;
zssk2:=1;
zssd2:=1;
if 开多平空条件 then BEGIN
平空:SELLSHORT( HOLDING<0,zssk2,MARKETR);
开多:BUY( HOLDING=0,zssd2,MARKETR);
lowafterentry:=ENTERPRICE;
END
if 开空平多条件 then BEGIN
平多:SELL( HOLDING>0,zssd2,MARKETR);
开空:BUYSHORT( HOLDING=0,zssk2,MARKETR);
highafterentry:=ENTERPRICE;
END
帮我看一下,这个为什么没有信号。
补充内容 (2024-4-22 15:54):
if holding=0 then begin // 自适应参数默认值;
liqka:= 1;
end
if holding<>0 then begin //当有持仓的情况下,liqka会随着持仓时间的增加而逐渐减小,即止损止盈幅度乘数的减少。
liqka:=liqka - 0.1;
liqka:=max(liqka,0.5);
end
if holding>0 then begin
dliqpoint:=lowafterentry - (open*trs/1000)*liqka; //;
end
if holding<0 then begin
kliqpoint:=highafterentry + (open*trs/1000)*liqka; //
end
//------------------------------------------------------------------------------------------------
//跟踪止损
//------------------------------------------------------------------------------------------------
aa:ref(dliqpoint,1), colorred ;
bb:ref(kliqpoint,1), colorgreen ;
// 持有多单时 价格下破自适应出场均线,平多单
if holding > 0 and enterbars >0 and ref(c,1) <= aa and ref(c,2) >= ref(dliqpoint,1) and dliqpoint>0 then begin
独孤九剑止多:sell(1,holding,marketr);
平多价格:min(aa,open);
end
// 持有空单时 价格上破自适应出场均线,平空单
if holding < 0 and enterbars >0 and ref(c,1)>= bb and ref(c,2) <= ref(kliqpoint,1) and kliqpoint>0 then begin
独孤九剑止空:sellshort(1,holding ,marketr);
平空价格:max(bb,open);
end
当前持仓:holding,colorgray,linethick0;
if holding=0 then begin // 自适应参数默认值;
liqka:= 1;
end
if holding<>0 then begin //当有持仓的情况下,liqka会随着持仓时间的增加而逐渐减小,即止损止盈幅度乘数的减少。
liqka:=liqka - 0.1;
liqka:=max(liqka,0.5);
end
if holding>0 then begin
dliqpoint:=lowafterentry - (open*trs/1000)*liqka; //;
end
if holding<0 then begin
kliqpoint:=highafterentry + (open*trs/1000)*liqka; //
end
//------------------------------------------------------------------------------------------------
//跟踪止损
//------------------------------------------------------------------------------------------------
aa:ref(dliqpoint,1), colorred ;
bb:ref(kliqpoint,1), colorgreen ;
// 持有多单时 价格下破自适应出场均线,平多单
if holding > 0 and enterbars >0 and ref(c,1) <= aa and ref(c,2) >= ref(dliqpoint,1) and dliqpoint>0 then begin
独孤九剑止多:sell(1,holding,marketr);
平多价格:min(aa,open);
end
// 持有空单时 价格上破自适应出场均线,平空单
if holding < 0 and enterbars >0 and ref(c,1)>= bb and ref(c,2) <= ref(kliqpoint,1) and kliqpoint>0 then begin
独孤九剑止空:sellshort(1,holding ,marketr);
平空价格:max(bb,open);
end
当前持仓:holding,colorgray,linethick0;
|
|