以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://www.weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://www.weistock.com/bbs/list.asp?boardid=4) ---- 改进型海龟 (http://www.weistock.com/bbs/dispbbs.asp?boardid=4&id=55033) |
||||
-- 作者:武田晴信 -- 发布时间:2013/8/13 8:56:01 -- 改进型海龟 自己写了个加50日线的海龟,好像不对劲,高手能看下吗。我说下思路哈,就是把原来的两个海龟合并,不要买空的那部分,去掉最下面下面的那根K线。你们能看下这样写行吗?谢谢,我是新人,希望多多指导: //开始编写属于您自己的交易指标吧!GO! //该模型为简单示范模型,用户需根据自己交易经验,修改完善后再实际应用!!! //author: fjasmin input: t20(20,15,60,1);//参数名,缺省值,最小值,最大值,步长 input: t50(50,20,60,1); input: t10(10,10,30,1); input: atrlen(20,15,30,1); input: posnum(1,1,20,1); //声明变量 nt:=1;//调试信息带有时间戳 buyorderthisbar:=0;//当前BAR有过交易 variable: _debug = 1; //是否输出前台的交易指令 variable: _tdebug = 1;
//是否输出后台的交易指令 variable: _debugout = 0; //是否输出后台交易的调试信息 variable: myentryprice = 0;//开仓价格 variable: myxitprice = 0;//平仓价格 variable: turtleunits = 0;//交易单位 variable: position = 0;//仓位状态 //0表示没有仓位,1表示持有多头,-1表示持有空头 variable: t50hi=close; variable: t50lo=close; variable: t20hi=close; variable: t20lo=close; variable: t10hi=close; variable: t10lo=close; //需要准备计算的变量 t50hi=:ref(hhv(h,t50),1); t50lo=:ref(llv(h,t50),1); t20hi=:ref(hhv(h,t20),1);// t20lo=:ref(llv(h,t20),1);// t10hi=:ref(hhv(h,t10),1); t10lo=:ref(llv(h,t10),1); avgtr:=ref(ma(tr,atrlen),1); //开始执行时,初始化数据 if barpos = 1 then begin //position : = 0; end //IFN //如果是当时没有持仓的状态 if position=0 and barpos > t20 and h>l then begin
//建立多头进场条件
long:=h>t20hi;
//多头进场
if long then begin
myentryprice:=if (open>t20hi+mindiff,open,t20hi+mindiff);
buy(_debug,posnum,limitr,myentryprice);
position:=1;
turtleunits:=1;
n:=avgtr;
buyorderthisbar:=1;
end//IF
//建立空头进场条件
short:=l<t50lo;
//空头进场
if short and position = 0 then begin
myentryprice:=if(open<t20lo-mindiff,open,t20lo-mindiff);
buyshort(_debug,posnum,limitr,myentryprice);
position:=-1;
turtleunits:=1;
n:=avgtr;
buyorderthisnbar:=1;
end
//不要转跳,让程序检查同一根K线是否可以加仓
//goto continueline;
//如果当前持有多头仓位的状态
if position=1 and barpos>t20 and h>l then begin
//多头加仓条件
while (high>myentryprice+0.5*n) and turtleunits < 4 do begin
myentryprice:=if(open>myentryprice+0.5*n,open,myentryprice+0.5*n);
myentryprice:=ceiling(myentryprice/mindiff)*mindiff;
buy(_debug,posnum,limitr,myentryprice);
turtleunits:=turtleunits+1;
buyorderthisbar:=1;
end//while循环结束
//建立多头离场条件
longx1:=(low<t10lo);
if longx1 and buyorderthisbar=0 then begin
myexitprice:=if(open<t10lo-mindiff,open,t10lo-mindiff);
sell(_debug,0,limitr,myexitprice);
position:=0;
turtleunits:=0;
end
//建立多头止损条件
longx2 := (low<myentryprice-2*n);
if longx2 and position = 1 and buyorderthisbar=0 then begin
myexitprice:=if(open<myentryprice-2*n,open,myentryprice-2*n);
myexitprice:=floor(myexitprice/mindiff)*mindiff;
sell(_debug,0,limitr,myexitprice);
position:=0;
turtleunits:=0;
end
goto continueline; end //if //如果当前持有空头仓位的状态 //显示账号信息: continueline@ mycount:asset,linethick0;//显示我的资产 available_cash:cash(0),linethick0;//可用现金 pos:holding,linethick0; toaldaytrade1:totaldaytrade,linethick0;//总交易次数 if _debugout>0 then begin
debugfile2(\'c:debugfile.txt\',\'barpos=%.of\',barpos,nt);
debugfile2(\'c:debugfile.txt\',\'t20hi=%.2f\',t20hi,nt);
debugfile2(\'c:debugfile.txt\',\'n=%.2f\',n,nt);
debugfile2(\'c:debugfile.txt\',\'close=%.2f\',c,nt);
debugfile2(\'c:debugfile.txt\',\'position=%.2f\',position,nt);
debugfile2(\'c:debugfile.txt\',\'turtleunits=%.of\',turtleunits,nt);
debugfile2(\'c:debugfile.txt\',\'myentryprice=%.of\',myentryprice,nt);
debugfile2(\'c:debugfile.txt\',\'myexitprice=%.of\',myexitprice,nt); end the current position:holding,colorgray,linethick0;//当前持仓 the current captal:asset,noaxis,colorgray;//当前资产
//多头加仓条件 { KD:=; //开多条件 PD:=; //平多条件 KK:=; //开空条件 PK:=; //平空条件 平空:SELLSHORT(PK,1,THISCLOSE); //平空信号 开多:BUY(KD AND HOLDING=0,1,THISCLOSE); //开多信号 平多:SELL(PD,1,THISCLOSE); //平多信号 开空:BUYSHORT(KK AND HOLDING=0,1,THISCLOSE); //开空信号 } { 信号语句排列规则——先平后开 “费率设置”按钮——用于合理设置模型“费率”,以便在图形上正确输出如下帐户信息: 持仓:holding,linethick0; 资产:asset,noaxis; 可用现金:cash(0),linethick0; } |
||||
-- 作者:武田晴信 -- 发布时间:2013/8/13 8:56:57 -- 就是改了一下海龟的交易法则,但是目前对海龟还是不怎么熟悉,所以就只能写成这个样子 |
||||
-- 作者:武田晴信 -- 发布时间:2013/8/13 8:57:48 -- 我直接上传txt文档上来吧
|
||||
-- 作者:武田晴信 -- 发布时间:2013/8/13 9:04:49 -- 这个题目木有违规吧,如果有的话,吧主通知我一下、 |
||||
-- 作者:武田晴信 -- 发布时间:2013/8/13 9:26:23 -- 目测木有人看。。。。。。。。。。。。。。。 |
||||
-- 作者:武田晴信 -- 发布时间:2013/8/13 10:08:46 -- 我自己去顶一哈 |
||||
-- 作者:fly -- 发布时间:2013/8/13 10:09:00 -- 改进一个成名的策略,问题有点难度,要有专门研究的人才可以帮助到您
您改进了哪个地方,或者说说您的思路? |
||||
-- 作者:jieni -- 发布时间:2013/8/19 8:30:49 -- 怎么不发个测试图 |
||||
-- 作者:cswave -- 发布时间:2014/4/3 22:39:18 -- 顶一下。 |