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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 总赢利大于2000元或总亏损大于3000元时全部平仓

   

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


  共有7504人关注过本帖树形打印复制链接

主题:总赢利大于2000元或总亏损大于3000元时全部平仓

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


加好友 发短信
等级:小飞侠 帖子:1966 积分:0 威望:0 精华:1 注册:2013/6/15 21:56:35
  发帖心情 Post By:2013/8/26 12:52:31    Post IP:27.227.249.41[显示全部帖子]

搞了这么长时间,还没有搞定。还是我老人家帮帮你吧。用"openprofit"是不对的(用于图表交易)


//股指期货自动交易程序(1分钟日内交易系统)
//编制:
//日期:2012年12月8日 定稿

{
//加密及期限
drawtextex(1,1,200,800,engincode());
rzb:=strcmp(engincode(),'aaaaaaaaaa');
if rzb<>0 then 
begin
drawtextex(1,1,500,500,'程序不能在此计算机上运行');
exit;
end

有效期:1121230,linethick0;
账号:11111,linethick0;
zhh:=strtonum(taccount(1));

if zhh<>账号 then 
begin
drawtextex(1,1,500,500,'授权账号不正确,程序无法使用');
exit;
end
if date>有效期 then
begin
drawtextex(1,1,500,500,'已过授权时间,程序无法使用');
exit;
end
if datatype<>1 then 
begin
drawtextex(1,1,50,950,'本程序使用1分钟周期,请切换到1分钟周期');
exit;
end
}

//========================================================
//交易控制变量
variable:a1=1;

//**********************************
//交易手数:
tn:=1;

//最大持仓量
cx:=1;

//提前下单量(秒)
xd:=3;

//交易时间区间
p1:=time>091500 and time<150000;
p2:=if(islastbar,dynainfo(207),time);
p3:=time0-timetot0(p2),linethick0;

//*******************************
r1:=barslast(date<>ref(date,1));
r2:=ref(o,r1);

//partline(r1>0,r2);

//*******************************
hd:=if(islastbar,8,2.0);
hd1:=if(islastbar,3,0.2);

//********************************
MA1:MA(CLOSE,5);
MA2:MA(CLOSE,25);

//*******************************
r10:=ref(asset,r1+1);
if r10-asset>3000 then a1:=-1;
if asset-r10>2000 then a1:=-1;

if a1<0 and p3<=xd then
begin
sell(1,tn,limitr,c-hd1);
sellshort(1,limitr,c+hd1);
end

//*******************************
if cross(ma1,ma2) and a1>0 and p1 and p3<=xd then
begin
sellshort(holding<0,tn,limitr,c+hd1);
buy(holding=0,tn,limitr,c+hd1);
end

if cross(ma2,ma1) and a1>0 and p1 and p3<=xd then
begin
sell(holding>0,tn,limitr,c-hd1);
buyshort(holding=0,tn,limitr,c-hd1);
end

//*******************************
//收盘前清仓
if p2>=151000 then
begin
sellshort(holding<0,abs(holding),limitr,c+hd1);
sell(holding>0,holding,limitr,c-hd1);
a1:=1;
end
//*************************************
交易总数:totaltrade,colorwhite,linethick0;
盈亏:asset-1000000,colorred,linethick1,noaxis;
日盈亏:asset-ref(asset,r1+1),noaxis,colorred,linethick0;
持仓:holding,colorwhite,linethick0;

rr1:=barslast(month<>ref(month,1));
月盈利:asset-ref(asset,rr1+1),linethick0;


这是一个很好的模板,留着以后用吧!
可以是k线走完,也可以是固定间隔,如果用1秒轮询,就是提前3秒下单;
最后说一句,你的这种思路有问题,怎么能赚2000陪3000出局呢?至少应该调过来吧。供参考!

版主评定:好评,获得5个金币奖励好评,获得5个金币奖励
(理由:好文章)
 回到顶部
帅哥哟,离线,有人找我吗?
qwer123
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1966 积分:0 威望:0 精华:1 注册:2013/6/15 21:56:35
  发帖心情 Post By:2013/8/26 13:20:31    Post IP:27.227.249.41[显示全部帖子]

刚才替你调试了一下,有一个小错误,更正如下:


//股指期货自动交易程序(1分钟日内交易系统)
//编制:
//日期:2012年12月8日 定稿

//=======================================
//交易控制变量
variable:a1=1;

//交易手数:
tn:=1;

//最大持仓量
cx:=1;

//提前下单量(秒)
xd:=3;

//交易时间区间
p1:=time>091500 and time<150000;
p2:=if(islastbar,dynainfo(207),time);
p3:=time0-timetot0(p2),linethick0;

//*******************************
r1:=barslast(date<>ref(date,1));
r2:=ref(o,r1);

//partline(r1>0,r2);

//*******************************
hd:=if(islastbar,8,2.0);
hd1:=if(islastbar,3,0.2);

//********************************
MA1:MA(CLOSE,5);
MA2:MA(CLOSE,25);

//*******************************
r10:=ref(asset,r1+1);
if r10-asset>3000 then a1:=-1;
if asset-r10>2000 then a1:=-1;

if a1<0 and p3<=xd then
begin
sell(1,tn,limitr,c-hd1);
sellshort(1,tn,limitr,c+hd1);
end

//*******************************
if cross(ma1,ma2) and a1>0 and p1 and p3<=xd then
begin
sellshort(holding<0,tn,limitr,c+hd1);
buy(holding=0,tn,limitr,c+hd1);
end

if cross(ma2,ma1) and a1>0 and p1 and p3<=xd then
begin
sell(holding>0,tn,limitr,c-hd1);
buyshort(holding=0,tn,limitr,c-hd1);
end

//********收盘前清仓********
if p2>=151000 then
begin
sellshort(holding<0,abs(holding),limitr,c+hd1);
sell(holding>0,holding,limitr,c-hd1);
a1:=1;
end
//*************************************
交易总数:totaltrade,colorwhite,linethick0;
盈亏:asset-1000000,colorred,linethick1,noaxis;
日盈亏:asset-ref(asset,r1+1),noaxis,colorred,linethick0;
持仓:holding,colorwhite,linethick0;

rr1:=barslast(month<>ref(month,1));
月盈利:asset-ref(asset,rr1+1),linethick0;



 回到顶部
帅哥哟,离线,有人找我吗?
qwer123
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1966 积分:0 威望:0 精华:1 注册:2013/6/15 21:56:35
  发帖心情 Post By:2013/8/26 15:54:26    Post IP:27.227.249.41[显示全部帖子]

p2:=if(islastbar,dynainfo(207),time);//如果是最后一根k线,用行情时间,否则使用time。他们有什么不同看函数说明,或设置语句输出看一下。
p3:=time0-timetot0(p2),linethick0;//计算这根k线结束的时间(秒)

r1:=barslast(date<>ref(date,1));//计算今天的k线位置,相当于todaybars;
r2:=ref(o,r1);//输出第一根k线的开盘价;

//partline(r1>0,r2);//画线指令,自己要看看说明。

//*******************************
hd:=if(islastbar,8,2.0);//如果是最后一根k线hd=8,否则hd=2.0;
hd1:=if(islastbar,3,0.2);//
r10:=ref(asset,r1+1);//开盘时的资金;
if r10-asset>3000 then a1:=-1;//亏损3000时给a1赋值-1;
if asset-r10>2000 then a1:=-1;

你不要这么着急写交易程序,还是静下心来,从头把金字塔好好理解一下。

 回到顶部
帅哥哟,离线,有人找我吗?
qwer123
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1966 积分:0 威望:0 精华:1 注册:2013/6/15 21:56:35
  发帖心情 Post By:2013/8/26 15:59:19    Post IP:27.227.249.41[显示全部帖子]


 回到顶部
帅哥哟,离线,有人找我吗?
qwer123
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1966 积分:0 威望:0 精华:1 注册:2013/6/15 21:56:35
  发帖心情 Post By:2013/8/26 18:47:01    Post IP:27.227.249.41[显示全部帖子]

这要看你的策略了,最大持仓量,是用于加载策略的。tn你可以随便改,是一下就知道了。

 回到顶部