  
- UID
- 2
- 积分
- 2948020
- 威望
- 1424047 布
- 龙e币
- 1523973 刀
- 在线时间
- 13794 小时
- 注册时间
- 2009-12-3
- 最后登录
- 2025-5-1

|
进入核心模块:遵循先平仓后开仓原则:- ////////////////////////////////////////////////////进出条件设计///////////////////////////////////////////////////////////
- buycond = smavector5[smavector5.size() - 6] > smavector8[smavector8.size() - 4] && smavector8[smavector8.size() - 4] > smavector13[smavector13.size() - 9];//lips > teeth > jaws
- sellcond = smavector5[smavector5.size() - 6] < smavector8[smavector8.size() - 4] && smavector8[smavector8.size() - 4] < smavector13[smavector13.size() - 9];//jaws > teeth > lips
- ////////////////////////////////////////////////////进出条件设计///////////////////////////////////////////////////////////
-
- //Bar模式下策略核心模块(注意先平仓后开仓)
- /////////////////////////////////////////////////////////bar出场模块开始///////////////////////////////////////////////////
- //(3)最新价小于下沿,持有多单进行平仓模块(sell model)默认出场方式
- if (mapMd[sInst].LastPrice < lowband && fx == 1 && cscc == 0)
- {
- fx = 0;
- map<string, double>::iterator it;
- for (it = mapSub.begin(); it != mapSub.end(); it++)
- {
- int sl = (int)(ss * it->second);
- if (yxpc == 0)
- {
- closesell1(it->first, sInst, sl, mapMd[sInst].AskPrice1 - hd * mapInstrument[sInst].PriceTick);//卖出平仓,优先平昨仓
- }
- else if (yxpc == 1)
- {
- closesell2(it->first, sInst, sl, mapMd[sInst].AskPrice1 - hd * mapInstrument[sInst].PriceTick);//卖出平仓,优先平今仓
- }
- string s = it->first + " 多单跌破鳄鱼法则交易系统下沿达到出场条件卖出平仓 " + to_string(sl) + " 手, 价格 " + to_string(mapMd[sInst].BidPrice1 - hd * mapInstrument[sInst].PriceTick) + " 基础手数 " + to_string(ss) + " 手";
- maps[num] = s;
- num++;
- }
- if (num != 0)shuchurizhi();
- tm = 0;
- xieruzhuangtai();
- }
- //(4)最新价大于上沿,持有空单进行平仓模块(buytocover model)默认出场方式
- if (mapMd[sInst].LastPrice > topband && fx == -1 && cscc == 0)
- {
- fx = 0;
- map<string, double>::iterator it;
- for (it = mapSub.begin(); it != mapSub.end(); it++)
- {
- int sl = (int)(ss * it->second);
- if (yxpc == 0)
- {
- closebuy1(it->first, sInst, sl, mapMd[sInst].BidPrice1 + hd * mapInstrument[sInst].PriceTick); //买入平仓,优先平昨仓
- }
- else if (yxpc == 1)
- {
- closebuy2(it->first, sInst, sl, mapMd[sInst].BidPrice1 + hd * mapInstrument[sInst].PriceTick); //买入平仓,优先平今仓
- }
- string s = it->first + " 空单涨破鳄鱼法则交易系统上沿达到出场条件买入平仓 " + to_string(sl) + " 手, 价格 " + to_string(mapMd[sInst].AskPrice1 + hd * mapInstrument[sInst].PriceTick) + " 基础手数 " + to_string(ss) + " 手";
- maps[num] = s;
- num++;
- }
- if (num != 0)shuchurizhi();
- tm = 0;
- xieruzhuangtai();
- }
- ////////////////////////////////////////////////////////////////////////////////////交易系统默认自带出场模块////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////策略重启遗留持仓处理模块//////////////////////////////////////
- if (cscc != 0)//遗留持仓处理检测
- {
- //(5)最新价小于下沿,持有多单进行平仓模块(sell model)[处理遗留持仓之多单]默认出场方式
- if (mapMd[sInst].LastPrice < lowband && fx == 1 && cscc > 0)
- {
- fx = 0;
- cscc = 0;
- map<string, double>::iterator it;
- for (it = mapSub.begin(); it != mapSub.end(); it++)
- {
- int sl = ss;
- if (yxpc == 0)
- {
- closesell1(it->first, sInst, sl, mapMd[sInst].AskPrice1 - hd * mapInstrument[sInst].PriceTick);//卖出平仓,优先平昨仓
- }
- else if (yxpc == 1)
- {
- closesell2(it->first, sInst, sl, mapMd[sInst].AskPrice1 - hd * mapInstrument[sInst].PriceTick);//卖出平仓,优先平今仓
- }
- string s = it->first + " 遗留多单跌破鳄鱼法则交易系统下沿达到出场条件卖出平仓 " + to_string(sl) + " 手,价格 " + to_string(mapMd[sInst].BidPrice1 - hd * mapInstrument[sInst].PriceTick) + " 基础手数 " + to_string(ss) + " 手";
- maps[num] = s;
- num++;
- }
- if (num != 0)shuchurizhi();
- tm = 0;
- xieruzhuangtai();
- }
- //(6)最新价大于上沿,持有空单进行平仓模块(buytocover model)[处理遗留持仓之空单]默认出场方式
- if (mapMd[sInst].LastPrice > topband && fx == -1 && cscc < 0)
- {
- fx = 0;
- cscc = 0;
- map<string, double>::iterator it;
- for (it = mapSub.begin(); it != mapSub.end(); it++)
- {
- int sl = ss;
- if (yxpc == 0)
- {
- closebuy1(it->first, sInst, sl, mapMd[sInst].BidPrice1 + hd * mapInstrument[sInst].PriceTick); //买入平仓,优先平昨仓
- }
- else if (yxpc == 1)
- {
- closebuy2(it->first, sInst, sl, mapMd[sInst].BidPrice1 + hd * mapInstrument[sInst].PriceTick); //买入平仓,优先平今仓
- }
- string s = it->first + " 遗留空单涨破鳄鱼法则交易系统上沿达到出场条件买入平仓 " + to_string(sl) + " 手,价格 " + to_string(mapMd[sInst].AskPrice1 + hd * mapInstrument[sInst].PriceTick) + " 基础手数 " + to_string(ss) + " 手";
- maps[num] = s;
- num++;
- }
- if (num != 0)shuchurizhi();
- tm = 0;
- xieruzhuangtai();
- }
- }
- /////////////////////////////////////////////////////////bar出场模块结束///////////////////////////////////////////////////
-
- /////////////////////////////////////////////////////////bar入场模块///////////////////////////////////////////////////
-
- //(1)最新价小于下沿,无持仓进行卖出开仓模块(sell short model)
- if (mapMd[sInst].LastPrice < lowband && sellcond && fx == 0 && cscc == 0)
- {
- fx = -1;
- ss = lots;
- map<string, double>::iterator it;
- for (it = mapSub.begin(); it != mapSub.end(); it++)
- {
- int sl = (int)(ss * it->second);
- OrderInsert(it->first, sInst, '1', '0', sl, mapMd[sInst].AskPrice1 - hd * mapInstrument[sInst].PriceTick, "", "");//卖出开仓语句
- string s = it->first + " 突破鳄鱼法则交易系统下沿达到入场条件卖出开仓 " + to_string(sl) + " 手,价格 " + to_string(mapMd[sInst].AskPrice1 - hd * mapInstrument[sInst].PriceTick) + " 基础手数 " + to_string(ss) + " 手";
- maps[num] = s;
- num++;
- }
- if (num != 0)shuchurizhi();
- tm = 0;
- xieruzhuangtai();
- }
- //(2)最新价大于上沿,无持仓进行买入开仓模块(buy long model)
- if (mapMd[sInst].LastPrice > topband && buycond && fx == 0 && cscc == 0)
- {
- fx = 1;
- ss = lots;
- map<string, double>::iterator it;
- for (it = mapSub.begin(); it != mapSub.end(); it++)
- {
- int sl = (int)(ss * it->second);
- OrderInsert(it->first, sInst, '0', '0', sl, mapMd[sInst].BidPrice1 + hd * mapInstrument[sInst].PriceTick, "", "");//买入开仓语句
- string s = it->first + " 突破鳄鱼法则交易系统上沿达到入场条件买入开仓 " + to_string(sl) + " 手,价格 " + to_string(mapMd[sInst].BidPrice1 + hd * mapInstrument[sInst].PriceTick) + " 基础手数 " + to_string(ss) + " 手";
- maps[num] = s;
- num++;
- }
- if (num != 0)shuchurizhi();
- tm = 0;
- xieruzhuangtai();
- }
- /////////////////////////////////////////////////////////bar入场模块///////////////////////////////////////////////////
复制代码 |
|