哪位高人幫忙看一下吧 [金字塔]
- 咨詢內容:
//定義n日平倉;
input:n(3,3,20,1);
//定義單日上漲或下跌百分比;
input:m(3,3,20,0.5);
input:posNum(1,1,20,1);
//變量定義
VARIABLE:position:=0;//倉位狀態,0表示沒有持倉,1表示多頭,-1表示空頭
variable:barCount:=0;//記錄信號出現日是第幾根bar;
variable:lClosePrice:=0;//記錄信號出來前一日收盤價;
variable:closePrice:=0;//記錄信號出來當日收盤價;
llastC:=ref(close,2);//前日收盤價;
lastC:ref(close,1);//昨日收盤價;
myExitPrice:=0;
//如果當前沒有持倉
if(position=0) then begin
//多頭進場條件
long :=((lastC-llastC)/llastC)>0.03;
l0:(lastC-llastC)/llastC,linethick0;
//多頭進場
if long=1 then begin
myEntryPrice:=if(OPEN>lastC+MINDIFF,open,lastC+MINDIFF);//判斷跳空情況
buy(1,posNum,LIMITR,myEntryPrice);
position:=1;
barCount:=BARPOS-1;
lClosePrice:=llastC;//開倉時候記錄開倉前日收盤價;
closePrice:=lastC;
end
end
p1:position,linethick0;
b:barCount,linethick0;
//有多頭倉位的情況,3種情況,止損平倉,定時平倉,持有后移動止損獲利平倉;
if position=1 then BEGIN
//止損平倉
longX1:=low<(closePrice-(closePrice-lClosePrice)*0.65);//價格跌破信號出來時那一天長陽線的65%;
l123:closePrice-(closePrice-lClosePrice)*0.65,linethick0;
if(longX1=1)then BEGIN //無論如何,會進入,不知為何??????????????
myExitPrice:=if(open<closePrice-(closePrice-lClosePrice)*0.65,open,closePrice-(closePrice-lClosePrice)*0.65);
exitP:myExitPrice;
myExitPrice:=floor(myExitPrice/MINDIFF)*MINDIFF; //對齊到最小變動價位;
sell(1,0,limitr,myExitPrice);//作為例子,使用限價指令,在圖上標出;可以使用市價指令;
position:=0;
end//定時平倉
{ longX2:=low<(myEntryPrice-2*N);//myEntryPrice,不是局部變量嗎
if(longX2 and position=1)then BEGIN
myExitPrice:=if(open<myEntryPrice-2*N,open,myEntryPrice-2*N);
myExitPrice:=floor(myExitPrice/MINDIFF)*MINDIFF; //對齊到最小變動價位;
sell(1,0,limitr,myExitPrice);//作為例子,使用限價指令,在圖上標出;可以使用市價指令;
position:=0;
totolUnits:=0;
end}
end
p2:position,linethick0;下面那段平倉的代碼,怎么無論如何都會進入?
- 金字塔客服:
還有,怎么公式調試器不好用啊,好奇怪,是因為免費版嗎
- 用戶回復:
longX2 and position=1
這個平倉條件滿足后才能平倉,使用shift+q的調試功能,進行調試,查看結果是否符合預期
有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友
可聯系技術人員 QQ: 511411198 進行 有償 編寫!(不貴!點擊查看價格!)
相關文章
-
沒有相關內容