等级: 免费版
- 注册:
- 2021-5-20
- 曾用名:
|
老师好,我的模型原是文华的,现在想改回K走完模式。折腾了许多天,都不知道这其中的逻辑了。请老师帮忙从轮询改为K走完模式。
VARIABLE:KCN=0,mHolding=0;
资:ASSET-1000000,NOAXIS,COLORRED;
仓:HOLDING,LINETHICK0,COLORYELLOW;
MA1:=EMA(O,3),COLORGREEN;
KDPK0:=C<REF(C,1);
KKPD0:=C>REF(C,1);
KDPK00:=C<REF(C,1);
KKPD00:=C>REF(C,1);
KDPK2:=KDPK00&&MA1<C;
KKPD2:=KKPD00&&MA1>=C;
KDPK3:=REF(KDPK2,1);
KKPD3:=REF(KKPD2,1);
//交易系统
if KDPK3 then begin
KCN:=1;
end
if KKPD3 then begin
KCN:=-1;
end
TJ0:=BARSLAST((KDPK0&&mHOLDING<0)||(KKPD0&&mHOLDING>0));
//-------------金字塔BPK书写------------------------------------------------------
BKCN:=TJ0>=1;
//-------------金字塔平书写仓------------------------------------------------------
BP1:mholding>0 and (BKCN=1),NODRAW;
SP1:mholding<0 and (BKCN=1),NODRAW;
if BP1 then begin
sell(1,0,limitR,C);
mHolding:=0;
end
if SP1 then begin
//sellshort(1,0,limitR,C);
mHolding:=0;
end
SK1:KCN=-1 and ( EXITBARS>=1) and abs(mholding)<2 and mholding<=0,NODRAW;
BK1:KCN=1 and ( EXITBARS>=1) and abs(mholding)<2 and mholding>=0,NODRAW;
if KCN=1 and TYPE(1)=0 and abs(mholding)<2 and mholding>=0 then begin
buy(1,1,limitR,C);
mHolding:=mHolding+1;
end
if KCN=-1 and TYPE(1)=0 and abs(mholding)<2 and mholding<=0 then begin
//buyshort(1,1,limitR,O);
mHolding:=mHolding-1;
end
if bk1 then begin
buy(1,1,limitR,O);
mHolding:=mHolding+1;
end
if sk1 then begin
//buyshort(1,1,limitR,O);
mHolding:=mHolding-1;
end
|
|