===============================================//中間變量gapprice:=gap*fprice;//一跳多少錢 variable:markprice=fprice;//發生交易時的參考價格 disp:=(gapn-0.1)*gapprice;//定義波動極限,upp和downp的范圍之內是能進行增減交易,最邊緣的交易將導致超出范圍upp:fprice+disp;downp:fprice-disp; refpm:ref(markprice,1),CIRCLEDOT; //執行 if barpos=1 then buy(1,10000,market); if date()>daterun+1000000 then begin if c>=refpm+gapprice and c<upp then begin sell (1,stockgap,market,refpm+gapprice); markprice:=refpm+gapprice; GOTO QUITLINE; end end QUITLINE@ ee:markprice,CROSSDOT; EXIT; ====================================設計思路是,當價格高于markprice一個gapprice時賣出一次,同時markprice要加上一個gapprice。主要的問題是,refpm并沒有完全被賦值為前一天的markprice,而是在發生變化時推遲了一天,于是價格突破某個界限時的交易變成了連續兩天交易。猜測可能是在判斷語句里對markprice重新賦值造成的,但不知道該怎么處理。如圖,refpm是圓圈線,ee:markprice是X線,應該兩者只差一個周期,但是在發生交易的位置,卻并非如此。
金字塔客服:
if c>=refpm+gapprice and c<upp then begin
這里加一個holding>0的條件,也就是:
if c>=refpm+gapprice and c<upp and holding>0 then begin
網友回復:
if c>=markprice+gapprice and c<upp then begin
sell (1,stockgap,limitr,refpm+gapprice),ignorecheckprice; markprice:=markprice+gapprice; GOTO QUITLINE; end