Board logo

标题: [金字塔源码] 金字塔Dual Thrust日内策略模型源码集锦 (多个版本源码) [打印本页]

作者: 龙听    时间: 2018-9-30 14:13     标题: 金字塔Dual Thrust日内策略模型源码集锦 (多个版本源码)

Dual Thrust与R-Breaker一样,曾长期排名 Future Trust杂志最赚钱的策略。该策略在形式上和开盘区间突破策略类似。不同点主要体现在两方面:Dual Thrust在Range(代码中的浮动区间)的设置上,引入前N日的四个价位,使得一定时期内的Range相对稳定,可以适用于日间的趋势跟踪;Dual Thrust对于多头和空头的触发条件,考虑了非对称的幅度,做多和做空参考的Range可以选择不同的周期数,也可以通过参数K1和K2来确定。


  当K1<K2时,多头相对容易被触发,当K1>K2时,空头相对容易被触发。因此,投资者在使用该策略时,一方面可以参考历史数据测试的最优参数,另一方面,则可以根据自己对后势的判断,或从其他大周期的技术指标入手,阶段性地动态调整K1和K2的值。



201307302114045770.gif

此主题相关图片如下:dual thrust.jpg
201307302114054088.jpg



图片附件: 201307302114045770.gif (2018-9-30 14:13, 125 Bytes) / 下载次数 136
http://www.qhlt.cn/attachment.php?aid=4441&k=d4135973d8b232750aab823aaa8da0cf&t=1714284587&sid=NfTzEO



图片附件: 201307302114054088.jpg (2018-9-30 14:13, 32.35 KB) / 下载次数 97
http://www.qhlt.cn/attachment.php?aid=4442&k=b336fd24121c3538eca1144b0a054def&t=1714284587&sid=NfTzEO



图片附件: 201307302114054088.jpg (2018-9-30 14:13, 32.35 KB) / 下载次数 121
http://www.qhlt.cn/attachment.php?aid=4443&k=183f02cf2f836c7be55c804fc1ab2d86&t=1714284587&sid=NfTzEO


作者: 龙听    时间: 2018-9-30 14:15

版本一:
  1. //策略:Dual Thrust
  2. //类型:日内
  3. //修订时间:2012.11.1
  4. //Designed By Rogarz


  5. //中间变量
  6. input:n(1,1,100,1),K1(0.7,0.1,1,0.1),k2(0.7,0.1,1,0.1),nmin(10,1,100,1),ss(1,1,100,1);
  7. CYC:=barslast(date<>ref(date,1))+1;
  8. 昨高:=callstock(stklabel,vthigh,6,-1);
  9. 昨低:=callstock(stklabel,vtlow,6,-1);
  10. 昨收:=callstock(stklabel,vtclose,6,-1);
  11. 开盘价:=valuewhen(cyc=1,open);
  12. HH:=hhv(昨高,n);//N日high的最高价
  13. HC:=hhv(昨收,n);//N日close的最高价
  14. LC:=LLV(昨收,n);//N日close的最低价
  15. LL:=LLV(昨低,n);//N日low的最低价
  16. 浮动区间:=max(HH-LL,HC-LL);//range
  17. 上轨:开盘价+k1*浮动区间;
  18. 下轨:开盘价-K2*浮动区间;
  19. t1:=time>opentime(1) and time<closetime(0)-nmin*100;
  20. t2:=time>=closetime(0)-nmin*100;
  21. 手数:=ss;
  22. //交易条件 www.cxh99.com
  23. 开多条件:=c>上轨 and holding=0;
  24. 开空条件:=c<下轨 and holding=0;
  25. //交易系统
  26. 开多:buy(开多条件 and t1 and cyc>1,手数,market);
  27. 开空:buyshort(开空条件 and t1 and cyc>1,手数,market);
  28. 收盘平多:sell(t2,手数,market);
  29. 收盘平空:sellshort(t2,手数,market);
复制代码


这个策略在论坛中已有很多个版本,这个版本——引入了前N日的四个价位,以及K1、K2参数。默认参数设置与原论坛中的策略一致,为前一日,K1=k2=0.7.
作者: 龙听    时间: 2018-9-30 14:15

版本二:第二种版源码:

适合日线以下 任何周期 中间直接调用 日线数据 不过每天要把画面切换到 日线周期 刷新一个昨日的日线数据

还有注意费率设置 要改成期货 15% 合约单位 按该品种自己调整 手续费自己调整


  1. input:k(0.7,0.1,1,0.1);
  2. predayhigh:=callstock(stklabel,vthigh,6,-1);//昨日最高价
  3. predaylow:=callstock(stklabel,vtlow,6,-1);//昨日最低价
  4. predayclose:=callstock(stklabel,vtclose,6,-1);//昨日收盘价
  5. predayrange:=max(predayhigh-predayclose,predayclose-predaylow);//取大波动值
  6. dayopen:=callstock(stklabel,vtopen,6,0);//今天开盘价
  7. upperband:intpart(dayopen+k*predayrange),colorred;//区间上沿
  8. lowerband:intpart(dayopen-k*predayrange),colorgreen;//区间下沿

  9. 下日波动:max(callstock(stklabel,vthigh,6,0)-callstock(stklabel,vtclose,6,0),callstock(stklabel,vtclose,6,0)-callstock(stklabel,vtlow,6,0))*0.7;
  10. if holding=0 then begin
  11. if high>=upperband then
  12.   buy(1,volunit,limitr,max(open,upperband));
  13. end
  14. if holding=0 then begin
  15. if low<=lowerband then
  16.   buyshort(1,volunit,limitr,min(open,lowerband));
  17. end
  18. if holding>0 then begin
  19. if low<=lowerband then begin
  20.   sell(1,holding,limitr,min(open,lowerband));
  21.   buyshort(1,volunit,limitr,min(open,lowerband));
  22. end

  23. if time>=closetime(0) then
  24.   sell(1,holding,limitr,close);
  25. end

  26. if holding<0 then begin
  27. if high>=upperband then begin
  28.   sellshort(1,holding,limitr,max(open,upperband));
  29.   buy(1,volunit,limitr,max(open,upperband));
  30. end
  31. //www.cxh99.com
  32. if time>=closetime(0) then
  33.   sellshort(1,holding,limitr,close);
  34. end


  35. 资产:ASSET,PRECISION0,NOAXIS,COLORFF00FF;
  36. goodin:=(1-(asset/hhv(asset,5520)))*100;
  37. 资产回撤百分比:goodin;
  38. 资产实际亏损:hhv(asset,5520)-asset,COLORgreen;
复制代码

作者: 龙听    时间: 2018-9-30 14:16

版本三:
本帖隐藏的内容需要回复才可以浏览

作者: 达达兔    时间: 2019-5-6 07:26

学习了
作者: 哈巴狗    时间: 2019-5-16 00:18

学习了
作者: 旺仔    时间: 2019-5-19 03:31

学习
作者: 刘伟    时间: 2019-6-6 16:39

好东西啊
作者: 西门斯    时间: 2019-6-15 17:08

xixie
作者: 呆哥哥    时间: 2020-1-3 23:21

感謝分享、版主辛苦了
作者: 傲雪松    时间: 2020-1-27 10:40

xuexi
作者: 洛阳人家    时间: 2021-2-11 21:50

谢谢分享
作者: 随波逐流    时间: 2021-7-14 11:15

开启版本三
作者: 美股菜菜    时间: 2021-11-2 13:02

感謝分享、版主辛苦了
作者: 永昼    时间: 2022-3-3 13:22

xuexi
作者: 硫化鉀    时间: 2023-3-18 14:49

學習




欢迎光临 龙听期货论坛 (http://www.qhlt.cn/) Powered by Discuz! 7.2