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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 求助 运用全局变量 实现 大盈利或连续亏损两次后停止交易一段时间

   

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


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

主题:求助 运用全局变量 实现 大盈利或连续亏损两次后停止交易一段时间

帅哥哟,离线,有人找我吗?
厚德载物生
  21楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游侠 帖子:107 积分:0 威望:0 精华:0 注册:2014/11/10 9:11:27
  发帖心情 Post By:2015/4/27 16:05:32    Post IP:58.247.225.238[只看该作者]

谢谢版主 我再试试 图片点击可在新窗口打开查看

 回到顶部
帅哥哟,离线,有人找我吗?
厚德载物生
  22楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游侠 帖子:107 积分:0 威望:0 精华:0 注册:2014/11/10 9:11:27
  发帖心情 Post By:2015/4/28 13:03:12    Post IP:58.247.225.238[只看该作者]

版主 还是不行啊 哪怕把反手条件删掉 只留开仓条件与平仓条件 也还是不行

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


加好友 发短信
等级:罗宾汉 帖子:46311 积分:50819 威望:0 精华:2 注册:2011/3/23 8:50:25
  发帖心情 Post By:2015/4/28 13:17:57    Post IP:58.246.57.26[只看该作者]

把你写的贴出来,要全部代码


金字塔—专业程序化交易量化投资平台

客户服务部

----------------------------------------------------------- 欢迎您参加我公司的技术培训,具体培训需求请发邮件到service@weistock.com

您的宝贵建议或者投诉,请发往邮箱:weiwei@weistock.com

 回到顶部
帅哥哟,离线,有人找我吗?
厚德载物生
  24楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游侠 帖子:107 积分:0 威望:0 精华:0 注册:2014/11/10 9:11:27
  发帖心情 Post By:2015/4/29 23:04:29    Post IP:58.247.225.238[只看该作者]

好的,版主请赐教


//置顶版块  全局变量
variable:tpcc=0;//持仓计数
variable:rnqzpc=0; //日内收盘前强制平仓标志


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

交易总数:totaltrade,colorwhite,linethick0,nodraw;
日盈亏:asset-ref(asset,r1+1),noaxis,colorred,linethick0,nodraw;


QQ:=(H+L+C)/3;

60均线:MA((HIGH+LOW+CLOSE)/3,20),COLORred;

3Q:=MA((H+L+C+O)/4,1);
5Q:=MA(3Q,3);

// 第一版块 交易背景  




11均线:MA(3Q,10);

22均线:ma(5Q,100),COLORcyan;

33均线:ma(11均线,50);




//第二版块  交易参数设定


TIME1:= time>091500 AND time<151300;
TIME2:= time>091500 AND time<095500;
TIME3:= time>091500 AND time<093500;
TIME4:= time>=095500 AND time<151000;
TIME5:= time>=093500 AND time<151000;
TIME6:= time>=091400 AND time<091700;
TIME8:= time>=092300 AND time<151400;


//第三版块  开平仓条件设定


平空条件4:= 11均线>60均线  and not(ABS(60均线-11均线)<8 or 5Q-5<60均线) AND holding<0 ;//
平多条件4:= 11均线<60均线  and not(ABS(60均线-11均线)<8 or 5Q+5>60均线) AND holding>0 ;// 

平空条件3:=holding<0 and O-enterprice>=10 ;
平多条件3:=holding>0 and enterprice-O>=10 ; 




//第四版块  交易条件设定

pbuycond:= 平多条件4;
psellcond:=平空条件4;


a4:=平多条件4;
b4:=平空条件4 ;

a3:=平多条件3;
b3:=平空条件3;


if a4 and tpcc=1  then BEGIN
  平多4:SELL(1,lots,MARKETR),orderqueue;
  tpcc:=0;
  debugfile('D:\00002743.txt', '平多4 %.0f',holding );
end

if a3  and tpcc=1    then BEGIN
   止损平多3:SELL(1,lots,MARKETR),orderqueue;
  tpcc:=0;
  debugfile('D:\00002743.txt', '止损平多3 %.0f',holding );
end


if b4 and tpcc=2  then BEGIN
  平空4:SELLSHORT(1,lots,MARKETR),orderqueue;
  tpcc:=0;
  debugfile('D:\00002743.txt', '平空4 %.0f',holding );
end


if b3 and tpcc=2  then BEGIN
  止损平空3:SELLSHORT(1,lots,MARKETR),orderqueue;
  tpcc:=0;
  debugfile('D:\00002743.txt', '平空3 %.0f',holding );
end


//交易执行 开仓条件

开空条件0:= 60均线>11均线 AND abs(60均线-11均线)>1   and not(  3Q>60均线)  ;
开多条件0:= 60均线<11均线 AND abs(60均线-11均线)>1   and not(  3Q<60均线) ;


c0:=开空条件0   AND HOLDING=0;
c4:=pbuycond    AND holding=0 ;



d0:=开多条件0 AND HOLDING=0 ;
d4:=psellcond AND  holding=0 ;




//交易执行 空



if c4 and tpcc=0 AND TIME8 then BEGIN
  强转反开空:BUYSHORT(1,lots,MARKETR),orderqueue;
  tpcc:=2;
  debugfile('D:\00002743.txt', '强转反开空4 %.0f',holding );
end

if c0 and tpcc=0 AND TIME8   then BEGIN
  开空0:BUYSHORT(1,lots,MARKETR),orderqueue;//
  tpcc:=2;
  debugfile('D:\00002743.txt', '开空0 %.0f',holding );
end


//交易执行 多



if d4 and tpcc=0 AND TIME8 then BEGIN
 强转开多:BUY(1,lots,MARKETR),orderqueue;
  tpcc:=1;
  debugfile('D:\00002743.txt', ' 强转开多4 %.0f',holding );
end



if d0 and tpcc=0 AND TIME8 then BEGIN
 开多0:BUY(1,lots,MARKETR),orderqueue;//
  tpcc:=1;
  debugfile('D:\00002743.txt', ' 开多0 %.0f',holding );
end



//交易执行 收盘


if    time>=151400 and tpcc>0 then//weekday=5 and
begin
  收盘1:sell(1,0,MARKETR);
  收盘2:sellshort(1,0,MARKETR);
tpcc:=0;
rnqzpc:=1; //收盘前强制平仓标志赋值
end

 回到顶部
帅哥哟,离线,有人找我吗?
厚德载物生
  25楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游侠 帖子:107 积分:0 威望:0 精华:0 注册:2014/11/10 9:11:27
  发帖心情 Post By:2015/4/29 23:07:28    Post IP:58.247.225.238[只看该作者]

五一前最后一天 十分希望版主能帮助解决这个问题  另外 我用的是 15秒周期  ,版主可以整段代码复制,用多秒显示图形 再次感谢

 回到顶部
帅哥哟,离线,有人找我吗?
厚德载物生
  26楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游侠 帖子:107 积分:0 威望:0 精华:0 注册:2014/11/10 9:11:27
  发帖心情 Post By:2015/4/30 0:07:56    Post IP:58.247.225.238[只看该作者]

根据版主之前的回帖  我经过重重实验 ,这样修改代码 ,终于能正常显示交易信号,但是   盈利6000块停盘145周期,连续亏损两次停盘20周期, 功能执行不完整 有时起作用有时不起作用,请看上传图
图片点击可在新窗口打开查看此主题相关图片如下:qq图片20150430000114.png
图片点击可在新窗口打开查看
图片点击可在新窗口打开查看此主题相关图片如下:qq图片20150429235735.png
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:qq图片20150429235224.jpg
图片点击可在新窗口打开查看


 回到顶部
帅哥哟,离线,有人找我吗?
厚德载物生
  27楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游侠 帖子:107 积分:0 威望:0 精华:0 注册:2014/11/10 9:11:27
  发帖心情 Post By:2015/4/30 0:13:47    Post IP:58.247.225.238[只看该作者]

以下为我修改后的完整代码,开平仓以及收盘都做了全局变量 n m 的设定,另外 在做停盘条件上 用and不行 图形就不显示交易信号了,我必须用 not and (<一定周期的写法才能正常显示交易信号)


//置顶版块  全局变量
variable:tpcc=0;//持仓计数
variable:rnqzpc=0; //日内收盘前强制平仓标志
variable:n=0,m=0;
r1:=barslast(date<>ref(date,1));
r2:=ref(o,r1+1);
交易总数:totaltrade,colorwhite,linethick0,nodraw;
日盈亏:asset-ref(asset,r1+1),noaxis,colorred,linethick0,nodraw;


QQ:=(H+L+C)/3;






60均线:MA((HIGH+LOW+CLOSE)/3,20),COLORred;


3Q:=MA((H+L+C+O)/4,1);
5Q:=MA(3Q,3);

// 第一版块 交易背景  




11均线:MA(3Q,10);

22均线:ma(5Q,100),COLORcyan;

33均线:ma(11均线,50);
//第二版块  交易参数设定
TIME1:= time>091500 AND time<151300;
TIME2:= time>091500 AND time<095500;
TIME3:= time>091500 AND time<093500;
TIME4:= time>=095500 AND time<151000;
TIME5:= time>=093500 AND time<151000;
TIME6:= time>=091400 AND time<091700;
TIME8:= time>=092300 AND time<151400;
//第三版块  开平仓条件设定


平空条件4:= 11均线>60均线  and not(ABS(60均线-11均线)<8 or 5Q-5<60均线) AND holding<0 ;//
平多条件4:= 11均线<60均线  and not(ABS(60均线-11均线)<8 or 5Q+5>60均线) AND holding>0 ;// 

平空条件3:=holding<0 and O-enterprice>=10 ;
平多条件3:=holding>0 and enterprice-O>=10 ; 




//第四版块  交易条件设定

pbuycond:= 平多条件4;
psellcond:=平空条件4;


a4:=平多条件4;
b4:=平空条件4 ;

a3:=平多条件3;
b3:=平空条件3;

if a4 and tpcc=1  then BEGIN
  平多4:SELL(1,lots,MARKETR),orderqueue;
  tpcc:=0;
   if numprofit(1)>6000 then begin
         m:=0;
         n:=1;
     end
     if numprofit(1)>0 then m:=0;
     if numprofit(1)<0 then m:=m+1;
   debugfile('D:\00002743.txt', '平多4 %.0f',holding );
end

if a3  and tpcc=1    then BEGIN
  止损平多3:SELL(1,lots,MARKETR),orderqueue;
  tpcc:=0;
  if numprofit(1)>6000 then begin
         m:=0;
         n:=1;
     end
     if numprofit(1)>0 then m:=0;
     if numprofit(1)<0 then m:=m+1;
  debugfile('D:\00002743.txt', '止损平多3 %.0f',holding );
end


if b4 and tpcc=2  then BEGIN
  平空4:SELLSHORT(1,lots,MARKETR),orderqueue;
  tpcc:=0;
  if numprofit(1)>6000 then begin
         m:=0;
         n:=1;
     end
     if numprofit(1)>0 then m:=0;
     if numprofit(1)<0 then m:=m+1;
  debugfile('D:\00002743.txt', '平空4 %.0f',holding );
end


if b3 and tpcc=2  then BEGIN
  止损平空3:SELLSHORT(1,lots,MARKETR),orderqueue;
  tpcc:=0;
  if numprofit(1)>6000 then begin
         m:=0;
         n:=1;
     end
     if numprofit(1)>0 then m:=0;
     if numprofit(1)<0 then m:=m+1;
  debugfile('D:\00002743.txt', '平空3 %.0f',holding );
end

//交易执行 开仓条件

开空条件0:= 60均线>11均线 AND abs(60均线-11均线)>1   and not(  3Q>60均线)  ;
开多条件0:= 60均线<11均线 AND abs(60均线-11均线)>1   and not(  3Q<60均线) ;

停盘过滤:=(barslast(n=1 and ref(n=0,1))<145) or (barslast(m=2 and ref(m=1,1))<20);//

c0:=开空条件0  and not(停盘过滤) AND HOLDING=0;
c4:=pbuycond   and not(停盘过滤) AND HOLDING=0 ;




d0:=开多条件0  and not(停盘过滤) AND HOLDING=0 ;
d4:=psellcond  and not(停盘过滤) AND HOLDING=0 ;

//交易执行 空
if c4 and tpcc=0 AND TIME8 then BEGIN
  强转反开空:BUYSHORT(1,lots,MARKETR),orderqueue;
  tpcc:=2;
  debugfile('D:\00002743.txt', '强转反开空4 %.0f',holding );
  m=0;
  n=0;
end


if c0 and tpcc=0 AND TIME8   then BEGIN
  开空0:BUYSHORT(1,lots,MARKETR),orderqueue;//
  tpcc:=2;
  debugfile('D:\00002743.txt', '开空0 %.0f',holding );
  m=0;
  n=0;
end


//交易执行 多
if d4 and tpcc=0 AND TIME8 then BEGIN
 强转开多:BUY(1,lots,MARKETR),orderqueue;
  tpcc:=1;
  debugfile('D:\00002743.txt', ' 强转开多4 %.0f',holding );
  m=0;
  n=0;
end

if d0 and tpcc=0 AND TIME8 then BEGIN
 开多0:BUY(1,lots,MARKETR),orderqueue;//
  tpcc:=1;
  debugfile('D:\00002743.txt', ' 开多0 %.0f',holding );
  m=0;
  n=0;
end



//交易执行 收盘

if    time>=151400 and tpcc>0 then//weekday=5 and
begin
  收盘1:sell(1,0,MARKETR);
  收盘2:sellshort(1,0,MARKETR);
tpcc:=0;
rnqzpc:=1; //收盘前强制平仓标志赋值
n=0;
m=0;
end





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


加好友 发短信
等级:罗宾汉 帖子:46311 积分:50819 威望:0 精华:2 注册:2011/3/23 8:50:25
  发帖心情 Post By:2015/4/30 8:40:53    Post IP:58.246.57.26[只看该作者]

请问图中的盈利6000块是实际账户盈利的6000吗?



金字塔—专业程序化交易量化投资平台

客户服务部

----------------------------------------------------------- 欢迎您参加我公司的技术培训,具体培训需求请发邮件到service@weistock.com

您的宝贵建议或者投诉,请发往邮箱:weiwei@weistock.com

 回到顶部
帅哥哟,离线,有人找我吗?
厚德载物生
  29楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游侠 帖子:107 积分:0 威望:0 精华:0 注册:2014/11/10 9:11:27
  发帖心情 Post By:2015/4/30 9:42:40    Post IP:58.247.225.238[只看该作者]

对,是这个意思

 回到顶部
帅哥哟,离线,有人找我吗?
厚德载物生
  30楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:论坛游侠 帖子:107 积分:0 威望:0 精华:0 注册:2014/11/10 9:11:27
  发帖心情 Post By:2015/4/30 9:46:07    Post IP:58.247.225.238[只看该作者]

顶一个 顶一个 等待版主的回复

 回到顶部
总数 52 上一页 1 2 3 4 5 6 下一页