欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 为什么不输出maxc

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有3264人关注过本帖平板打印复制链接

主题:为什么不输出maxc

帅哥哟,离线,有人找我吗?
uime
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游民 帖子:114 积分:27 威望:0 精华:0 注册:2013/5/9 7:26:16
  发帖心情 Post By:2015/6/25 11:12:37    Post IP:123.11.84.191[只看该作者]

我把数据换成参数后的代码

//cash现金存量      DYNAINFO( 12) 涨跌  TACCOUNT(19) 当前可用资金  
//当平仓资金权益从最高点回撤大于10%小于20%,开仓比例为本金的1.5%;
// 当平仓资金权益从最高点回撤大于20%小于30%,仓位使用为本金的0.75%;
// 当平仓资金权益从最高点回撤大于30%小于40%,仓位使用为本金的0.4%;
// 正常情况(平仓资金权益从最高点回撤小于10%),开仓比例为本金的3%;

variable:position=0,maxc=cash(0),N=0,myentryprice=0,myexitprice=0;
input:jinru(10,5,100,1),yingli(3,1,10,1),zhisun(15,5,100,2),tuichu(10,5,20,1);
zhis:=zhisun/10;
hi20:ref(hhv(h,jinru),1);
lo20:ref(llv(l,jinru),1);
TR1 := MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
ATR : =MA(TR1,20);


//如果没有持仓,开多仓
IF POSITION=0 AND BARPOS>jinru  THEN BEGIN
N:=atr;
if CASH(0)<MAXC*0.9 and CASH(0)>MAXC*0.8 THEN PosNum:=cash(0)*0.015/n/MULTIPLIER ;
else if
CASH(0)<MAXC*0.8 and CASH(0)>MAXC*0.7 THEN PosNum:=cash(0)*0.0075/N/MULTIPLIER;
else if
CASH(0)<MAXC*0.7 and CASH(0)>MAXC*0.6 THEN PosNum:=cash(0)*0.004/N/MULTIPLIER;
else if
else PosNum:=cash(0)*0.03/N/MULTIPLIER;
posnum:=floor(posnum);
if H>hi20  THEN BEGIN
MYENTRYPRICE := IF(OPEN>hi20+MINDIFF ,OPEN ,hi20+MINDIFF ) ;
//posnum:=intpart (asset*0.02/N/MULTIPLIER);
BUY(cash(0)>(posnum*myentryprice+posnum*zhis*N*MULTIPLIER),POSNUM,LIMITR,MYENTRYPRICE);
POSITION := 1 ;
end
if L<lo20 then BEGIN
MYENTRYPRICE := IF(OPEN<lo20+MINDIFF ,OPEN ,lo20-MINDIFF ) ;
BUYshort(cash(0)>(posnum*myentryprice+posnum*zhis*N*MULTIPLIER),POSNUM,LIMITR,MYENTRYPRICE);
POSITION := -1 ;
end
end




//如果已经开仓,加多仓;
if position>0 and h>myentryprice+yingli*N and (cash(0)-posnum*h-(holding+posnum)*zhis*N*MULTIPLIER)>0 THEN
begin
myentryprice:=if(open>enterprice+yingli*N+mindiff,open,enterprice+yingli*N+mindiff);
buy(1,posnum,limitr,myentryprice);
position:=position+1;
myentryprice:=myentryprice+yingli*N;
end
//如果已经开空仓,加仓;
if position<0 and l<myentryprice-yingli*N and (cash(1)-posnum*h-(abs(holding)+posnum)*zhis*N*MULTIPLIER)>0 THEN
begin
myentryprice:=if(open<enterprice-yingli*N+mindiff,open,enterprice-yingli*N+mindiff);
buyshort(1,posnum,limitr,myentryprice);
position:=position-1;
myentryprice:=myentryprice-yingli*N;
end
//多仓出局
if position>0 and low<enterprice-zhis*N then
begin
MYEXITPRICE := IF(OPEN<MYENTRYPRICE-zhis*N ,OPEN ,MYENTRYPRICE-zhis*N ) ;
MYEXITPRICE := FLOOR(MYEXITPRICE/MINDIFF)*MINDIFF ;
SELL( 1,0,LIMITR,MYEXITPRICE);
POSITION := 0 ;
if maxc<cash(0) then maxc:=cash(0);
END

//空仓止损
if position<0 and high>enterprice+zhis*N then
begin
MYEXITPRICE := IF(OPEN>MYENTRYPRICE+zhis*N ,OPEN ,MYENTRYPRICE+zhis*N ) ;
MYEXITPRICE := ceiling(MYEXITPRICE/MINDIFF)*MINDIFF ;
SELLshort( 1,0,LIMITR,MYEXITPRICE);
POSITION := 0 ;
if maxc<cash(0) then maxc:=cash(0);
END

{pdtimelimit:= position>0 and all(close<myentryprice+3*n,10);
pktimelimit:=position<0 and all(close>myentryprice-3*N,10);

if pdtimelimit and holding>0 then 
begin
sell(pdtimelimit,0,close);
position:=0;
end

if pktimelimit  and holding<0 then
begin
sellshort(pktimelimit,0,close);
position:=0;
end

if position=0 and  maxc<cash(0) then maxc=cash(0);

}
持仓:holding,linethick0;
maxasset:maxc,noaxis;
资产:asset,noaxis;
可用现金:cash(0),linethick0;


 回到顶部
总数 20 1 2 下一页