以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://222.73.7.161/bbs/index.asp)
--  程序化交易实盘俱乐部  (http://222.73.7.161/bbs/list.asp?boardid=9)
----  创丰1号策略(代码公开)  (http://222.73.7.161/bbs/dispbbs.asp?boardid=9&id=66170)

--  作者:dls0760
--  发布时间:2014/6/16 8:46:12
--  创丰1号策略(代码公开)

 

 

原帖已经被转移至 策略发布区, 讨论请去

http://www.weistock.com/bbs/dispbbs.asp?boardid=10&Id=66189

 

创丰1号代码公开如下:

 

 

abb:=not(islastbar) or (islastbar and tholding2=0);
ma1:ma(c,5);
ma2:ma(c,10);
ma3:ma(c,20);
ma4:ma(c,60);

创丰1号-A:VALUEWHEN(TIME=0916,O),COLORMAGENTA;

DIFF := EMA(CLOSE,12) - EMA(CLOSE,26);
DEA  := EMA(DIFF,9);
MACD1 := 2*(DIFF-DEA), COLORSTICK;

VARIABLE: aspect=0;
VARIABLE: stopprice=0;
VARIABLE: stopnum = 1.6;

RUNMODE:0;  

if barpos = 0 then
  stopprice := l - stopnum;

if aspect = 0 then
begin
 
 if l <= stopprice then
 begin

  aspect:= 1;
  stopprice := h+stopnum;
 end
 

 if l - stopnum > stopprice then
  stopprice := l-stopnum;
end

if aspect = 1 then
begin

 if h >= stopprice then
 begin

  aspect:= 0;
  stopprice := l-stopnum;
 end
 

 if h + stopnum < stopprice then
  stopprice := h+stopnum;
end


RSV:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;
K:=SMA(RSV,3,1);
D:=SMA(K,3,1);
J:=3*K-2*D;

手数:=1;
a1:=k>ref(k,1) and c-ENTERPRICE>=9 ;
a2:=k<ref(k,1) and c-ENTERPRICE<=-9 ;


EMA13:=EMA(C,10),COLORWHITE;
EMA21:=EMA(C,21),COLORYELLOW;
EMA34:=EMA(C,34),COLORFF00FF;
EMA60:=MA(C,55),COLORFFCC66;
X1:=(C+L+H)/3;
X2:=EMA(X1,5);
X3:=EMA(X2,4);

STICKLINE(C>stopprice,LOW,HIGH,0.1,1),COLORRED;
STICKLINE(C>stopprice,CLOSE,OPEN,3,1),COLORRED;
STICKLINE(C<stopprice,LOW,HIGH,0.1,1),COLORFFFF52;
STICKLINE(C<stopprice,CLOSE,OPEN,3,0),COLORFFFF52;

 

BUY1:=(K>REF(K,1)&&D<REF(D,1)&&J>REF(J,1))&&C>stopprice&&time>0915&&time<=1510 and macd1>ref(macd1,1) and  holding<=0 ;
SELL1:=(J<REF(J,1)&&K<REF(K,1)&&D>REF(D,1))&&C<stopprice&&time>0915&&time<=1510 and  macd1<ref(macd1,1) and holding>=0 ;

VARIABLE:DUOKONG=0;
TSFS:=0;
ORDVOL:=1;     {开仓手数}
ZSDS:=8;    

VARIABLE:YDZY=1; 
VARIABLE:HIGHPRICE=0,LOWPRICE=0;
VARIABLE:DHCDS=5,KHCDS=5;
VARIABLE:DYLDS=1,KYLDS=1; 
VARIABLE:Z3B1:=1; 
DUOKONG:=1;

IF HOLDING<0 THEN BEGIN
 IF BUY1 THEN BEGIN  
  空平:SELLSHORT(1,ORDVOL,THISCLOSE),ORDERQUEUE;
 END
 

 IF  a1 THEN BEGIN
  空损:SELLSHORT(1,ORDVOL,THISCLOSE),ORDERQUEUE;
   多1开:BUY(1=1,ORDVOL,THISCLOSE),ORDERQUEUE;
 END
 

 IF YDZY=1 THEN BEGIN

  IF L<LOWPRICE THEN BEGIN
   LOWPRICE:=L;
  END
 

  IF ENTERPRICE-LOWPRICE>=KYLDS and c-ENTERPRICE<=-0.2 THEN BEGIN
   IF L-LOWPRICE>=KHCDS THEN BEGIN 
    空赢:SELLSHORT(1,ORDVOL,THISCLOSE),ORDERQUEUE;
   END
  END
 END
 

 IF Z3B1=1 THEN BEGIN
  IF ENTERPRICE-LOWPRICE>=3 THEN BEGIN
   IF ENTERPRICE-L<=1.2 THEN BEGIN

   END
  END
 END
END

IF HOLDING=0 THEN BEGIN
 IF DUOKONG=1 OR DUOKONG=2 THEN BEGIN
  IF BUY1  and abb  THEN BEGIN
   多开:BUY(1=1,ORDVOL,THISCLOSE),ORDERQUEUE;
   HIGHPRICE:=ENTERPRICE;
  END
 END
END

IF HOLDING>0 THEN BEGIN
 IF SELL1 THEN BEGIN 
  多平:SELL(1,ORDVOL,THISCLOSE),ORDERQUEUE;;
 END
 

 IF a2 THEN BEGIN
  多损:SELL(1,ORDVOL,THISCLOSE),ORDERQUEUE;
     空1开:BUYSHORT(1=1,ORDVOL,THISCLOSE),ORDERQUEUE;
 END

 IF YDZY=1 THEN BEGIN

  IF H>HIGHPRICE THEN BEGIN
   HIGHPRICE:=H;
  END
 

  IF HIGHPRICE-ENTERPRICE>=DYLDS and c-ENTERPRICE>=0.2 THEN BEGIN
   IF HIGHPRICE-H>=DHCDS THEN BEGIN 
    多赢:SELL(1,ORDVOL,THISCLOSE),ORDERQUEUE;
   END
  END
 END
 
 IF Z3B1=1 THEN BEGIN
  IF HIGHPRICE-ENTERPRICE>=3 THEN BEGIN
   IF H-ENTERPRICE<=1.2 THEN BEGIN

   END
  END
 END
END

IF HOLDING=0 THEN BEGIN
 IF DUOKONG=1 OR DUOKONG=3 THEN BEGIN
  IF SELL1  and abb  THEN BEGIN
   空开:BUYSHORT(1=1,ORDVOL,THISCLOSE),ORDERQUEUE;
   LOWPRICE:=ENTERPRICE;
  END
 END
END


  IF time>=1513 THEN BEGIN
  收盘平空:SELLSHORT(1,ORDVOL,THISCLOSE),ORDERQUEUE;
  END

  IF time>=1513 THEN BEGIN
  收盘平多:SELL(1,ORDVOL,THISCLOSE),ORDERQUEUE;
  END


--  作者:redchina888
--  发布时间:2014/6/16 9:24:20
--  
学习
--  作者:dls0760
--  发布时间:2014/6/16 9:57:23
--  
策略采用收盘价设计,包含移动止损/止盈,不含限价/偷价/未来涵数。

图片点击可在新窗口打开查看