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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 关于加仓的问题?

   

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


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

主题:关于加仓的问题?

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


加好友 发短信
等级:超级版主 帖子:14496 积分:0 威望:0 精华:0 注册:2017/7/4 13:40:18
  发帖心情 Post By:2019/2/26 9:09:43    Post IP:180.169.30.6[显示全部帖子]

 jc1:holding>0 and MID>AvGENTERPRICE;//多头加仓条件
if jc1 then buy(holding>0,1,market);

jc2:holding<0 and AvGENTERPRICE<MID;//空头加仓条件
if jc2 then buyshort(holding<0,1,market);


zs1:holding>0 and MID<AvGENTERPRICE;//多头止损条件
if zs1 then sell(holding>0,holding,market);

zs2:holding<0 and MID>AvGENTERPRICE;//空头止损条件
if zs2 then sellshort(holding<0,holding,market);
[此贴子已经被作者于2019/2/26 10:16:12编辑过]


命数如织,当如磐石。
 回到顶部
帅哥哟,离线,有人找我吗?
FireScript
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:14496 积分:0 威望:0 精华:0 注册:2017/7/4 13:40:18
  发帖心情 Post By:2019/2/26 14:44:21    Post IP:180.169.30.6[显示全部帖子]

 VARIABLE:ct1:=0,ct2:=0;
jc1:holding>0 and MID>AvGENTERPRICE;//多头加仓条件
if jc1 then  
begin
buy(holding>0 and ct1<2,1,market);
ct1:=ct1+1;
end

jc2:holding<0 and AvGENTERPRICE<MID;//空头加仓条件
if jc2 then begin
buyshort(holding<0 and ct2<2,1,market);
ct2:=ct2+1;
end

zs1:holding>0 and MID<AvGENTERPRICE;//多头止损条件
if zs1 then
begin
sell(holding>0,holding,market);
ct1:=0;
end
zs2:holding<0 and MID>AvGENTERPRICE;//空头止损条件
if zs2 then
begin
sellshort(holding<0,holding,market);
ct2:=0;
end

用全局变量控制试下。


命数如织,当如磐石。
 回到顶部
帅哥哟,离线,有人找我吗?
FireScript
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:14496 积分:0 威望:0 精华:0 注册:2017/7/4 13:40:18
  发帖心情 Post By:2019/2/26 15:11:07    Post IP:180.169.30.6[显示全部帖子]

 发下你的完整代码我看下。


命数如织,当如磐石。
 回到顶部
帅哥哟,离线,有人找我吗?
FireScript
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:14496 积分:0 威望:0 精华:0 注册:2017/7/4 13:40:18
  发帖心情 Post By:2019/2/27 9:32:38    Post IP:180.169.30.6[显示全部帖子]

 你没把全局变量整合进去。

VARIABLE:ct1:=0,ct2:=0;
M:=26;
K:=2;
MID:  MA(CLOSE,M);//布林中轨
UPPER: MID + K*STD(CLOSE,M);//布林上轨
LOWER: MID - K*STD(CLOSE,M);//布林下轨

ss1:CEILING(30/(UPPER-MID));
ss2:CEILING(30/(MID-LOWER));
buycond1:h>=UPPER;
buycond2:l<=LOWER;

开多:buy(buycond1 and holding=0,ss1,market);
开空:buyshort(buycond2 and holding=0,ss2,market);

jc1:holding>0 and MID>AvGENTERPRICE and ct1<2;//多头加仓条件
if jc1 then 
begin
加仓1:buy(holding>0 and ct1<2,1,market);
ct1:=ct1+1;
end

jc2:holding<0 and AvGENTERPRICE<MID and ct2<2 ;//空头加仓条件
if jc2 then begin
加仓2:buyshort(holding<0 and ct2<2,1,market);
ct2:=ct2+1;
end

ydzs1:l<MID and holding>0;//多头止损条件
if ydzs1 then
begin
止损1:sell(holding>0,holding,market);
ct1:=0;
end
ydzs2:h>MID and holding<0;//空头止损条件
if ydzs2 then
begin
止损2:sellshort(holding<0,holding,market);
ct2:=0;
end



当前持仓:HOLDING,COLORGRAY,LINETHICK0;
当前资产:ASSET,NOAXIS,COLORGRAY;



命数如织,当如磐石。
 回到顶部
帅哥哟,离线,有人找我吗?
FireScript
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:14496 积分:0 威望:0 精华:0 注册:2017/7/4 13:40:18
  发帖心情 Post By:2019/2/27 10:05:12    Post IP:180.169.30.6[显示全部帖子]

 截图具体说明下你说的不符合条件的开仓。开仓肯定有很多次了。平仓之后再次符合条件肯定还会开仓的。我这个代码只能保证有限次的加仓。


命数如织,当如磐石。
 回到顶部