帮我看下我编写的东西好吗为什么出现句末木有分号 [金字塔]
- 咨询内容:
刚刚用金字塔格式的传上去不能正常显示,这个是TXT文档的类型 下载信息 [文件大小: 下载次数: ]点击浏览该文件:123.txt
- 金字塔客服:
以前说程序不能直接复制到回复区,现在就放在TXT文档中
- 用户回复:
已经出现了好几次这种情况了。有点郁闷
- 网友回复:
//开始编写属于您自己的交易指标吧!GO!//该模型为简单示范模型,用户需根据自己交易经验,修改完善后再实际应用!!!
//author: fjasmine
input: t20(20,15,60,1);//参数名,缺省值,最小值,最大值,步长
input: t10(10,10,30,1);input: atrlen(20,15,30,1);
input: posnum(1,1,20,1);
variable:daycount=1,positioncount=1,sellsign=0;//定义了三个常数变量,分别赋值
variable:entandexitsign=1,entpoint=0,exitpoint=0;//定义了三个常数变量,分别赋值
variable:n=0;//定义常数变量N,初始化值为0
ma1:ma(c,5);//输出五日均价ma2:ma(c,10);//输出十日均价
m:=ma(tr,20);//输出20日均价
buyhhv:=hhv(h,20);//20日最高价
sellllv:=llv(l,10);//20日最低价
ss:n,linethick0;
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: t20hi=close;
variable: t20lo=close;
variable: t10hi=close;
variable: t10lo=close;
//需要准备计算的变量
t20hi=:ref(hhv(h,t20),1);//
t20lp=: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//if
//如果是当时没有持仓的状态
if position=0 and barpos > t20 andh>l then begin
//建立多头进场条件
long:=h>t20hi;
//多头进场
iflong 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<t20lo;
//空头进场
ifshort and position=0 then begin
myentryprice:=if(open<t20lo-mindiff,open,t20lo-mindiff);
buyshort(_debug,posnum,limitr,myentryprice);
position:=-1;
turtleunits:=1;
n:=avgtr;
buyorderthisbar:=1;
end
//不要转跳,让程序检查同一根K线是否可以加仓
//gotocontinueline;
end//if
//如果当前持有多头仓位的状态
ifposition=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);
iflongx1 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);
iflongx2 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
if barpos >= 21 or barpos=21 then begin//如果从上市到交易日大于21天那么
if barpos =21 then//如果从上市到现在加以日等于21,那么
n:=m;//n=m
if daycount =6 or barpos = 21 then begin//五天调整N值
n:=(19*n+tr)/20;//计算N的值
daycount:=2;
end
daycount:=daycount+1;
entpoint:=enterbars+1;
if entpoint=entandexitsign then begin//说明stop指令买进头寸成功
positioncount:=positioncount+1;//头寸计数
sellsign:=true;//开始以stop卖出,如果达到指定的价格
end
if positioncount=1 then begin//第一头寸
how:=cash(0)*0.01/n;//波动性百分比决定头寸规模
open1:buy(h>=enterprice+0.5*n,how,market);//在20日新高stop指令买进
end
if positioncount = 2 then begin//第二头寸
how:=cash(0)*0.01/n;//波动性百分比决定头寸规模
open2:buy(h>enterprice+0.5*n,how,market);//在上头寸(即第一头寸)+0.5个N新高stop指令买进
end
if positioncount=3 then begin//第三头寸
how:=cash(0)*0.01/n;//波动性百分比决定头寸规模
open3:buy(h>=enterprice+0.5*n,how,market);//在上头寸(即第二头寸)+0.5个N新高stop指令买进
end
if positioncount = 4 then begin //第四头寸
how:=cash(0)*0.01/n;//波动性百分比决定头寸规模
open4:buy(h>=enterprice+0.5*n,how,market); //在上头寸(即第三头寸)+0.5个N新高stop指令买进
end
if sellsign = true then begin
exitpoint:=exitbars+1;
ifexitpoint = entandexitsign then begin //说明卖出成功
positioncount:=1;{头寸计算复原}
sellsign:=false;
end
ifenterprice-2*n then sell(l<sellllv,100%,market);{退出亏损头寸}
else
sell(l<enterprice-2*n,100%,market);
end
end
//显示账号信息: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 currentposition:holding,colorgray,linethick0;//当前持仓the currentcaptal:asset,noaxis,colorgray;//当前资产
改好了,但是你这个很多变量后面少了空格是什么情况?
[此贴子已经被作者于2013/7/30 9:31:14编辑过] - 网友回复:
以下是引用jinzhe在2013/7/30 9:30:41的发言:
//开始编写属于您自己的交易指标吧!GO!//该模型为简单示范模型,用户需根据自己交易经验,修改完善后再实际应用!!!
//author: fjasmine
input: t20(20,15,60,1);//参数名,缺省值,最小值,最大值,步长
input: t10(10,10,30,1);input: atrlen(20,15,30,1);
input: posnum(1,1,20,1);
variable:daycount=1,positioncount=1,sellsign=0;//定义了三个常数变量,分别赋值
variable:entandexitsign=1,entpoint=0,exitpoint=0;//定义了三个常数变量,分别赋值
variable:n=0;//定义常数变量N,初始化值为0
ma1:ma(c,5);//输出五日均价ma2:ma(c,10);//输出十日均价
m:=ma(tr,20);//输出20日均价
buyhhv:=hhv(h,20);//20日最高价
sellllv:=llv(l,10);//20日最低价
ss:n,linethick0;
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: t20hi=close;
variable: t20lo=close;
variable: t10hi=close;
variable: t10lo=close;
//需要准备计算的变量
t20hi=:ref(hhv(h,t20),1);//
t20lp=: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//if
//如果是当时没有持仓的状态
if position=0 and barpos > t20 andh>l then begin
//建立多头进场条件
long:=h>t20hi;
//多头进场
iflong 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<t20lo;
//空头进场
ifshort and position=0 then begin
myentryprice:=if(open<t20lo-mindiff,open,t20lo-mindiff);
buyshort(_debug,posnum,limitr,myentryprice);
position:=-1;
turtleunits:=1;
n:=avgtr;
buyorderthisbar:=1;
end
//不要转跳,让程序检查同一根K线是否可以加仓
//gotocontinueline;
end//if
//如果当前持有多头仓位的状态
ifposition=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);
iflongx1 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);
iflongx2 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
if barpos >= 21 or barpos=21 then begin//如果从上市到交易日大于21天那么
if barpos =21 then//如果从上市到现在加以日等于21,那么
n:=m;//n=m
if daycount =6 or barpos = 21 then begin//五天调整N值
n:=(19*n+tr)/20;//计算N的值
daycount:=2;
end
daycount:=daycount+1;
entpoint:=enterbars+1;
if entpoint=entandexitsign then begin//说明stop指令买进头寸成功
positioncount:=positioncount+1;//头寸计数
sellsign:=true;//开始以stop卖出,如果达到指定的价格
end
if positioncount=1 then begin//第一头寸
how:=cash(0)*0.01/n;//波动性百分比决定头寸规模
open1:buy(h>=enterprice+0.5*n,how,market);//在20日新高stop指令买进
end
if positioncount = 2 then begin//第二头寸
how:=cash(0)*0.01/n;//波动性百分比决定头寸规模
open2:buy(h>enterprice+0.5*n,how,market);//在上头寸(即第一头寸)+0.5个N新高stop指令买进
end
if positioncount=3 then begin//第三头寸
how:=cash(0)*0.01/n;//波动性百分比决定头寸规模
open3:buy(h>=enterprice+0.5*n,how,market);//在上头寸(即第二头寸)+0.5个N新高stop指令买进
end
if positioncount = 4 then begin //第四头寸
how:=cash(0)*0.01/n;//波动性百分比决定头寸规模
open4:buy(h>=enterprice+0.5*n,how,market); //在上头寸(即第三头寸)+0.5个N新高stop指令买进
end
if sellsign = true then begin
exitpoint:=exitbars+1;
ifexitpoint = entandexitsign then begin //说明卖出成功
positioncount:=1;{头寸计算复原}
sellsign:=false;
end
ifenterprice-2*n then sell(l<sellllv,100%,market);{退出亏损头寸}
else
sell(l<enterprice-2*n,100%,market);
end
end
//显示账号信息: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 currentposition:holding,colorgray,linethick0;//当前持仓the currentcaptal:asset,noaxis,colorgray;//当前资产
此主题相关图片如下:8$n0{ih0v12k2gdd557psg.jpg改好了,但是你这个很多变量后面少了空格是什么情况?
刚刚用你改好的:
[此贴子已经被作者于2013/7/30 9:31:14编辑过]
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 511411198 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容