我試著編了一個程序,就是改編了海龜,但是不出信號?
作者:金字塔 來源:cxh99.com 發布時間:2015年12月02日
- 咨詢內容:
INPUT:手數(1,1,10000,1);INPUT:止損(50,1,100,1);INPUT:回撤(5,1,10,1);
variable:開倉次數=0;
橫盤高點:=ref(hhv(h,20),1);橫盤低點:=ref(llv(l,20),1);
多頭止損價:=enterprice-止損*mindiff,noaxis;空頭止損價:=enterprice+止損*mindiff,noaxis;開倉后最高:=hhv(h,enterbars+1),noaxis;開倉后最低:=llv(l,enterbars+1),noaxis;開多倉后最高盈利:=開倉后最高-enterprice,noaxis;開空倉后最高盈利:=enterprice-開倉后最低,noaxis;多倉當前盈利:=c-enterprice,noaxis;空倉當前盈利:=enterprice-c,noaxis;
開倉時間:=time>090000 and time<=143000;收盤平倉時間:=time>145500;//進場的條件開多條件:=ref(c,1)>橫盤高點 and todaybar>=30 and 開倉時間 and 開倉次數<=4 and holding=0; 開空條件:=ref(c,1)<橫盤低點 and todaybar>=30 and 開倉時間 and 開倉次數<=4 and holding=0 ;
//止盈平倉if holding>0 and 開多倉后最高盈利>=50*mindiff and 多倉當前盈利<=(回撤/10)*開多倉后最高盈利 and enterbars>0 then begin 止盈平多:sell(1,holding,market); 開倉次數:=開倉次數+1; end;if holding<0 and 開空倉后最高盈利>=50*mindiff and 空倉當前盈利<=(回撤/10)*開空倉后最高盈利 and enterbars>0 then begin 止盈平空:sellshort(1,holding,market); 開倉次數:=開倉次數+1; end
//止損平倉if holding>0 and l<=多頭止損價 then begin 止損平多:sell(1,holding,market); 開倉次數:=開倉次數+1; end; if holding<0 and h>=空頭止損價 then begin 止損平空:sell(1,holding,market); 開倉次數:=開倉次數+1; end; //開倉if 開空條件=1 then begin開空:buyshort(開空條件,手數,limitr,o);開倉次數:=開倉次數+1;end;if 開多條件=1 then begin開多:buy(開多條件,手數,limitr,o);開倉次數:=開倉次數+1;end //收盤平倉if 收盤平倉時間 and holding<>0 then begin 平多:sell(1,holding,limitr,o); 平空:sellshort(1,holding,limitr,o); 開倉次數:=0; end
- 金字塔客服:
說下思路
- 用戶回復:
稍微看了下
橫盤高點:=ref(hhv(h,20),1);
開多條件:=ref(c,1)>橫盤高點
開多條件恒不成立
- 網友回復:
請幫忙重寫一下,應該怎么寫?
- 網友回復:
改成2個周期前就有信號了。
橫盤高點:ref(hhv(h,20),2);
橫盤低點:ref(llv(l,20),2);