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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → [求助]移动止盈问题

   

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


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

主题:[求助]移动止盈问题

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


加好友 发短信
等级:新手上路 帖子:35 积分:31 威望:0 精华:0 注册:2011/11/30 14:35:54
[求助]移动止盈问题  发帖心情 Post By:2014/4/17 8:31:05    Post IP:61.154.239.10[只看该作者]

看了论坛中的移动止盈范例,添加进我的策略中,怎么maxprofit与win总是一直一致的,在行情转向过后,两个的数据还是一致,导致win2一直是0,这是什么原因
VARIABLE: maxprofit=0;
win:=0;
win2:=0;
if holding > 0 and enterbars > 0 then
begin
 win:=(c-enterprice)/enterprice*100; //记录最大盈利
 if win>maxprofit then begin
  maxprofit:=win; 
  u:maxprofit;
  end
 win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
 p:win2;
end
if holding < 0 and enterbars > 0 then
begin
 win:=(enterprice-c)/enterprice*100; //记录最大盈利
 if win> maxprofit then begin
  maxprofit:=win;
  i:maxprofit;
  end
 win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
 d:win2;
end
//出现最高盈利后,回落到盈利的60%平仓出场
止赢多:SELL(win2>=60 and openprofit > 0, 0);// and openprofit > 0
止盈空:sellshort(win2>60 and openprofit > 0,0);
[此贴子已经被作者于2014/4/17 8:31:48编辑过]

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


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

你的开仓语句写在哪里?


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

客户服务部

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

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

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


加好友 发短信
等级:新手上路 帖子:35 积分:31 威望:0 精华:0 注册:2011/11/30 14:35:54
  发帖心情 Post By:2014/4/17 9:40:30    Post IP:61.154.239.10[只看该作者]

整个程序总体是这样的顺序
VARIABLE: maxprofit=0;
{这部分是引用昨日数据}
HH:=hhv(昨高,n);
HC:=hhv(昨收,n);
LC:=LLV(昨收,n);
LL:=LLV(昨低,n);
we:=max(HH-LL,HC-LL)
s:开盘价+k1*we;
x:开盘价-k2*we
z:(s+x)/2;
//交易条件
a1:=c>上轨 and holding=0;
a2:=c<下轨 and holding=0;
//交易系统

开多:buy(a1=1 and (t1 or t2) and cyc>1,1,market);
开空:buyshort(a2=1 and (t1 or t2) and cyc>1,1,market);

win:=0;
win2:=0;
if holding > 0 and enterbars > 0 then
begin
 win:=(c-enterprice)/enterprice*100; //记录最大盈利
 if win>maxprofit then begin
  maxprofit:=win; 
  u:maxprofit;
  end
 win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
 p:win2;
end
if holding < 0 and enterbars > 0 then
begin
 win:=(enterprice-c)/enterprice*100; //记录最大盈利
 if win> maxprofit then begin
  maxprofit:=win;
  i:maxprofit;
  end
 win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
 d:win2;
end
//出现最高盈利后,回落到盈利的60%平仓出场
止赢多:SELL(win2>=60 and openprofit > 0, 0);// and openprofit > 0
止盈空:sellshort(win2>60 and openprofit > 0,0);


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


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

把你引用昨日的数据贴一下

 

HH:=hhv(昨高,n);这个是什么意思,N周期前的昨高?
 
n的值是多少?


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

客户服务部

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

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

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


加好友 发短信
等级:新手上路 帖子:35 积分:31 威望:0 精华:0 注册:2011/11/30 14:35:54
  发帖心情 Post By:2014/4/17 10:11:41    Post IP:61.154.239.10[只看该作者]

VARIABLE: maxprofit=0;
昨高:=callstock(stklabel,vthigh,6,-n);
昨低:=callstock(stklabel,vtlow,6,-n);
昨收:=callstock(stklabel,vtclose,6,-n);
\\n是15,指引用十五日内的最高最低价
HH:=hhv(昨高,n);
HC:=hhv(昨收,n);
LC:=LLV(昨收,n);
LL:=LLV(昨低,n);
we:=max(HH-LL,HC-LL)
s:开盘价+k1*we;
x:开盘价-k2*we
z:(s+x)/2;
//交易条件
a1:=c>s and holding=0;
a2:=c<x and holding=0;
//交易系统

开多:buy(a1=1 and (t1 or t2) and cyc>1,1,market);
开空:buyshort(a2=1 and (t1 or t2) and cyc>1,1,market);

win:=0;
win2:=0;
if holding > 0 and enterbars > 0 then
begin
 win:=(c-enterprice)/enterprice*100; //记录最大盈利
 if win>maxprofit then begin
  maxprofit:=win; 
  u:maxprofit;
  end
 win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
 p:win2;
end
if holding < 0 and enterbars > 0 then
begin
 win:=(enterprice-c)/enterprice*100; //记录最大盈利
 if win> maxprofit then begin
  maxprofit:=win;
  i:maxprofit;
  end
 win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度
 d:win2;
end
//出现最高盈利后,回落到盈利的60%平仓出场
止赢多:SELL(win2>=60 and openprofit > 0, 0);// and openprofit > 0
止盈空:sellshort(win2>60 and openprofit > 0,0);

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


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

HH:=hhv(昨高,n);
HC:=hhv(昨收,n);
LC:=LLV(昨收,n);
LL:=LLV(昨低,n);
那这几句是用来干什么的?解释一下


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

客户服务部

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

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

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


加好友 发短信
等级:新手上路 帖子:35 积分:31 威望:0 精华:0 注册:2011/11/30 14:35:54
  发帖心情 Post By:2014/4/17 10:22:49    Post IP:61.154.239.10[只看该作者]

这个是用来求的15日内最高价和最低价,还有收盘价的最高最低价。
[此贴子已经被作者于2014/4/17 10:24:24编辑过]

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


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

算了,不指望你给我全部代码了,怎么改也编译不过

你不能理解范例中最大获利,那么给你一个简单的例子:

maxprofit:=hhv(h,enterbars+1)-enteprice;多头

maxprofit:=enterprice-llv(l,enterbars+1);空头

 



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

客户服务部

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

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

 回到顶部