請老師修改成博易的指標,謝謝 [博易POBO]
咨詢內容:
VARIABLE:dayCount=1,PositionCount=1,SellSign=0,dK=0;//加多空標志,1:多,-1:空 0:空倉
VARIABLE:EntAndExitSign=1,EntPoint=0,ExitPoint=0;
VARIABLE:N=0;
N:=MA(TR,trn);
BUYHHV:=HHV(H,hn);
SELLLLV:=LLV(L,ln);
sellshortllv:=llv(l,hn);
buyshorthhv:=hhv(h,ln);
IF BARPOS>=hn THEN
BEGIN
IF BARPOS=hn THEN
IF DayCount=hn/2 OR BARPOS=hn THEN
BEGIN{hn/2天調整N值}
N:=((hn-1)*N+TR)/hn;{計算N值}
DayCount:=2;
END
DayCount:=DayCount+1;
EntPoint:=ENTERBARS+1;
IF EntPoint=EntAndExitSign THEN
BEGIN{說明STOP指令買進頭寸成功}
PositionCount:=PositionCount+1;{頭寸計數}
SellSign:=True;{可以平倉信號,如果達到指定的價格}
END
IF PositionCount=1 THEN BEGIN{第一頭寸}
HOW:=CASH(0)*0.01/N;{波動性百分比決定頭寸規模}
if high=buyhhv then
BEGIN
dk:=1;
多開1:BUY(1,HOW,STOP,BUYHHV);{在20日新高STOP指令買進}
END;
if low=sellshortllv then
begin
dk:=-1;
空開1:buyshort(1,HOW,STOP,sellshortllv);{在20日新低STOP指令空開}
end;
END
IF PositionCount=2 THEN BEGIN{如到第二頭寸}
HOW:=CASH(0)*0.01/N;{波動性百分比決定頭寸規模}
if dk=1 then 多開2:BUY(1,HOW,STOP,ENTERPRICE+0.5*N);{在上頭寸(即第一頭寸)+0.5個N以STOP指令買進}
if dk=-1 then 空開2:buyshort(1,HOW,STOP,ENTERPRICE-0.5*N);
END
IF PositionCount=3 THEN BEGIN{如到第三頭寸}
HOW:=CASH(0)*0.01/N;
if dk=1 then 多開3:BUY(1,HOW,STOP,ENTERPRICE+0.5*N);{在上頭寸(即第二頭寸)+0.5個N以STOP指令買進}
if dk=-1 then 空開3:buyshort(1,HOW,STOP,ENTERPRICE-0.5*N);
END
IF PositionCount=4 THEN BEGIN
HOW:=CASH(0)*0.01/N;
if dk=1 then 多開4:BUY(1,HOW,STOP,ENTERPRICE+0.5*N);
if dk=-1 then 空開4:buyshort(1,HOW,STOP,ENTERPRICE-0.5*N);
END
IF SellSign=True THEN
BEGIN
ExitPoint:=EXITBARS+1;
if dk=1 then
begin
IF ExitPoint=EntAndExitSign THEN
BEGIN {說明賣出成功}
PositionCount:=1;{頭寸計算復原}
SellSign:=False;
dk:=0;
END
IF ENTERPRICE-2*N then
SELL(1,100%,STOP,SELLLLV);{退出離盈利頭寸}
ELSE
SELL(1,100%,STOP,ENTERPRICE-2*N);{退出虧損頭寸}
end;
if dk=-1 then
begin
IF ExitPoint=EntAndExitSign THEN
BEGIN
PositionCount:=1;
SellSign:=False;
dk:=0;
END
IF ENTERPRICE+2*N then
sellSHORT(1,100%,STOP,BUYSHORTHHV);
ELSE
sellSHORT(1,100%,STOP,ENTERPRICE+2*N);
END;
END
?
END;
請老師修改成博易的指標,謝謝
input:trn(20,5,30),hn(20,5,30),ln(10,5,20);VARIABLE:dayCount=1,PositionCount=1,SellSign=0,dK=0;//加多空標志,1:多,-1:空 0:空倉
VARIABLE:EntAndExitSign=1,EntPoint=0,ExitPoint=0;
VARIABLE:N=0;
N:=MA(TR,trn);
BUYHHV:=HHV(H,hn);
SELLLLV:=LLV(L,ln);
sellshortllv:=llv(l,hn);
buyshorthhv:=hhv(h,ln);
IF BARPOS>=hn THEN
BEGIN
IF BARPOS=hn THEN
IF DayCount=hn/2 OR BARPOS=hn THEN
BEGIN{hn/2天調整N值}
N:=((hn-1)*N+TR)/hn;{計算N值}
DayCount:=2;
END
DayCount:=DayCount+1;
EntPoint:=ENTERBARS+1;
IF EntPoint=EntAndExitSign THEN
BEGIN{說明STOP指令買進頭寸成功}
PositionCount:=PositionCount+1;{頭寸計數}
SellSign:=True;{可以平倉信號,如果達到指定的價格}
END
IF PositionCount=1 THEN BEGIN{第一頭寸}
HOW:=CASH(0)*0.01/N;{波動性百分比決定頭寸規模}
if high=buyhhv then
BEGIN
dk:=1;
多開1:BUY(1,HOW,STOP,BUYHHV);{在20日新高STOP指令買進}
END;
if low=sellshortllv then
begin
dk:=-1;
空開1:buyshort(1,HOW,STOP,sellshortllv);{在20日新低STOP指令空開}
end;
END
IF PositionCount=2 THEN BEGIN{如到第二頭寸}
HOW:=CASH(0)*0.01/N;{波動性百分比決定頭寸規模}
if dk=1 then 多開2:BUY(1,HOW,STOP,ENTERPRICE+0.5*N);{在上頭寸(即第一頭寸)+0.5個N以STOP指令買進}
if dk=-1 then 空開2:buyshort(1,HOW,STOP,ENTERPRICE-0.5*N);
END
IF PositionCount=3 THEN BEGIN{如到第三頭寸}
HOW:=CASH(0)*0.01/N;
if dk=1 then 多開3:BUY(1,HOW,STOP,ENTERPRICE+0.5*N);{在上頭寸(即第二頭寸)+0.5個N以STOP指令買進}
if dk=-1 then 空開3:buyshort(1,HOW,STOP,ENTERPRICE-0.5*N);
END
IF PositionCount=4 THEN BEGIN
HOW:=CASH(0)*0.01/N;
if dk=1 then 多開4:BUY(1,HOW,STOP,ENTERPRICE+0.5*N);
if dk=-1 then 空開4:buyshort(1,HOW,STOP,ENTERPRICE-0.5*N);
END
IF SellSign=True THEN
BEGIN
ExitPoint:=EXITBARS+1;
if dk=1 then
begin
IF ExitPoint=EntAndExitSign THEN
BEGIN {說明賣出成功}
PositionCount:=1;{頭寸計算復原}
SellSign:=False;
dk:=0;
END
IF ENTERPRICE-2*N then
SELL(1,100%,STOP,SELLLLV);{退出離盈利頭寸}
ELSE
SELL(1,100%,STOP,ENTERPRICE-2*N);{退出虧損頭寸}
end;
if dk=-1 then
begin
IF ExitPoint=EntAndExitSign THEN
BEGIN
PositionCount:=1;
SellSign:=False;
dk:=0;
END
IF ENTERPRICE+2*N then
sellSHORT(1,100%,STOP,BUYSHORTHHV);
ELSE
sellSHORT(1,100%,STOP,ENTERPRICE+2*N);
END;
END
?
END;
?
?來源:程序化99網( www.tumamayizhan.com )
博易技術人員: 您好,無法修改 來源 程序化久久網
有思路,想編寫各種指標公式,交易模型,選股公式,還原公式的朋友
可聯系技術人員 QQ: 262069696 或微信號:cxh99cxh99 進行 有償收費 編寫!
(注:由于人數限制,QQ或微信請選擇方便的一個聯系我們就行,加好友時請簡單備注下您的需求,否則無法通過。謝謝您!)
相關文章
-
沒有相關內容