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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 请问如下条件如何编写?

   

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


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

主题:请问如下条件如何编写?

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


加好友 发短信
等级:论坛游侠 帖子:215 积分:0 威望:0 精华:0 注册:2016/6/12 14:31:00
请问如下条件如何编写?  发帖心情 Post By:2017/3/22 8:59:39    Post IP:113.105.163.239[只看该作者]

请问如下的第二次及第n次开仓条件的语句如何编写?

tr1 : max(max((high-low),abs(ref(close,1)-high)),abs(ref(close,1)-low));

atr : ma(tr1,20);                               //atr公式

 

ma20:ma(close,20);                               //20日均线

 

a1:=0.01*valuewhen(barpos=1,asset);              //初始资金的1%

 

a2:=floor(a1/(2*atr));                         //开仓手数

 

a3:=ref(hhv(high,20),1);                       //20日高点

 

if holding=0 and close>a3 and close>ma20

then begin

buy(1,a2,marketr);

end                                   //第一次开仓

 

a4:=enterprice-2*ref(atr,enterbars=1);

if holding=1 and low<=a4

then begin

sell(1,0,limitr,a4);

end                                 //第一次开仓离场

 

//第二次及第n次开仓条件:如果随后的收盘 > 上一次(即第 n-1 次)开仓的(enterprice+2*atr),则开仓(即第 n 次);


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


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

variable:bj=0;

tr1 : max(max((high-low),abs(ref(close,1)-high)),abs(ref(close,1)-low));

atr : ma(tr1,20);                               //atr公式


ma20:ma(close,20);                               //20日均线


a1:=0.01*valuewhen(barpos=1,asset);              //初始资金的1%


a2:=floor(a1/(2*atr));                         //开仓手数


a3:=ref(hhv(high,20),1);                       //20日高点


if holding=0 and close>a3 and close>ma20 and bj=0

then begin

buy(1,a2,marketr);

bj:=1;

end                                   //第一次开仓

if holidng=0 and close>enterprice+2*atr and bj=1 

then begin

buy(1,a2,marketr);

end

a4:=enterprice-2*ref(atr,enterbars=1);

if holding=1 and low<=a4

then begin

sell(1,0,limitr,a4);

end              



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

客户服务部

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

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

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


加好友 发短信
等级:论坛游侠 帖子:215 积分:0 威望:0 精华:0 注册:2016/6/12 14:31:00
  发帖心情 Post By:2017/3/22 9:34:08    Post IP:113.105.163.239[只看该作者]

明白了,谢谢!

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


加好友 发短信
等级:论坛游侠 帖子:215 积分:0 威望:0 精华:0 注册:2016/6/12 14:31:00
  发帖心情 Post By:2017/3/22 9:46:12    Post IP:113.105.163.239[只看该作者]

你好,我看到你这行代码:
if holding=0 and close>a3 and close>ma20 and bj=0
then begin
buy(1,a2,marketr);
bj:=1;
end                                   //第一次开仓

if holding=0 and close>enterprice+2*atr and bj=1 
then begin
buy(1,a2,marketr);
end

第二处的“if holding=0 and close>enterprice+2*atr and bj=1 ”,这里有没有写错?还是“if holding=0”吗?不是“if holding>0

 回到顶部