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


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → [分享]文华的止损策略写成的金字塔源码

   

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


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

主题:[分享]文华的止损策略写成的金字塔源码

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


加好友 发短信
等级:黑侠 帖子:628 积分:2193 威望:0 精华:0 注册:2010/5/27 11:25:08
[分享]文华的止损策略写成的金字塔源码  发帖心情 Post By:2010/9/6 17:14:55    Post IP:222.240.176.212[显示全部帖子]

//限价止损
{IF  h>=ENTERPRICE+D*mindiff and HOLDING<0 THEN BEGIN//D---D个价位止损
SELLshort(HOLDING<0,HOLDING,stopr,ENTERPRICE+D*mindiff);//止空
END;
IF  l<=ENTERPRICE-D*mindiff and HOLDING>0 THEN BEGIN//D---D个价位止损
SELL(HOLDING>0,HOLDING,stopr,ENTERPRICE-D*mindiff);//止多
END;}

//追踪止损
{
stps:ref(if(holding<0,if(enterprice-llv(l,openbar)>=mindiff*step,enterprice+d*mindiff-CEILING((enterprice-llv(l,openbar))/mindiff/step)*step*mindiff,enterprice+d*mindiff),drawnull),1);
stpl:ref(if(holding>0,if(hhv(h,openbar)-enterprice>=mindiff*step,floor(((hhv(h,openbar)-enterprice)/mindiff/step))*step*mindiff+enterprice-d*mindiff,enterprice-d*mindiff),drawnull),1);

IF h>=stps and HOLDING<0 THEN BEGIN//D---D个价位止损;step---步长;stps----空单止损位;
SELLshort(HOLDING<0,HOLDING,stopr,stps);//止空
END;
IF l<=stpl THEN BEGIN//D---D个价位止损;step---步长;stpl----多单止损位;
SELL(HOLDING>0,HOLDING,stopr,stpl);//止多
END;
}


//限价止损+追踪止盈
{
stps:ref(if(holding<0,if(llv(l,openbar)>=enterprice-dd*mindiff-step*mindiff,enterprice+d*mindiff,llv(l,openbar)+step*mindiff),drawnull),1);
stpl:ref(if(holding>0,if(hhv(h,openbar)<=enterprice+dd*mindiff+step*mindiff,enterprice-d*mindiff,hhv(h,openbar)-step*mindiff),drawnull),1);

IF h>=stps and HOLDING<0 THEN BEGIN//D---D个价位止损;step---步长;stps----空单止损位;dd---dd个价位止盈;
SELLshort(HOLDING<0,HOLDING,stopr,stps);//止空
END;
IF l<=stpl THEN BEGIN//D---D个价位止损;step---步长;stpl----多单止损位;dd---dd个价位止盈;
SELL(HOLDING>0,HOLDING,stopr,stpl);//止多
END;
}


版主评定:好评,获得10个金币奖励好评,获得10个金币奖励
(理由:好文章)
 回到顶部
帅哥哟,离线,有人找我吗?
ch3coohqb
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:黑侠 帖子:628 积分:2193 威望:0 精华:0 注册:2010/5/27 11:25:08
  发帖心情 Post By:2010/9/26 17:20:45    Post IP:222.240.176.212[显示全部帖子]

input:d(20,5,60,1);
input:dd(5,5,60,1);
input:step(20,5,40,1);

ma1:ma(c,10);
ma2:ma(c,20);
buy(holding=0 and cross(ma1,ma2),thisclose);


stps:ref(if(holding<0 and openbar>=0,if(enterprice-llv(l,openbar+1)>=mindiff*step,enterprice+d*mindiff-CEILING((enterprice-llv(l,openbar+1))/mindiff/step)*step*mindiff,enterprice+d*mindiff),drawnull),1);
stpl:ref(if(holding>0 and openbar>=0,if(hhv(h,openbar+1)-enterprice>=mindiff*step,floor(((hhv(h,openbar+1)-enterprice)/mindiff/step))*step*mindiff+enterprice-d*mindiff,enterprice-d*mindiff),drawnull),1);

IF h>=stps and HOLDING<0 THEN BEGIN//D---D个价位止损;step---步长;stps----空单止损位;
SELLshort(HOLDING<0,HOLDING,stopr,stps);//止空
END;
IF l<=stpl THEN BEGIN//D---D个价位止损;step---步长;stpl----多单止损位;
SELL(HOLDING>0,HOLDING,stopr,stpl);//止多
END;


开仓历时:openbar,linethick0;
test:hhv(h,openbar+1),linethick0;


 

==================

主贴的源码有点问题~

主要出在开仓后第一个周期openbar返回0结果HHV求出的是所有周期的最大值...

我以前写好的是用enterbars的后来改的不见了~

上面这个源码仅用于测试...

 

大家用之前先看看文华的策略介绍

然后再仔细看下这个源码是如何运算的..


 回到顶部