以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  交易策略发布专区  (http://weistock.com/bbs/list.asp?boardid=10)
----  [交易系统]恒温器策略  (http://weistock.com/bbs/dispbbs.asp?boardid=10&id=8276)

--  作者:z7c9
--  发布时间:2011/10/3 11:17:12
--  [交易系统]恒温器策略

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

 

runmode:0;

input:bollingerlengths(50);
input:trendliqlength(50);
input:numstddevs(2);
input:swingprcnt1(0.5);
input:swingprcnt2(0.75);
input:atrlength(10);
input:swingtrendswitch(20);

variable:swing=false;

cmival:=abs(close-ref(close,30))/(hhv(high,30),1)-llv(low,30);

buyeasierday:=0;
selleasierday:=0;

trendlokbuy:=ma(low,3);
trendloksell:=ma(high,3);

keyofday:=(high+low+close)/3;

if close>keyofday then
 selleasierday:=1;
else
 buyeasierday:=1;
 
atr:=ma(tr,atrlength); 

if ref(buyeasierday,1)=1 then begin
 swingbuypt:=open+swingprcnt1*atr;
 swingsellpt:=open-swingprcnt2*atr;
end 

if ref(selleasierday,1)=1 then begin
 swingbuypt:=open+swingprcnt2*atr;
 swingsellpt:=open-swingprcnt1*atr;
end

swingbuypt:=max(swingbuypt,trendlokbuy);
swingsellpt:=min(swingsellpt,trendloksell);

ma1:=ma(close,trendliqlength);

mid:=ma(close,bollingerlengths);
trendbuypt:=mid+numstddevs*std(close,bollingerlengths);
trendsellpt:=mid-numstddevs*std(close,bollingerlengths);

if cmival<swingtrendswitch then begin
 if holding=0 then begin
  if high>=swingbuypt then begin
   buy(1,1,limitr,max(open,swingbuypt));
   swing:=true;
  end 
 end 
 
 if holding=0 then begin
  if low<=swingsellpt then begin
   buyshort(1,1,limitr,min(open,swingsellpt));
   swing:=true;
  end 
 end
 
 if holding>0 then begin
  if low<=swingsellpt then begin
   sell(1,holding,limitr,min(open,swingsellpt));
   buyshort(1,1,limitr,min(open,swingsellpt));
   swing:=true;
  end
 end
 
 if holding<0 then begin
  if high>=swingbuypt then begin
   sellshort(1,holding,limitr,max(open,swingbuypt));
   buy(1,1,limitr,max(open,swingbuypt));
   swing:=true;
  end
 end
end else begin
 swingprotstop:=3*atr;
 
 if holding=0 then begin
  if high>=trendbuypt then begin
   buy(1,1,limitr,max(open,trendbuypt));
   swing:=false;
  end 
 end
 
 if holding=0 then begin
  if low<=trendsellpt then begin
   buyshort(1,1,limitr,min(open,trendsellpt));
   swing:=false;
  end 
 end
 
 if holding>0 then begin
  if swing then begin
   if low<=enterprice-swingprotstop then
    sell(1,holding,limitr,min(open,enterprice-swingprotstop));
  end else begin
   if low<=ma1 then
    sell(1,holding,limitr,min(open,ma1));
  end
 end
 
 if holding<0 then begin
  if swing then begin
   if high>=enterprice+swingprotstop then
    sellshort(1,holding,limitr,max(open,enterprice+swingprotstop));
  end else begin
   if high>=ma1 then
    sellshort(1,holding,limitr,max(open,ma1));
  end 
 end
end

盈亏:asset-50000,noaxis,colorred,linethick2;


--  作者:jonathan
--  发布时间:2016/12/26 14:48:49
--  
最后一句话 -50000 是什么意思?
--  作者:hojiawork
--  发布时间:2017/9/5 16:03:55
--  
渣渣策略,连偷价之后还是渣渣,随便个15行以内的策略公式都比这强N倍。