标签:
杂谈 |
查看原文:http://www.125808047.com/?p=2020
MHDMT_EA为神龙通道系统自带的EA文件,在此提供出来,供喜欢神龙通道这套超短交易系统的朋友研究及后续研发之用。MHDMT_EA调用了系统自带的两个指标MHDMT_GRAY_BELT.ex4和MHDMT_XMA.ex4,指标文件打包在该文章结尾附件中,下载后需要先行放置到指标文件夹中。
本网收集整理智能交易EA仅为MQL4编程爱好者提供语法及相关编程技巧的学习研究之用,智能交易存在极高的风险测试请用模拟盘,请勿用于实盘。MHDMT_EA源码如下:
//+------------------------------------------------------------------+
//| MHDMT_EA.mq4 |
//| Copyright 2016, QQ:125808047 |
//+------------------------------------------------------------------+
#property copyright "www.125808047.com"
#property link "http://www.125808047.com/"
int g_magic_76 = 1;
extern double 开仓手数 = 0.1;
extern int 浮亏止损点数 = 500;
string gs_92 = "MHDMT_XMA";
string gs_unused_100 = "MHDMT_GRAY_BELT";
int g_ticket_108;
int g_ticket_112;
bool gi_116;
bool gi_120;
int gi_unused_124;
int gi_unused_128;
double gd_132;
bool gi_140;
datetime g_time_144;
datetime g_time_148;
int init() {
gi_116 = TRUE;
gi_120 = TRUE;
gi_unused_124 = 1;
gi_unused_128 = 1;
gd_132 = Point;
gi_140 = FALSE;
g_time_144 = Time[0];
g_time_148 = Time[0];
return (0);
}
int start() {
if (gi_140 == FALSE && (Digits == 3 || Digits == 5)) {
gd_132 = 10.0 * Point;
gi_140 = TRUE;
}
double ld_0 = 2.0 * iCustom(NULL, 0, gs_92, 25, 25, 3, 1, 1) - iCustom(NULL, 0, gs_92, 25, 25, 2, 1, 1);
int li_8 = 2.0 * iCustom(NULL, 0, gs_92, 25, 25, 2, 1, 1) - iCustom(NULL, 0, gs_92, 25, 25, 3, 1, 1);
for (int pos_12 = 0; pos_12 < OrdersTotal(); pos_12++) {
if (OrderSelect(pos_12, SELECT_BY_POS, MODE_TRADES) == FALSE) break;
if (OrderMagicNumber() != g_magic_76 || OrderSymbol() != Symbol()) continue;
if (OrderType() == OP_BUY)
if (High[1] > li_8) bool cg = OrderClose(OrderTicket(), OrderLots(), Bid, 3, White);
if (OrderType() == OP_SELL)
if (Low[1] < ld_0) cg = OrderClose(OrderTicket(), OrderLots(), Ask, 3, White);
}
if ((f0_0() == 1 && f0_1(g_magic_76) == 0 && g_time_144 != Time[0]) || (!gi_116)) {
g_ticket_108 = OrderSend(Symbol(), OP_BUY, 开仓手数, Ask, 3, Ask - 浮亏止损点数 * gd_132, 0, "", g_magic_76,
0, Blue);
if (g_ticket_108 > 0) {
gi_116 = TRUE;
g_time_144 = Time[0];
if (OrderSelect(g_ticket_108, SELECT_BY_TICKET, MODE_TRADES)) Print("BUY order opened : ",
OrderOpenPrice());
} else {
gi_116 = FALSE;
Print("Error opening BUY order : ", GetLastError());
}
}
if ((f0_0() == -1 && f0_2(g_magic_76) == 0 && g_time_148 != Time[0]) || (!gi_120)) {
g_ticket_112 = OrderSend(Symbol(), OP_SELL, 开仓手数, Bid, 3, Bid + 浮亏止损点数 * gd_132, 0, "",
g_magic_76, 0, Red);
if (g_ticket_112 > 0) {
gi_120 = TRUE;
g_time_148 = Time[0];
if (OrderSelect(g_ticket_112, SELECT_BY_TICKET, MODE_TRADES)) Print("Sell order opened : ",
OrderOpenPrice());
} else {
gi_120 = FALSE;
Print("Error opening SELL order : ", GetLastError());
}
}
return (0);
}
int f0_1(int a_magic_0) {
int count_4 = 0;
for (int pos_8 = 0; pos_8 < OrdersTotal(); pos_8++) {
if (OrderSelect(pos_8, SELECT_BY_POS, MODE_TRADES) == FALSE) break;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == a_magic_0)
if (OrderType() == OP_BUY) count_4++;
}
return (count_4);
}
int f0_2(int a_magic_0) {
int count_4 = 0;
for (int pos_8 = 0; pos_8 < OrdersTotal(); pos_8++) {
if (OrderSelect(pos_8, SELECT_BY_POS, MODE_TRADES) == FALSE) break;
if (OrderSymbol() == Symbol() && OrderMagicNumber() == a_magic_0)
if (OrderType() == OP_SELL) count_4++;
}
return (count_4);
}
int f0_0() {
int count_0 = 0;
int count_4 = 0;
int li_ret_8 = 0;
for (int li_12 = 1; High[li_12] > 2.0 * iCustom(NULL, 0, gs_92, 25, 25, 2, 1, li_12) - iCustom(NULL, 0,
gs_92, 25, 25, 3, 1, li_12); li_12++) count_0++;
for (li_12 = 1; Low[li_12] < 2.0 * iCustom(NULL, 0, gs_92, 25, 25, 3, 1, li_12) - iCustom(NULL, 0,
gs_92, 25, 25, 2, 1, li_12); li_12++) count_4++;
if (count_0 == 1) li_ret_8 = -1;
if (count_4 == 1) li_ret_8 = 1;
return (li_ret_8);
}
[download id="14"]

加载中…