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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 代码编写问题

   

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


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

主题:代码编写问题

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


加好友 发短信
等级:新手上路 帖子:13 积分:0 威望:0 精华:0 注册:2018/12/7 14:28:41
代码编写问题  发帖心情 Post By:2018/12/10 13:07:26    Post IP:180.169.30.6[只看该作者]

{金牛三色K线}
{主趋势线:EMA(EMA(C,10),10),COLORRED,LINETHICK3;
B:=主趋势线<REF(主趋势线,1);
IF(B-1,主趋势线,DRAWNULL)COLORRED,LINETHICK3;}
主趋势线:EMA(EMA(C,10),10),COLORRED,LINETHICK3;
B:=主趋势线>REF(主趋势线,1);
IF(B-1,主趋势线,DRAWNULL)COLORBLUE,LINETHICK3;
{操盘线:EMA(EMA(C,5),5),COLORRED,LINETHICK2;
Y:=操盘线>REF(操盘线,1);
IF(Y-1,操盘线,DRAWNULL)COLORGREEN,LINETHICK2;}

AA:=EMA(C,5) > EMA(C,20);
BB:=EMA(C,5) < EMA(C,20);
CC:= EMA(C,5) > EMA(C,10);
CC1:=EMA(C,5) < EMA(C,10);
DD:=CLOSE<OPEN;

STICKLINE(AA,H,L,0,0),COLORRED;
STICKLINE(AA,O,C,3,1),COLORRED;
STICKLINE(AA AND DD,O,C,3,0),COLORRED;
STICKLINE(BB,H,L,0,0),COLORGREEN;
STICKLINE(BB,O,C,3,1),COLORGREEN;

STICKLINE(BB AND DD,O,C,3,0),COLORGREEN;


if aa then 
BEGIN
sellshort(holding<0,holding,market);
buy(holding=0,1,limit,c);    
end

if bb then 
BEGIN
sell(holding>0,holding,market);
buyshort(holding=0,1,limit,c);    
end


if holding>0 and hhv(h,enterbars+1)>enterprice+10*mindiff and c<=enterprice+3 then sell(1,0,limitr,enterprice+8),ignorecheckprice;
if holding<0 and llv(l,enterbars+1)<enterprice-10*mindiff and c>=enterprice-3 then sellshort(1,0,limitr,enterprice-8),ignorecheckprice;





if holding>0 and c<=主趋势线-5*MINDIFF then 止损1:sell(1,holding,market);
if holding<0 and c>=主趋势线+5*MINDIFF then 止损2:sellshort(1,holding,market);


if time>=185500 then 
begin
sellshort(holding<0,holding,market);
sell(holding>0,holding,market);
end


老师帮我看下,我想写的是,进场货获利10点后回测到3点,就自动平仓, 开单后止损在趋势线5点位置, 每天交易到2点55自动平仓,这样写对吗。

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


加好友 发短信
等级:超级版主 帖子:14496 积分:0 威望:0 精华:0 注册:2017/7/4 13:40:18
  发帖心情 Post By:2018/12/10 13:25:31    Post IP:180.169.30.6[只看该作者]

 基本差不多,要表述从高点回撤的话这个地方可能要修改下。

if holding>0 and hhv(h,enterbars+1)>enterprice+10*mindiff and c<= hhv(h,enterbars+1)-3*mindiff then sell(1,0,limitr,enterprice+8*MINDIFF),ignorecheckprice;
if holding<0 and llv(l,enterbars+1)<enterprice-10*mindiff and c>= hhv(h,enterbars+1)+3*mindiff then sellshort(1,0,limitr,enterprice-8*MINDIFF),ignorecheckprice;


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


加好友 发短信
等级:新手上路 帖子:14 积分:0 威望:0 精华:0 注册:2018/12/7 10:44:21
  发帖心情 Post By:2018/12/10 14:22:46    Post IP:175.43.245.218[只看该作者]

老师您好用你修改的后,在3分钟周期里面。多单会出现第一根K收盘后在进场价格往上8点的位置挂平仓单呢,怎么修改呢

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


加好友 发短信
等级:新手上路 帖子:14 积分:0 威望:0 精华:0 注册:2018/12/7 10:44:21
  发帖心情 Post By:2018/12/10 14:25:16    Post IP:175.43.245.218[只看该作者]

还有出现了持续进仓,在收盘价格的位置。持续进仓

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


加好友 发短信
等级:新手上路 帖子:14 积分:0 威望:0 精华:0 注册:2018/12/7 10:44:21
  发帖心情 Post By:2018/12/10 14:32:40    Post IP:175.43.245.218[只看该作者]

老师 求帮忙
图片点击可在新窗口打开查看此主题相关图片如下:微信图片_20181210143055.png
图片点击可在新窗口打开查看

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


加好友 发短信
等级:超级版主 帖子:14496 积分:0 威望:0 精华:0 注册:2017/7/4 13:40:18
  发帖心情 Post By:2018/12/10 15:23:42    Post IP:180.169.30.6[只看该作者]

 这个持续开仓和你的开仓条件有关系。

比如这个:
AA:=EMA(C,5) > EMA(C,20);

其实这个aa会有一段持续的过程,也就是说连续N个K上都会满足的。这样的话一旦触发了平仓使得holding=0也成立了,就会连续开仓。也就是你上面图上看到的。

“老师您好用你修改的后,在3分钟周期里面。多单会出现第一根K收盘后在进场价格往上8点的位置挂平仓单呢,怎么修改呢 ”
这个应该是if holding>0 and hhv(h,enterbars+1)>enterprice+10*mindiff and c<= hhv(h,enterbars+1)-3*mindiff then sell(1,0,limitr,enterprice+8*MINDIFF),ignorecheckprice;

这句代码触发的,但是你这个代码里面的下单时候就是按照开仓K的收盘价+8个变动价位挂单的啊。因为你上面这个连续开平的缘故,导致上一个K收盘价就是上次开仓价。


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


加好友 发短信
等级:新手上路 帖子:14 积分:0 威望:0 精华:0 注册:2018/12/7 10:44:21
  发帖心情 Post By:2018/12/10 15:31:03    Post IP:175.43.245.218[只看该作者]

亲爱的老师 ,那这两段话有没有办法修改一下呢,求帮忙一下

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


加好友 发短信
等级:超级版主 帖子:14496 积分:0 威望:0 精华:0 注册:2017/7/4 13:40:18
  发帖心情 Post By:2018/12/10 16:55:21    Post IP:180.169.30.6[只看该作者]

 这里修改下试下呢:

if holding>0 and hhv(h,enterbars+2)>enterprice+10*mindiff and c<= hhv(h,enterbars+2)-3*mindiff then 止盈1:sell(1,0,limitr,enterprice+8*MINDIFF),ignorecheckprice;
if holding<0 and llv(l,enterbars+2)<enterprice-10*mindiff and c>= hhv(h,enterbars+2)+3*mindiff then 止盈2:sellshort(1,0,limitr,enterprice-8*MINDIFF),ignorecheckpri


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