1 Star 0 Fork 4

sunwy/mql4

forked from 航耍耍/mql4 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
俄罗斯加码.mq4 14.91 KB
一键复制 编辑 原始数据 按行查看 历史
航耍耍 提交于 2021-11-09 08:24 . 123123123123
#property copyright "中国自动化交易联盟-红之汇著"
#property link "QQ:712933993"
extern string Name = "++++++++ Calypso ver 1.04 ++++++++";
extern string Cop = "+++ Copyright ?2010, winzfx.com +++";
extern string no = "";
extern string n1 = "输入选项";
double gd_108 = 0.01;
extern string n8 = "最大手数";
extern double Dinamic_lot = 10.0;
extern string n9 = "保护仓位";
extern bool lv_mode = FALSE;
extern int Level_stop = 0;
extern string n3 = "列入停止";
extern bool sm_mode = FALSE;
extern int stop = 25;
extern string n4 = "最大订单";
extern int sn_mode = 50;
extern string n5 = "之间订单";
extern int sh_mode = 50;
extern string n6 = "共融的乘法";
extern bool st_mode = TRUE;
extern double sk_mode = 2.0;
extern string n7 = "共享反向";
extern bool sr_mode = TRUE;
int gi_unused_220 = 0;
int g_magic_224 = 59999;
int gi_228 = 24;
int g_pos_232;
datetime g_time_236;
string g_symbol_240;
double g_ima_248;
double g_ima_256;
double gd_264;
void ads() {
SetLab("ads01", 20, 25, 3, "中国自动化交易联盟-红之汇著", 11, "宋体", Lime);
SetLab("ads02", 1, 10, 3, "QQ:712933993 ", 11, "Arial", Aqua);
}
void SetLab(string a_name_0, int a_x_8, int a_y_12, int a_corner_16, string a_text_20, int a_fontsize_28, string a_fontname_32, color a_color_40 = -1) {
ObjectCreate(a_name_0, OBJ_LABEL, 0, 0, 0);
ObjectSet(a_name_0, OBJPROP_XDISTANCE, a_x_8);
ObjectSet(a_name_0, OBJPROP_YDISTANCE, a_y_12);
ObjectSet(a_name_0, OBJPROP_CORNER, a_corner_16);
ObjectSetText(a_name_0, a_text_20, a_fontsize_28, a_fontname_32, a_color_40);
}
double setpoint() {
double ld_ret_0;
if (Digits <= 3) ld_ret_0 = 0.01;
else ld_ret_0 = 0.0001;
return (ld_ret_0);
}
int start() {
double ld_0;
double ld_8;
double l_ord_open_price_16;
double l_ord_open_price_24;
double l_minlot_32;
double l_marginrequired_40;
double ld_48;
int li_56;
double ld_60;
int l_count_68;
bool li_72;
bool li_76;
int l_count_80;
int l_count_84;
int l_count_88;
double ld_92;
double l_minlot_100;
double ld_108;
double ld_116;
double ld_124;
double ld_132;
int l_error_140;
int li_144;
string ls_148;
string ls_156;
string ls_164;
string ls_172;
ads();
HideTestIndicators(TRUE);
g_ima_256 = iMA(Symbol(), 0, 3, 0, MODE_LWMA, PRICE_MEDIAN, 0);
g_ima_248 = iMA(Symbol(), 0, 3, 0, MODE_LWMA, PRICE_MEDIAN, 1);
HideTestIndicators(FALSE);
if (IsTradeAllowed()) {
if (Time[0] == g_time_236) return (0);
g_time_236 = Time[0];
g_symbol_240 = Symbol();
ld_0 = NormalizeDouble(Ask, Digits);
ld_8 = NormalizeDouble(Bid, Digits);
l_ord_open_price_16 = 0;
l_ord_open_price_24 = 0;
l_minlot_32 = MarketInfo(g_symbol_240, MODE_MINLOT);
l_marginrequired_40 = MarketInfo(Symbol(), MODE_MARGINREQUIRED);
ld_48 = l_minlot_32;
for (double ld_180 = 0; ld_48 < 1.0; ld_180++) ld_48 = 10.0 * ld_48;
li_56 = OrdersTotal() - 1;
if (lv_mode == TRUE) {
if (AccountBalance() - AccountBalance() * Level_stop / 100.0 > AccountEquity()) {
for (int l_pos_188 = li_56; l_pos_188 >= 0; l_pos_188--) {
OrderSelect(l_pos_188, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == g_magic_224 && OrderSymbol() == g_symbol_240) {
if (OrderType() == OP_BUY) CloseBuy();
if (OrderType() == OP_SELL) CloseSell();
}
}
}
}
ld_60 = 0;
l_count_68 = 0;
li_72 = TRUE;
li_76 = TRUE;
for (l_pos_188 = li_56; l_pos_188 >= 0; l_pos_188--) {
OrderSelect(l_pos_188, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == g_magic_224 && OrderSymbol() == g_symbol_240) l_count_68++;
}
if (l_count_68 >= sn_mode) li_72 = FALSE;
l_count_80 = 0;
l_count_84 = 0;
l_count_88 = 0;
ld_92 = gd_108;
l_minlot_100 = gd_108;
ld_108 = 0;
ld_116 = 0;
ld_124 = 0;
for (l_pos_188 = li_56; l_pos_188 >= 0; l_pos_188--) {
OrderSelect(l_pos_188, SELECT_BY_POS, MODE_TRADES);
if (OrderType() == OP_BUY && OrderMagicNumber() == g_magic_224 && OrderSymbol() == g_symbol_240) {
ld_60 = OrderProfit() + OrderSwap() + ld_60;
ld_108 += OrderLots();
l_ord_open_price_16 = OrderOpenPrice();
l_count_88++;
if (MathAbs(l_ord_open_price_16 - ld_0) < sh_mode * setpoint()) l_count_80++;
if (l_ord_open_price_16 - ld_0 > sh_mode * setpoint()) l_count_84++;
if (ld_0 < l_ord_open_price_16) ld_116++;
if (OrderLots() > ld_92) ld_92 = OrderLots();
}
}
ld_108 /= 2.0;
if (l_count_80 != 0) li_76 = FALSE;
ld_92 = l_minlot_32;
if (l_count_88 == 0) {
l_minlot_100 = NormalizeDouble(AccountFreeMargin() * Dinamic_lot / 1000.0 / MarketInfo(Symbol(), MODE_MARGINREQUIRED), ld_180);
if (l_minlot_100 < l_minlot_32) l_minlot_100 = l_minlot_32;
}
if (l_count_84 == l_count_88 && l_count_88 != 0 && ld_116 == l_count_88) {
if (st_mode == TRUE) {
for (l_pos_188 = li_56; l_pos_188 >= 0; l_pos_188--) {
OrderSelect(l_pos_188, SELECT_BY_POS, MODE_TRADES);
if (OrderType() == OP_BUY && OrderMagicNumber() == g_magic_224 && OrderSymbol() == g_symbol_240)
if (OrderLots() > ld_92) ld_92 = OrderLots();
}
l_minlot_100 = NormalizeDouble(ld_92 * sk_mode, ld_180);
}
}
if (ld_60 >= l_marginrequired_40 * ld_108) {
li_56 = OrdersTotal() - 1;
for (l_pos_188 = li_56; l_pos_188 >= 0; l_pos_188--) {
OrderSelect(l_pos_188, SELECT_BY_POS, MODE_TRADES);
RefreshRates();
if (OrderType() == OP_BUY && OrderMagicNumber() == g_magic_224 && OrderSymbol() == g_symbol_240) {
if (IsTesting() || IsOptimization()) OrderClose(OrderTicket(), OrderLots(), MarketInfo(g_symbol_240, MODE_BID), 3, Blue);
else CloseBuy();
}
}
}
if (sr_mode == FALSE) gd_264 = iHighest(g_symbol_240, 0, MODE_HIGH, gi_228, 0);
else gd_264 = iLowest(g_symbol_240, 0, MODE_LOW, gi_228, 0);
if (gd_264 == 1.0 || gd_264 == 2.0 || gd_264 == 3.0 && g_ima_256 > g_ima_248 && li_72 == TRUE && li_76 == TRUE) {
RefreshRates();
if (IsTesting() || IsOptimization()) OrderSend(g_symbol_240, OP_BUY, l_minlot_100, NormalizeDouble(MarketInfo(g_symbol_240, MODE_ASK), Digits), 3, 0, 0, "Calypso ver 1.04", g_magic_224, 0, Blue);
else OpenBuy(g_symbol_240, l_minlot_100);
}
ld_132 = 0;
li_76 = TRUE;
l_count_80 = 0;
l_count_84 = 0;
l_count_88 = 0;
ld_92 = gd_108;
l_minlot_100 = gd_108;
ld_60 = 0;
li_56 = OrdersTotal() - 1;
for (l_pos_188 = li_56; l_pos_188 >= 0; l_pos_188--) {
OrderSelect(l_pos_188, SELECT_BY_POS, MODE_TRADES);
if (OrderType() == OP_SELL && OrderMagicNumber() == g_magic_224 && OrderSymbol() == g_symbol_240) {
ld_60 = OrderProfit() + OrderSwap() + ld_60;
ld_132 += OrderLots();
l_ord_open_price_24 = OrderOpenPrice();
l_count_88++;
if (MathAbs(l_ord_open_price_24 - ld_8) < sh_mode * setpoint()) l_count_80++;
if (ld_8 - l_ord_open_price_24 > sh_mode * setpoint()) l_count_84++;
if (ld_8 > l_ord_open_price_24) ld_124++;
if (OrderLots() > ld_92) ld_92 = OrderLots();
}
}
ld_132 /= 2.0;
if (l_count_80 != 0) li_76 = FALSE;
ld_92 = l_minlot_32;
if (l_count_88 == 0) {
l_minlot_100 = NormalizeDouble(AccountFreeMargin() * Dinamic_lot / 1000.0 / MarketInfo(Symbol(), MODE_MARGINREQUIRED), ld_180);
if (l_minlot_100 < l_minlot_32) l_minlot_100 = l_minlot_32;
}
if (l_count_84 == l_count_88 && l_count_88 != 0 && ld_124 == l_count_88) {
if (st_mode == TRUE) {
for (l_pos_188 = li_56; l_pos_188 >= 0; l_pos_188--) {
OrderSelect(l_pos_188, SELECT_BY_POS, MODE_TRADES);
if (OrderType() == OP_SELL && OrderMagicNumber() == g_magic_224 && OrderSymbol() == g_symbol_240)
if (OrderLots() > ld_92) ld_92 = OrderLots();
}
l_minlot_100 = NormalizeDouble(ld_92 * sk_mode, ld_180);
}
}
if (ld_60 >= l_marginrequired_40 * ld_132) {
li_56 = OrdersTotal() - 1;
for (l_pos_188 = li_56; l_pos_188 >= 0; l_pos_188--) {
OrderSelect(l_pos_188, SELECT_BY_POS, MODE_TRADES);
RefreshRates();
if (OrderType() == OP_SELL && OrderMagicNumber() == g_magic_224 && OrderSymbol() == g_symbol_240) {
if (IsTesting() || IsOptimization()) OrderClose(OrderTicket(), OrderLots(), MarketInfo(g_symbol_240, MODE_ASK), 3, Fuchsia);
else CloseSell();
}
}
}
if (sr_mode == FALSE) gd_264 = iLowest(g_symbol_240, 0, MODE_LOW, gi_228, 0);
else gd_264 = iHighest(g_symbol_240, 0, MODE_HIGH, gi_228, 0);
if (gd_264 == 1.0 || gd_264 == 2.0 || gd_264 == 3.0 && g_ima_256 < g_ima_248 && li_72 == TRUE && li_76 == TRUE) {
RefreshRates();
if (IsTesting() || IsOptimization()) OrderSend(g_symbol_240, OP_SELL, l_minlot_100, NormalizeDouble(MarketInfo(g_symbol_240, MODE_BID), Digits), 3, 0, 0, "Calypso ver 1.04", g_magic_224, 0, Fuchsia);
else OpenSell(g_symbol_240, l_minlot_100);
}
g_symbol_240 = Symbol();
l_error_140 = 0;
if (sm_mode == TRUE) {
if (stop < MarketInfo(g_symbol_240, MODE_STOPLEVEL)) stop = MarketInfo(g_symbol_240, MODE_STOPLEVEL);
for (g_pos_232 = 0; g_pos_232 <= OrdersTotal() - 1; g_pos_232++) {
OrderSelect(g_pos_232, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == g_magic_224 && OrderStopLoss() == 0.0 && OrderSymbol() == Symbol()) {
while (li_144 <= 10) {
OrderModify(OrderTicket(), 0, MarketInfo(g_symbol_240, MODE_ASK) - stop * setpoint(), 0, 0, C'0x02,0x00,0x00');
l_error_140 = GetLastError();
if (l_error_140 == 0/* NO_ERROR */) {
Print("买成功");
break;
}
Print("我不能修改,买失败 " + GetLastError());
RefreshRates();
Sleep(5000);
li_144++;
}
Print("-----ERROR----- 我不能修改买订单");
return (l_error_140);
}
}
}
} else Comment("交易禁止");
if (sm_mode == TRUE) ls_148 = "停止列入?狂欢?" + stop + " 项目";
else ls_148 = "站下车";
if (st_mode == TRUE) ls_156 = "多元化?地段内?呢?" + DoubleToStr(sk_mode, ld_180);
else ls_156 = "多元化?地段关闭";
if (sr_mode == TRUE) ls_164 = "反向纳入";
else ls_164 = "反向关";
if (lv_mode == TRUE) ls_172 = "保护支撑高度?呢?设定在" + DoubleToStr(Level_stop, 0);
else ls_172 = "保护支撑高度?关闭";
Comment(""
+ "\n"
+ " Calypso ver. 1.04"
+ "\n"
+ " forex-shop.net"
+ "\n"
+ "_________________________________________"
+ "\n"
+ "\n"
+ "杠杆 1:" + DoubleToStr(AccountLeverage(), 0)
+ "\n"
+ "帐户 " + DoubleToStr(AccountNumber(), 0)
+ "\n"
+ "时间服务器 " + TimeToStr(TimeCurrent(), TIME_SECONDS)
+ "\n"
+ "平衡 " + DoubleToStr(AccountBalance(), 0)
+ "\n"
+ "等效 " + DoubleToStr(AccountEquity(), 0)
+ "\n"
+ "_________________________________________"
+ "\n"
+ "我们的目标?外币存款买" + DoubleToStr(ld_108 * l_marginrequired_40, ld_180) + "$"
+ "\n"
+ "我们的目标?货币存款卖" + DoubleToStr(ld_132 * l_marginrequired_40, ld_180) + "$"
+ "\n"
+ "本地动态?设置为 " + DoubleToStr(Dinamic_lot, ld_180) + "%"
+ "\n"
+ ls_172
+ "\n"
+ ls_148
+ "\n"
+ "最大数量?订单? " + sn_mode
+ "\n"
+ "沙?呼?订单? " + sh_mode + " 第"
+ "\n"
+ ls_156
+ "\n"
+ ls_164
+ "\n"
+ "_________________________________________");
return (0);
}
int OpenBuy(string a_symbol_0, double a_lots_8) {
int l_ticket_16;
int l_slippage_20;
int li_24 = 1;
while (true) {
l_slippage_20 = 1;
l_ticket_16 = OrderSend(a_symbol_0, OP_BUY, a_lots_8, NormalizeDouble(MarketInfo(a_symbol_0, MODE_ASK), Digits), l_slippage_20, 0, 0, "Calypso ver 1.04", g_magic_224, 0, Blue);
if (l_ticket_16 <= 0) {
Print("我无法打开?部落?购买。错误?", GetLastError());
while (RefreshRates() == FALSE) Sleep(5000);
li_24++;
if (li_24 % 5 == 0) l_slippage_20++;
} else {
Print("部落?购买成功打开?");
break;
}
if (li_24 != 11) continue;
Comment("我无法打开?部落?买一个符号?", a_symbol_0, " 错误", GetLastError());
break;
}
return (0);
}
int OpenSell(string a_symbol_0, double a_lots_8) {
int l_ticket_16;
int l_slippage_20;
int li_24 = 1;
while (true) {
l_slippage_20 = 1;
l_ticket_16 = OrderSend(a_symbol_0, OP_SELL, a_lots_8, NormalizeDouble(MarketInfo(a_symbol_0, MODE_BID), Digits), l_slippage_20, 0, 0, "Calypso ver 1.04", g_magic_224, 0, Fuchsia);
if (l_ticket_16 <= 0) {
Print("我无法打开?部落?卖。错误?", GetLastError());
while (RefreshRates() == FALSE) Sleep(5000);
li_24++;
if (li_24 % 5 == 0) l_slippage_20++;
} else {
Print("部落?卖成功打开?");
break;
}
if (li_24 != 11) continue;
Comment("我无法打开?部落?卖的性格吗?", a_symbol_0, " 错误", GetLastError());
break;
}
return (0);
}
void CloseBuy() {
int l_error_0;
int l_count_4 = 0;
while (true) {
OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(MarketInfo(OrderSymbol(), MODE_BID), Digits), 2, White);
l_error_0 = GetLastError();
if (l_error_0 == 0/* NO_ERROR */) {
Print("关闭购买。部落?“巴?成功关闭");
return;
}
Print("我无法打开?部落?买一个符号?", Symbol(), " 错误", GetLastError());
Sleep(500);
RefreshRates();
l_count_4++;
if (l_count_4 <= 25) continue;
break;
}
Alert("Order failed to CLOSE - See Journal for errors");
}
void CloseSell() {
int l_error_0;
int l_count_4 = 0;
while (true) {
OrderClose(OrderTicket(), OrderLots(), NormalizeDouble(MarketInfo(OrderSymbol(), MODE_ASK), Digits), 2, Red);
l_error_0 = GetLastError();
if (l_error_0 == 0/* NO_ERROR */) {
Print("关闭卖。部落?卖成功关闭");
return;
}
Print("我无法打开?部落?卖的性格吗?", Symbol(), " 错误", GetLastError());
Sleep(500);
RefreshRates();
l_count_4++;
if (l_count_4 <= 25) continue;
break;
}
Alert("订单无法关闭 - 请看杂志的错误");
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/licq201/mql4.git
[email protected]:licq201/mql4.git
licq201
mql4
mql4
master

搜索帮助