: | : | :期货量化学习 | :期货量化 |
返回列表 发帖

鼎元C++程序化策略超市产品 第012款 “鳄鱼法则交易系统“

鼎元C++程序化策略超市产品 第012款 “鳄鱼法则交易系统“



说明:

1、鳄鱼的三件套还是比较好设计的。
2、分型就要命了,太复杂了。虽然看了MC的源码还是不知道怎么个写法。
3、所以进场我就用五周期最点突破和五周期最低点突破来进场了。
4、鳄鱼线多头排列是做多的条件,空头排列是做空的条件。
5、DLL策略下载:http://p.qhlt.cn/public-0-6.html

论坛官方微信、群(期货热点、量化探讨、开户与绑定实盘)
 
期货论坛 - 版权/免责声明   1.本站发布源码(包括函数、指标、策略等)均属开放源码,用意在于让使用者学习程序化语法撰写,使用者可以任意修改语法內容并调整参数。仅限用于个人学习使用,请勿转载、滥用,严禁私自连接实盘账户交易
  2.本站发布资讯(包括文章、视频、历史记录、教材、评论、资讯、交易方案等)均系转载自网络主流媒体,内容仅为作者当日个人观点,本网转载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。本网不对该类信息或数据做任何保证。不对您构成任何投资建议,不能依靠信息而取代自身独立判断,不对因使用本篇文章所诉信息或观点等导致的损失承担任何责任。
  3.本站发布资源(包括书籍、杂志、文档、软件等)均从互联网搜索而来,仅供个人免费交流学习,不可用作商业用途,本站不对显示的内容承担任何责任。请在下载后24小时内删除。如果喜欢,请购买正版,谢谢合作!
  4.龙听期货论坛原创文章属本网版权作品,转载须注明来源“龙听期货论坛”,违者本网将保留追究其相关法律责任的权力。本论坛除发布原创文章外,亦致力于优秀财经文章的交流分享,部分文章推送时若未能及时与原作者取得联系并涉及版权问题时,请及时联系删除。联系方式:http://www.qhlt.cn/thread-262-1-1.html
如何访问权限为100/255贴子:/thread-37840-1-1.html;注册后仍无法回复:/thread-23-1-1.html;微信/QQ群:/thread-262-1-1.html;网盘链接失效解决办法:/thread-93307-1-1.html

论坛上面相关主题:

[MC源码] 鳄鱼法则指标( Alligator Indicators)公式/交易策略【鳄鱼线、AO、AC指标公式及源码】:http://www.qhlt.cn/thread-115409-1-1.html

第245节:通过鳄鱼法则指标( Alligator Indicators)创建鳄鱼法则交易策略( Alligator Strategy)并对国内经典品种进行绩效:http://www.qhlt.cn/thread-129016-1-1.html

[外汇货币] 鳄鱼线指标(The Alligator Indicator)【2008.01期】http://www.qhlt.cn/thread-149288-1-1.html

[TS源码] Alligator Indicators(鳄鱼线) by Bill Williams:http://www.qhlt.cn/thread-22292-1-1.html

【混沌鳄鱼线(Chaos Alligator)】:http://www.qhlt.cn/thread-133651-1-1.html

【Chaos Alligator】http://www.qhlt.cn/thread-133446-1-1.html

期货量化策略精选系列21-经典鳄鱼法则策略交易系统(Alligator principle Trading system)【鳄鱼法则交易策略】http://www.qhlt.cn/thread-115497-1-1.html
如何访问权限为100/255贴子:/thread-37840-1-1.html;注册后仍无法回复:/thread-23-1-1.html;微信/QQ群:/thread-262-1-1.html;网盘链接失效解决办法:/thread-93307-1-1.html

TOP

主程式码(鳄鱼线设计及输出模块):
  1.         /////////////////////////////////////////////////////////////鳄鱼线设计//////////////////////////////////////////////////////
  2.         pc.clear();//清理一下PC容器,防止数据多次重置存储
  3.         RsqBar(sPeriod, sInst);//申请策略运行面板设置的品种周期数据
  4.         //下面是迭代和遍历取所需数据
  5.         map<string, TKVALUE>::iterator it;
  6.         for (it = mapK[sPeriod][sInst].begin(); it != mapK[sPeriod][sInst].end(); it++)
  7.         {
  8.                 pc.push_back(it->second.dClose);
  9.         }

  10.         vector<double>smavector5, smavector8, smavector13;
  11.         smavector8 = SmoothedAverageseries(pc, Teeth);//红线
  12.         smavector5 = SmoothedAverageseries(pc, Lips);//绿线
  13.         smavector13 = SmoothedAverageseries(pc, Jaws);//蓝线
  14.          /////////////////////////////////////////////////////////////鳄鱼线设计//////////////////////////////////////////////////////
  15.        
  16.          //进场突破周期及上下沿横构造
  17.         topband = highestref(sPeriod, sInst, breaklength, 1);
  18.         lowband = lowestref(sPeriod, sInst, breaklength, 1);
  19.         //进场突破周期及上下沿横构造

  20.         //输出鳄鱼线及进场点
  21.         InsertLog("  Teeth(红线): " + to_string(smavector5[smavector5.size() - 6]) + " Lips(绿线): " + to_string(smavector8[smavector8.size() - 4]) + " Jaws(蓝线): " + to_string(smavector13[smavector13.size() - 9]) + " 买突破价: " + to_string(topband) + " 卖突破价: " + to_string(lowband));
  22.         //输出鳄鱼线及进场点
复制代码
如何访问权限为100/255贴子:/thread-37840-1-1.html;注册后仍无法回复:/thread-23-1-1.html;微信/QQ群:/thread-262-1-1.html;网盘链接失效解决办法:/thread-93307-1-1.html

TOP

进入核心模块:遵循先平仓后开仓原则:
  1.         ////////////////////////////////////////////////////进出条件设计///////////////////////////////////////////////////////////
  2.         buycond = smavector5[smavector5.size() - 6] > smavector8[smavector8.size() - 4] && smavector8[smavector8.size() - 4] > smavector13[smavector13.size() - 9];//lips > teeth > jaws
  3.         sellcond = smavector5[smavector5.size() - 6] < smavector8[smavector8.size() - 4] && smavector8[smavector8.size() - 4] < smavector13[smavector13.size() - 9];//jaws > teeth > lips
  4.         ////////////////////////////////////////////////////进出条件设计///////////////////////////////////////////////////////////
  5.        
  6.         //Bar模式下策略核心模块(注意先平仓后开仓)

  7.         /////////////////////////////////////////////////////////bar出场模块开始///////////////////////////////////////////////////
  8.         //(3)最新价小于下沿,持有多单进行平仓模块(sell model)默认出场方式
  9.         if (mapMd[sInst].LastPrice < lowband && fx == 1 && cscc == 0)
  10.         {
  11.                 fx = 0;
  12.                 map<string, double>::iterator it;
  13.                 for (it = mapSub.begin(); it != mapSub.end(); it++)
  14.                 {
  15.                         int sl = (int)(ss * it->second);
  16.                         if (yxpc == 0)
  17.                         {
  18.                                 closesell1(it->first, sInst, sl, mapMd[sInst].AskPrice1 - hd * mapInstrument[sInst].PriceTick);//卖出平仓,优先平昨仓
  19.                         }
  20.                         else if (yxpc == 1)
  21.                         {
  22.                                 closesell2(it->first, sInst, sl, mapMd[sInst].AskPrice1 - hd * mapInstrument[sInst].PriceTick);//卖出平仓,优先平今仓
  23.                         }
  24.                         string s = it->first + "  多单跌破鳄鱼法则交易系统下沿达到出场条件卖出平仓  " + to_string(sl) + "  手, 价格  " + to_string(mapMd[sInst].BidPrice1 - hd * mapInstrument[sInst].PriceTick) + "  基础手数  " + to_string(ss) + "  手";
  25.                         maps[num] = s;
  26.                         num++;
  27.                 }
  28.                 if (num != 0)shuchurizhi();
  29.                 tm = 0;
  30.                 xieruzhuangtai();
  31.         }
  32.         //(4)最新价大于上沿,持有空单进行平仓模块(buytocover model)默认出场方式
  33.         if (mapMd[sInst].LastPrice > topband && fx == -1 && cscc == 0)
  34.         {
  35.                 fx = 0;
  36.                 map<string, double>::iterator it;
  37.                 for (it = mapSub.begin(); it != mapSub.end(); it++)
  38.                 {
  39.                         int sl = (int)(ss * it->second);
  40.                         if (yxpc == 0)
  41.                         {
  42.                                 closebuy1(it->first, sInst, sl, mapMd[sInst].BidPrice1 + hd * mapInstrument[sInst].PriceTick); //买入平仓,优先平昨仓
  43.                         }
  44.                         else if (yxpc == 1)
  45.                         {
  46.                                 closebuy2(it->first, sInst, sl, mapMd[sInst].BidPrice1 + hd * mapInstrument[sInst].PriceTick); //买入平仓,优先平今仓
  47.                         }
  48.                         string s = it->first + "  空单涨破鳄鱼法则交易系统上沿达到出场条件买入平仓  " + to_string(sl) + "  手, 价格  " + to_string(mapMd[sInst].AskPrice1 + hd * mapInstrument[sInst].PriceTick) + "  基础手数  " + to_string(ss) + "  手";
  49.                         maps[num] = s;
  50.                         num++;
  51.                 }
  52.                 if (num != 0)shuchurizhi();
  53.                 tm = 0;
  54.                 xieruzhuangtai();
  55.         }
  56.         ////////////////////////////////////////////////////////////////////////////////////交易系统默认自带出场模块////////////////////////////////

  57.         //////////////////////////////////////////////////////////////////////////////策略重启遗留持仓处理模块//////////////////////////////////////
  58.         if (cscc != 0)//遗留持仓处理检测
  59.         {
  60.                 //(5)最新价小于下沿,持有多单进行平仓模块(sell model)[处理遗留持仓之多单]默认出场方式
  61.                 if (mapMd[sInst].LastPrice < lowband && fx == 1 && cscc > 0)
  62.                 {
  63.                         fx = 0;
  64.                         cscc = 0;
  65.                         map<string, double>::iterator it;
  66.                         for (it = mapSub.begin(); it != mapSub.end(); it++)
  67.                         {
  68.                                 int sl = ss;
  69.                                 if (yxpc == 0)
  70.                                 {
  71.                                         closesell1(it->first, sInst, sl, mapMd[sInst].AskPrice1 - hd * mapInstrument[sInst].PriceTick);//卖出平仓,优先平昨仓
  72.                                 }
  73.                                 else if (yxpc == 1)
  74.                                 {
  75.                                         closesell2(it->first, sInst, sl, mapMd[sInst].AskPrice1 - hd * mapInstrument[sInst].PriceTick);//卖出平仓,优先平今仓
  76.                                 }
  77.                                 string s = it->first + "  遗留多单跌破鳄鱼法则交易系统下沿达到出场条件卖出平仓  " + to_string(sl) + "  手,价格  " + to_string(mapMd[sInst].BidPrice1 - hd * mapInstrument[sInst].PriceTick) + "  基础手数  " + to_string(ss) + "  手";
  78.                                 maps[num] = s;
  79.                                 num++;
  80.                         }
  81.                         if (num != 0)shuchurizhi();
  82.                         tm = 0;
  83.                         xieruzhuangtai();
  84.                 }
  85.                 //(6)最新价大于上沿,持有空单进行平仓模块(buytocover model)[处理遗留持仓之空单]默认出场方式
  86.                 if (mapMd[sInst].LastPrice > topband && fx == -1 && cscc < 0)
  87.                 {
  88.                         fx = 0;
  89.                         cscc = 0;
  90.                         map<string, double>::iterator it;
  91.                         for (it = mapSub.begin(); it != mapSub.end(); it++)
  92.                         {
  93.                                 int sl = ss;
  94.                                 if (yxpc == 0)
  95.                                 {
  96.                                         closebuy1(it->first, sInst, sl, mapMd[sInst].BidPrice1 + hd * mapInstrument[sInst].PriceTick); //买入平仓,优先平昨仓
  97.                                 }
  98.                                 else if (yxpc == 1)
  99.                                 {
  100.                                         closebuy2(it->first, sInst, sl, mapMd[sInst].BidPrice1 + hd * mapInstrument[sInst].PriceTick); //买入平仓,优先平今仓
  101.                                 }
  102.                                 string s = it->first + "  遗留空单涨破鳄鱼法则交易系统上沿达到出场条件买入平仓  " + to_string(sl) + "  手,价格  " + to_string(mapMd[sInst].AskPrice1 + hd * mapInstrument[sInst].PriceTick) + "  基础手数  " + to_string(ss) + "  手";
  103.                                 maps[num] = s;
  104.                                 num++;
  105.                         }
  106.                         if (num != 0)shuchurizhi();
  107.                         tm = 0;
  108.                         xieruzhuangtai();
  109.                 }
  110.         }
  111.         /////////////////////////////////////////////////////////bar出场模块结束///////////////////////////////////////////////////
  112.                
  113.         /////////////////////////////////////////////////////////bar入场模块///////////////////////////////////////////////////
  114.        
  115.         //(1)最新价小于下沿,无持仓进行卖出开仓模块(sell short model)
  116.         if (mapMd[sInst].LastPrice < lowband && sellcond && fx == 0 && cscc == 0)
  117.                 {
  118.                         fx = -1;
  119.                         ss = lots;
  120.                         map<string, double>::iterator it;
  121.                         for (it = mapSub.begin(); it != mapSub.end(); it++)
  122.                         {
  123.                                 int sl = (int)(ss * it->second);
  124.                                 OrderInsert(it->first, sInst, '1', '0', sl, mapMd[sInst].AskPrice1 - hd * mapInstrument[sInst].PriceTick, "", "");//卖出开仓语句
  125.                                 string s = it->first + "  突破鳄鱼法则交易系统下沿达到入场条件卖出开仓  " + to_string(sl) + "  手,价格  " + to_string(mapMd[sInst].AskPrice1 - hd * mapInstrument[sInst].PriceTick) + "  基础手数  " + to_string(ss) + "  手";
  126.                                 maps[num] = s;
  127.                                 num++;
  128.                         }
  129.                         if (num != 0)shuchurizhi();
  130.                         tm = 0;
  131.                         xieruzhuangtai();
  132.             }
  133.                 //(2)最新价大于上沿,无持仓进行买入开仓模块(buy long model)
  134.                 if (mapMd[sInst].LastPrice > topband && buycond && fx == 0 && cscc == 0)
  135.                 {
  136.                         fx = 1;
  137.                         ss = lots;
  138.                         map<string, double>::iterator it;
  139.                         for (it = mapSub.begin(); it != mapSub.end(); it++)
  140.                         {
  141.                                 int sl = (int)(ss * it->second);
  142.                                 OrderInsert(it->first, sInst, '0', '0', sl, mapMd[sInst].BidPrice1 + hd * mapInstrument[sInst].PriceTick, "", "");//买入开仓语句
  143.                                 string s = it->first + "  突破鳄鱼法则交易系统上沿达到入场条件买入开仓  " + to_string(sl) + "  手,价格  " + to_string(mapMd[sInst].BidPrice1 + hd * mapInstrument[sInst].PriceTick) + "  基础手数  " + to_string(ss) + "  手";
  144.                                 maps[num] = s;
  145.                                 num++;
  146.                         }
  147.                         if (num != 0)shuchurizhi();
  148.                         tm = 0;
  149.                         xieruzhuangtai();
  150.                 }
  151. /////////////////////////////////////////////////////////bar入场模块///////////////////////////////////////////////////
复制代码
如何访问权限为100/255贴子:/thread-37840-1-1.html;注册后仍无法回复:/thread-23-1-1.html;微信/QQ群:/thread-262-1-1.html;网盘链接失效解决办法:/thread-93307-1-1.html

TOP

这里关键是“SmoothedAverageseries”这个函数的设计,函数设计参考:http://www.qhlt.cn/thread-163882-1-1.html
如何访问权限为100/255贴子:/thread-37840-1-1.html;注册后仍无法回复:/thread-23-1-1.html;微信/QQ群:/thread-262-1-1.html;网盘链接失效解决办法:/thread-93307-1-1.html

TOP

我将在五一过后通过盘中进行调试。到时更新第一时间上传。
如何访问权限为100/255贴子:/thread-37840-1-1.html;注册后仍无法回复:/thread-23-1-1.html;微信/QQ群:/thread-262-1-1.html;网盘链接失效解决办法:/thread-93307-1-1.html

TOP

返回列表