金字塔决策交易系统

 找回密码
 

微信登录

微信扫一扫,快速登录

搜索
楼主: 100020509

请老师帮忙加一下开平仓

[复制链接]

35

主题

175

帖子

175

积分

Rank: 2

等级: 标准版

注册:
2023-10-17
曾用名:
 楼主| 发表于 2024-7-26 22:11 | 显示全部楼层
老师好,我们电话联系修改后我又做了一些回测,还是出现反手的问题,当根k线开仓当根就反手了,来回几次,请看截图。
[attachimg]26394[/attachimg

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号? 微信登录

x
回复

使用道具 举报

44

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
发表于 2024-7-29 09:01 | 显示全部楼层
if 平仓反手 and (exitbars>0 or exitbars=-1) then
begin
       
END

你平仓反手的条件加上一个and (exitbars>0 or exitbars=-1),表示平仓历史大于0不是当根平仓
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

35

主题

175

帖子

175

积分

Rank: 2

等级: 标准版

注册:
2023-10-17
曾用名:
 楼主| 发表于 2024-7-29 11:38 | 显示全部楼层
您好,老师,还是一样的情况,很多反手都是当根开仓就反手了。
回复

使用道具 举报

44

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
发表于 2024-7-29 13:25 | 显示全部楼层
完整代码给下
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

44

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
发表于 2024-7-29 13:25 | 显示全部楼层
完整代码给下
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

35

主题

175

帖子

175

积分

Rank: 2

等级: 标准版

注册:
2023-10-17
曾用名:
 楼主| 发表于 2024-7-29 13:32 | 显示全部楼层
[PEL] 复制代码
vv:=100;
 
sth:=ref(h,2)>ref(h,3)&&ref(h,2)>=ref(h,1)&&ref(h,2)>=h;
stl:=ref(l,2)<ref(l,3)&&ref(l,2)<=ref(l,1)&&ref(l,2)<=l;
 
kk:=hhv(h,todaybar)>ref(max(c,valuewhen(todaybar=1,o)),todaybar)&&exist(stl,todaybar)&&exist(sth,todaybar)&&valuewhen(stl,ref(l,2)<ref(valuewhen(stl,ref(l,2)),1))&&c>valuewhen(sth,ref(h,2));//max bk
dd:=llv(l,todaybar)<ref(min(c,valuewhen(todaybar=1,o)),todaybar)&&exist(stl,todaybar)&&exist(sth,todaybar)&&valuewhen(sth,ref(h,2)>ref(valuewhen(sth,ref(h,2)),1))&&c<valuewhen(stl,ref(l,2));//min sk
kkx:=hhv(h,todaybar)>ref(max(c,valuewhen(todaybar=1,o)),todaybar)&&exist(stl,todaybar)&&exist(sth,todaybar)&&sth&&valuewhen(stl,ref(l,2)<ref(valuewhen(stl,ref(l,2)),1))&&c>ref(valuewhen(sth,ref(h,2)),1);//max bk
ddx:=llv(l,todaybar)<ref(min(c,valuewhen(todaybar=1,o)),todaybar)&&exist(stl,todaybar)&&exist(sth,todaybar)&&stl&&valuewhen(sth,ref(h,2)>ref(valuewhen(sth,ref(h,2)),1))&&c<ref(valuewhen(stl,ref(l,2)),1);//min sk

//kkp:=c<valuewhen(kk||kkx,valuewhen(stl,ref(l,2)))-mindiff&&count(c<valuewhen(kk||kkx,valuewhen(stl,ref(l,2)))-mindiff,barslast(kk||kkx))=1;
//ddp:=c>valuewhen(dd||ddx,valuewhen(sth,ref(h,2)))+mindiff&&count(c>valuewhen(dd||ddx,valuewhen(sth,ref(h,2)))+mindiff,barslast(dd||ddx))=1;

kkp:=c<ref(valuewhen(stl,c),typebar(1,1))-1*mindiff;
ddp:=c>ref(valuewhen(sth,c),typebar(1,3))+1*mindiff; 

kd:=kk or kkx;//开多条件
pd:=kkp;    //平多反手
mk:=dd or ddx;//开空条件
pk:=ddp;    //平空反手
 
tcon:=time>130000 and time<=185500;//时间大于北京时间9点(金字塔时间130000),小于145500(金字塔时间185500)
 
//有空头时候才触发反手
if pk and holding<0 and (exitbars>0 or exitbars=-1) then
begin
sellshort(1,holding,market);
buy(tcon,vv,market);  
end
 
buy(kd and holding=0 and tcon,vv,market);                        //开多信号
 
//有多头时候才触发反手
if pd and holding>0 and (exitbars>0 or exitbars=-1) then
begin
sell(1,holding,market);    
buyshort(tcon,vv,market);      
end
 
buyshort(mk and holding=0 and tcon,vv,market);                   //开空信号
 

 
//止损 
zsd:=sell(c<avgenterprice-20*mindiff,holding,market);
zsk:=sellshort(c>avgenterprice+20*mindiff,holding,market);
 

//止盈 
h1:=hhv(h,enterbars+1);//开仓后最高价
l1:=llv(l,enterbars+1);
 
maxprofit:=if(holding>0,h1-avgenterprice,avgenterprice-l1);//开仓后最大盈利(价差)
currentprofit:=if(holding>0,c-avgenterprice,avgenterprice-c);//当前浮动盈亏(价差)
 
if maxprofit>=15*mindiff and  currentprofit<maxprofit*1 and enterbars>=0 then
begin
zyd:=sell(1,holding,market);
zyk:=sellshort(1,holding,market);        
end
 

//清仓 
tq:=60*5;//提前的秒数
abb:=remainingtime(closetime(0))<=tq;
if abb then begin
qcd:=sell(1,holding,market);
qck:=sellshort(1,holding,market);     
end
回复

使用道具 举报

44

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
发表于 2024-7-29 14:24 | 显示全部楼层
vv:=100;
  
sth:=ref(h,2)>ref(h,3)&&ref(h,2)>=ref(h,1)&&ref(h,2)>=h;
stl:=ref(l,2)<ref(l,3)&&ref(l,2)<=ref(l,1)&&ref(l,2)<=l;
  
kk:=hhv(h,todaybar)>ref(max(c,valuewhen(todaybar=1,o)),todaybar)&&exist(stl,todaybar)&&exist(sth,todaybar)&&valuewhen(stl,ref(l,2)<ref(valuewhen(stl,ref(l,2)),1))&&c>valuewhen(sth,ref(h,2));//max bk
dd:=llv(l,todaybar)<ref(min(c,valuewhen(todaybar=1,o)),todaybar)&&exist(stl,todaybar)&&exist(sth,todaybar)&&valuewhen(sth,ref(h,2)>ref(valuewhen(sth,ref(h,2)),1))&&c<valuewhen(stl,ref(l,2));//min sk
kkx:=hhv(h,todaybar)>ref(max(c,valuewhen(todaybar=1,o)),todaybar)&&exist(stl,todaybar)&&exist(sth,todaybar)&&sth&&valuewhen(stl,ref(l,2)<ref(valuewhen(stl,ref(l,2)),1))&&c>ref(valuewhen(sth,ref(h,2)),1);//max bk
ddx:=llv(l,todaybar)<ref(min(c,valuewhen(todaybar=1,o)),todaybar)&&exist(stl,todaybar)&&exist(sth,todaybar)&&stl&&valuewhen(sth,ref(h,2)>ref(valuewhen(sth,ref(h,2)),1))&&c<ref(valuewhen(stl,ref(l,2)),1);//min sk

//kkp:=c<valuewhen(kk||kkx,valuewhen(stl,ref(l,2)))-mindiff&&count(c<valuewhen(kk||kkx,valuewhen(stl,ref(l,2)))-mindiff,barslast(kk||kkx))=1;
//ddp:=c>valuewhen(dd||ddx,valuewhen(sth,ref(h,2)))+mindiff&&count(c>valuewhen(dd||ddx,valuewhen(sth,ref(h,2)))+mindiff,barslast(dd||ddx))=1;

kkp:=c<ref(valuewhen(stl,c),typebar(1,1))-1*mindiff;
ddp:=c>ref(valuewhen(sth,c),typebar(1,3))+1*mindiff;

kd:=kk or kkx;//开多条件
pd:=kkp;    //平多反手
mk:=dd or ddx;//开空条件
pk:=ddp;    //平空反手
  
tcon:=time>130000 and time<=185500;//时间大于北京时间9点(金字塔时间130000),小于145500(金字塔时间185500)
  
//有空头时候才触发反手
if pk and holding<0  then
begin
sellshort(1,holding,market);
buy(tcon and (exitbars>0 or exitbars=-1),vv,market);  
end
  
buy(kd and holding=0 and tcon,vv,market);                        //开多信号
  
//有多头时候才触发反手
if pd and holding>0  then
begin
sell(1,holding,market);   
buyshort(tcon and (exitbars>0 or exitbars=-1),vv,market);      
end
  
buyshort(mk and holding=0 and tcon,vv,market);                   //开空信号
  

  
//止损
zsd:=sell(c<avgenterprice-20*mindiff,holding,market);
zsk:=sellshort(c>avgenterprice+20*mindiff,holding,market);
  

//止盈
h1:=hhv(h,enterbars+1);//开仓后最高价
l1:=llv(l,enterbars+1);
  
maxprofit:=if(holding>0,h1-avgenterprice,avgenterprice-l1);//开仓后最大盈利(价差)
currentprofit:=if(holding>0,c-avgenterprice,avgenterprice-c);//当前浮动盈亏(价差)
  
if maxprofit>=15*mindiff and  currentprofit<maxprofit*1 and enterbars>=0 then
begin
zyd:=sell(1,holding,market);
zyk:=sellshort(1,holding,market);        
end
  

//清仓
tq:=60*5;//提前的秒数
abb:=remainingtime(closetime(0))<=tq;
if abb then begin
qcd:=sell(1,holding,market);
qck:=sellshort(1,holding,market);     
end
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

35

主题

175

帖子

175

积分

Rank: 2

等级: 标准版

注册:
2023-10-17
曾用名:
 楼主| 发表于 2024-7-29 14:29 | 显示全部楼层
老师,还是这样,没变化。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号? 微信登录

x
回复

使用道具 举报

44

主题

1万

帖子

1万

积分

Rank: 8Rank: 8

等级: 超级版主

注册:
2021-5-18
曾用名:
发表于 2024-7-29 14:41 | 显示全部楼层
vv:=100;
  
sth:=ref(h,2)>ref(h,3)&&ref(h,2)>=ref(h,1)&&ref(h,2)>=h;
stl:=ref(l,2)<ref(l,3)&&ref(l,2)<=ref(l,1)&&ref(l,2)<=l;
  
kk:=hhv(h,todaybar)>ref(max(c,valuewhen(todaybar=1,o)),todaybar)&&exist(stl,todaybar)&&exist(sth,todaybar)&&valuewhen(stl,ref(l,2)<ref(valuewhen(stl,ref(l,2)),1))&&c>valuewhen(sth,ref(h,2));//max bk
dd:=llv(l,todaybar)<ref(min(c,valuewhen(todaybar=1,o)),todaybar)&&exist(stl,todaybar)&&exist(sth,todaybar)&&valuewhen(sth,ref(h,2)>ref(valuewhen(sth,ref(h,2)),1))&&c<valuewhen(stl,ref(l,2));//min sk
kkx:=hhv(h,todaybar)>ref(max(c,valuewhen(todaybar=1,o)),todaybar)&&exist(stl,todaybar)&&exist(sth,todaybar)&&sth&&valuewhen(stl,ref(l,2)<ref(valuewhen(stl,ref(l,2)),1))&&c>ref(valuewhen(sth,ref(h,2)),1);//max bk
ddx:=llv(l,todaybar)<ref(min(c,valuewhen(todaybar=1,o)),todaybar)&&exist(stl,todaybar)&&exist(sth,todaybar)&&stl&&valuewhen(sth,ref(h,2)>ref(valuewhen(sth,ref(h,2)),1))&&c<ref(valuewhen(stl,ref(l,2)),1);//min sk

//kkp:=c<valuewhen(kk||kkx,valuewhen(stl,ref(l,2)))-mindiff&&count(c<valuewhen(kk||kkx,valuewhen(stl,ref(l,2)))-mindiff,barslast(kk||kkx))=1;
//ddp:=c>valuewhen(dd||ddx,valuewhen(sth,ref(h,2)))+mindiff&&count(c>valuewhen(dd||ddx,valuewhen(sth,ref(h,2)))+mindiff,barslast(dd||ddx))=1;

kkp:=c<ref(valuewhen(stl,c),typebar(1,1))-1*mindiff;
ddp:=c>ref(valuewhen(sth,c),typebar(1,3))+1*mindiff;

kd:=kk or kkx;//开多条件
pd:=kkp;    //平多反手
mk:=dd or ddx;//开空条件
pk:=ddp;    //平空反手
  
tcon:=time>130000 and time<=185500;//时间大于北京时间9点(金字塔时间130000),小于145500(金字塔时间185500)
  
//有空头时候才触发反手
if pk and holding<0  then
begin
sellshort(1,holding,marketr);
buy(tcon and (exitbars>0 or exitbars=-1),vv,marketr);  
end
  
buy(kd and holding=0 and tcon,vv,marketr);                        //开多信号
  
//有多头时候才触发反手
if pd and holding>0  then
begin
sell(1,holding,marketr);   
buyshort(tcon and (exitbars>0 or exitbars=-1),vv,marketr);      
end
  
buyshort(mk and holding=0 and tcon,vv,marketr);                   //开空信号
  

  
//止损
zsd:=sell(c<avgenterprice-20*mindiff,holding,marketr);
zsk:=sellshort(c>avgenterprice+20*mindiff,holding,marketr);
  

//止盈
h1:=hhv(h,enterbars+1);//开仓后最高价
l1:=llv(l,enterbars+1);
  
maxprofit:=if(holding>0,h1-avgenterprice,avgenterprice-l1);//开仓后最大盈利(价差)
currentprofit:=if(holding>0,c-avgenterprice,avgenterprice-c);//当前浮动盈亏(价差)
  
if maxprofit>=15*mindiff and  currentprofit<maxprofit*1 and enterbars>=0 then
begin
zyd:=sell(1,holding,marketr);
zyk:=sellshort(1,holding,marketr);        
end
  

//清仓
tq:=60*5;//提前的秒数
abb:=remainingtime(closetime(0))<=tq;
if abb then begin
qcd:=sell(1,holding,marketr);
qck:=sellshort(1,holding,marketr);     
end
金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

使用道具 举报

35

主题

175

帖子

175

积分

Rank: 2

等级: 标准版

注册:
2023-10-17
曾用名:
 楼主| 发表于 2024-7-29 14:49 | 显示全部楼层
老师,还是相关问题,是否可以电话跟您请教一下?感谢

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号? 微信登录

x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 微信登录

本版积分规则

手机版|小黑屋|上海金之塔信息技术有限公司 ( 沪ICP备13035422号 )

GMT+8, 2025-7-24 08:46 , Processed in 0.107212 second(s), 20 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表