反向跟单EAMT4
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#property copyright "由联邦基金提供QQ:462079360"
#property link "/"
extern string 是否跟注释参数= "如果跟就选择true,不跟就选择false";
extern bool 是否跟注释= TRUE;
extern string 是否跟挂单参数= "如果跟就选择true,不跟就选择false";
extern bool 是否跟挂单= TRUE;
extern bool 是否跟修改定单= TRUE;
extern bool 是否最优价跟单= FALSE;
double gd_108 = 0.0;
extern string temp1 = "----------------------------------";
extern string 跟单下单量类型参数= "1 为固定下单量, 2为缩放下单量, 3为资金比例"; extern int 跟单下单量类型= 2;
extern double 固定下单量= 0.1;
extern string 缩放倍数参数= "下单量缩放倍数= 跟单手数/喊单手数";
extern double 下单量缩放倍数= 1.0;
extern string 资金比例参数= "资金比例:1000下1标准手为100%";
extern double 资金比例= 10.0;
extern string temp2 = "----------------------------------";
extern string 是否有黄金商品参数= "如果有就选择true,否则选择false";
extern bool 是否有黄金商品= TRUE;
extern string 喊单帐户黄金商品名称参数= "黄金商品名称如GOLD ,XAUUSD ,SPT_GLD 等等注意字母必须是大写";
extern string 喊单帐户黄金商品名称= "XAUUSD";
extern string 跟单帐户黄金商品名称= "XAUUSD";
int gia_220[];
bool gi_224;
double gd_228;
double g_lotstep_236;
double gd_244;
double gd_252;
int g_slippage_260 = 10;
int g_slippage_264 = 10;
int gi_268;
string gs_272;
string gs_280;
int gia_288[];
int gi_292;
int gi_296;
double gd_300;
double gd_308;
bool gi_316;
int g_file_320;
int g_count_324;
int g_index_328;
int g_index_332;
int g_index_336;
double gd_340;
double gda_348[];
double gd_352;
double g_price_360;
double gda_368[];
double gd_372;
double gd_380;
double g_price_388;
double gda_396[];
double gd_400;
double gda_408[];
string gsa_412[];
string gs_416;
string gs_424;
string gsa_432[];
double g_ask_436;
double g_bid_444;
double gd_452;
double g_point_460;
double gd_468;
double gd_476;
double gd_484;
bool g_bool_492;
bool gi_496;
bool g_bool_500;
bool gi_504;
bool gi_508;
bool g_bool_512;
bool g_bool_516;
bool g_bool_520;
int gi_524;
string gs_528 = "";
string gs_536 = "";
string gs_544 = "";
void init() {
gd_484 = gd_108;
g_bool_500 = 是否最优价跟单;
gd_228 = 下单量缩放倍数;
gs_536 = 喊单帐户黄金商品名称;
gs_528 = 跟单帐户黄金商品名称;
gi_524 = 跟单下单量类型;
g_bool_492 = 是否跟修改定单;
g_bool_512 = 是否有黄金商品;
g_bool_516 = 是否跟注释;
g_bool_520 = 是否跟挂单;
ArrayResize(gsa_412, 100);
ArrayResize(gia_288, 100);
ArrayResize(gda_408, 100);
ArrayResize(gda_348, 100);
ArrayResize(gda_368, 100);
ArrayResize(gda_396, 100);
ArrayResize(gia_220, 100);
for (g_count_324 = 0; g_count_324 < 100; g_count_324++) { gsa_412[g_index_332] = "";
gia_288[g_index_332] = 0;
gda_408[g_index_332] = 0;
gda_348[g_index_332] = 0;
gda_368[g_index_332] = 0;
gda_396[g_index_332] = 0;
gia_220[g_index_332] = 0;
}
if (Digits == 3 || Digits == 5) {
g_slippage_260 = 10 * g_slippage_260;
g_slippage_264 = 10 * g_slippage_264;
gd_484 = 10.0 * gd_484;
}
if (g_bool_500) g_slippage_264 = 0;
gi_296 = StringLen(Symbol()) - 6;
if (gi_296 > 0) gs_544 = StringSubstr(Symbol(), 6, gi_296);
g_lotstep_236 = MarketInfo(Symbol(), MODE_LOTSTEP);
gd_244 = MarketInfo(Symbol(), MODE_MINLOT);
gd_252 = MarketInfo(Symbol(), MODE_MAXLOT);
if (g_lotstep_236 == 0.01) gi_268 = 2;
if (g_lotstep_236 == 0.1) gi_268 = 1;
g_file_320 = FileOpen("mySendOrder.TXT", FILE_CSV|FILE_READ);
if (g_file_320 < 0) {
g_file_320 = FileOpen("mySendOrder.TXT", FILE_CSV|FILE_WRITE);
FileWrite(g_file_320, "1268019531;1;AUDUSD;10;0;0;0;1268019453;");
FileClose(g_file_320);
}
gs_280 = FileReadNumber(g_file_320);
Print("联邦基金远程本地跟单系统");
ObjectCreate("handan", OBJ_LABEL, 0, 0, 0);
ObjectSet("handan", OBJPROP_XDISTANCE, 10);
ObjectSet("handan", OBJPROP_YDISTANCE, 15);
ObjectSetText("handan", "联邦基金远程本地智能跟单系统", 16, "宋体", White);
ObjectCreate("handan1", OBJ_LABEL, 0, 0, 0);
ObjectSet("handan1", OBJPROP_XDISTANCE, 10);
ObjectSet("handan1", OBJPROP_YDISTANCE, 55);
ObjectSetText("handan1", "禁止使用此图表进行分析交易!", 16, "宋体", White);
ObjectCreate("handan2", OBJ_LABEL, 0, 0, 0);
ObjectSet("handan2", OBJPROP_XDISTANCE, 10);
ObjectSet("handan2", OBJPROP_YDISTANCE, 95);
ObjectSetText("handan2", "反向跟单EA运行中......", 16, "宋体", White);
Print("可以开始跟单了!");
while (true) {
gi_496 = TRUE;
RefreshRates();
FileSeek(g_file_320, 0, SEEK_SET);
gs_272 = FileReadNumber(g_file_320);
if (gs_272 != gs_280) {
gs_416 = FileReadString(g_file_320);
gi_292 = FileReadNumber(g_file_320);
gd_308 = FileReadNumber(g_file_320);
gd_340 = FileReadNumber(g_file_320);
gd_400 = FileReadNumber(g_file_320);
gd_372 = FileReadNumber(g_file_320);
gi_224 = FileReadNumber(g_file_320);
gs_424 = FileReadString(g_file_320);
if (gs_416 == gs_536) {
if (g_bool_512) gs_416 = gs_528;
else gi_224 = FALSE;
} else gs_416 = StringSubstr(gs_416, 0, 6) + gs_544;
if (gi_524 == 1) gd_300 = 固定下单量;
if (gi_524 == 2) gd_300 = NormalizeDouble(gd_308 * gd_228, gi_268);
if (gi_524 == 3) gd_300 = NormalizeDouble(资金比例* AccountBalance() / MarketInfo(Symbol(), MODE_LOTSIZE), gi_268);
if (gd_300 < gd_244) gd_300 = gd_244;
if (gd_300 > gd_252) gd_300 = gd_252;
gi_504 = FALSE;
for (g_index_328 = 0; g_index_328 < 100; g_index_328++) {
if (gia_220[g_index_328] == gi_224) {
if (gi_292 == 10 && gia_288[g_index_328] != 16) {
gia_220[g_index_328] = 0;
gi_504 = TRUE;
break;
}
if (gi_292 == 16) {
gda_368[g_index_328] = gd_372;
gda_396[g_index_328] = gd_400;
gi_504 = TRUE;
break;
}
}
}
if ((!gi_504 && gi_292 != 16) || (g_bool_492 && gi_292 == 16)) {
for (g_index_332 = 0; g_index_332 < 100; g_index_332++) {
if (gia_220[g_index_332] == 0) {
gsa_412[g_index_332] = gs_416;
gia_288[g_index_332] = gi_292;
gda_408[g_index_332] = gd_300;
gda_348[g_index_332] = gd_340;
gda_368[g_index_332] = gd_372;
gda_396[g_index_332] = gd_400;
gia_220[g_index_332] = gi_224;
if (g_bool_516 == TRUE) {
gsa_432[g_index_332] = gs_424;
break;
}
gsa_432[g_index_332] = "";
break;
}
}
}
gs_280 = gs_272;
}
if ((!IsTradeContextBusy()) && IsConnected()) {
for (g_index_336 = 0; g_index_336 < 100; g_index_336++) {
if (gia_220[g_index_336] != 0) {
g_bid_444 = MarketInfo(gsa_412[g_index_336], MODE_BID);
g_ask_436 = MarketInfo(gsa_412[g_index_336], MODE_ASK);
gd_452 = MarketInfo(gsa_412[g_index_336], MODE_STOPLEVEL);
g_point_460 = MarketInfo(gsa_412[g_index_336], MODE_POINT);
gd_468 = MarketInfo(gsa_412[g_index_336], MODE_SPREAD);
if (gia_288[g_index_336] == 1) {
if (!g_bool_500 || (g_bool_500 && gda_348[g_index_336] - g_bid_444 >= gd_484 * g_point_460)) {
gi_316 = OrderSend(gsa_412[g_index_336], OP_BUY, gda_408[g_index_336], g_ask_436, g_slippage_264, 0, 0, gsa_432[g_index_336],
if (gi_316 > 0) {
gia_288[g_index_336] = 16;
if (gda_368[g_index_336] == 0.0 && gda_396[g_index_336] == 0.0) gia_220[g_index_336] = 0;
}
}
}
if (gia_288[g_index_336] == 0) {
if (!g_bool_500 || (g_bool_500 && g_ask_436 - gda_348[g_index_336] >= gd_484 * g_point_460)) {
gi_316 = OrderSend(gsa_412[g_index_336], OP_SELL, gda_408[g_index_336], g_bid_444, g_slippage_264, 0, 0, gsa_432[g_index_336], gia_220[g_index_336], 0, Red);
if (gi_316 > 0) {
gia_288[g_index_336] = 16;
if (gda_368[g_index_336] == 0.0 && gda_396[g_index_336] == 0.0) gia_220[g_index_336] = 0;
}
}
}
if (gia_288[g_index_336] == 5 && g_bool_520 == TRUE) {
gi_316 = OrderSend(gsa_412[g_index_336], OP_BUYLIMIT, gda_408[g_index_336], gda_348[g_index_336], 0, 0, 0, gsa_432[g_index_336], gia_220[g_index_336], 0, Blue);
if (gi_316 > 0) {
gia_288[g_index_336] = 16;
if (gda_368[g_index_336] == 0.0 && gda_396[g_index_336] == 0.0) gia_220[g_index_336] = 0;
}
}
if (gia_288[g_index_336] == 4 && g_bool_520 == TRUE) {
gi_316 = OrderSend(gsa_412[g_index_336], OP_SELLLIMIT, gda_408[g_index_336], gda_348[g_index_336], 0, 0, 0, gsa_432[g_index_336], gia_220[g_index_336], 0, Red);
if (gi_316 > 0) {
gia_288[g_index_336] = 16;
if (gda_368[g_index_336] == 0.0 && gda_396[g_index_336] == 0.0) gia_220[g_index_336] = 0;
}
}
if (gia_288[g_index_336] == 3 && g_bool_520 == TRUE) {
gi_316 = OrderSend(gsa_412[g_index_336], OP_BUYSTOP, gda_408[g_index_336], gda_348[g_index_336], 0, 0, 0, gsa_432[g_index_336],
if (gi_316 > 0) {
gia_288[g_index_336] = 16;
if (gda_368[g_index_336] == 0.0 && gda_396[g_index_336] == 0.0) gia_220[g_index_336] = 0;
}
}
if (gia_288[g_index_336] == 2 && g_bool_520 == TRUE) {
gi_316 = OrderSend(gsa_412[g_index_336], OP_SELLSTOP, gda_408[g_index_336], gda_348[g_index_336], 0, 0, 0, gsa_432[g_index_336], gia_220[g_index_336], 0, Red);
if (gi_316 > 0) {
gia_288[g_index_336] = 16;
if (gda_368[g_index_336] == 0.0 && gda_396[g_index_336] == 0.0) gia_220[g_index_336] = 0;
}
}
Print("下单类型=" + gia_288[g_index_336]);
if (gia_288[g_index_336] == 10) {
gi_508 = FALSE;
for (int pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == gia_220[g_index_336]) {
gi_508 = TRUE;
if (OrderType() > OP_SELL) gi_316 = OrderDelete(OrderTicket());
if (OrderType() <= OP_SELL) gi_316 = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), g_slippage_260, PaleVioletRed);
if (gi_316 > 0) {
gia_220[g_index_336] = 0;
break;
}
}
}
if (!gi_508) gia_220[g_index_336] = 0;
}
if (gia_288[g_index_336] == 16) {
gi_508 = FALSE;
for (pos_0 = OrdersTotal() - 1; pos_0 >= 0; pos_0--) {
OrderSelect(pos_0, SELECT_BY_POS, MODE_TRADES);
if (OrderMagicNumber() == gia_220[g_index_336]) {
gi_508 = TRUE;
g_price_360 = OrderStopLoss();
g_price_388 = OrderTakeProfit();
gd_476 = gd_452 * g_point_460;
if (gda_368[g_index_336] == 0.0) {
gd_352 = 0;
g_price_360 = 0;
}
if (gda_396[g_index_336] == 0.0) {
gd_380 = 0;
g_price_388 = 0;
}
if (gda_368[g_index_336] != 0.0 && OrderType() == OP_SELL) gd_352 = gda_368[g_index_336] + gd_468 * g_point_460;
if (gda_396[g_index_336] != 0.0 && OrderType() == OP_SELL) gd_380 = gda_396[g_index_336] + gd_468 * g_point_460;
if (gda_368[g_index_336] != 0.0 && OrderType() == OP_SELLSTOP) gd_352 = gda_368[g_index_336] + gd_468 * g_point_460;
if (gda_396[g_index_336] != 0.0 && OrderType() == OP_SELLSTOP) gd_380 = gda_396[g_index_336] + gd_468 * g_point_460;
if (gda_368[g_index_336] != 0.0 && OrderType() == OP_SELLLIMIT) gd_352 = gda_368[g_index_336] + gd_468 * g_point_460;
if (gda_396[g_index_336] != 0.0 && OrderType() == OP_SELLLIMIT) gd_380 = gda_396[g_index_336] + gd_468 * g_point_460;
if (gda_368[g_index_336] != 0.0 && OrderType() == OP_BUY) gd_352 = gda_368[g_index_336] - gd_468 * g_point_460;
if (gda_396[g_index_336] != 0.0 && OrderType() == OP_BUY) gd_380 = gda_396[g_index_336] - gd_468 * g_point_460;
if (gda_368[g_index_336] != 0.0 && OrderType() == OP_BUYSTOP) gd_352 = gda_368[g_index_336] - gd_468 * g_point_460;
if (gda_396[g_index_336] != 0.0 && OrderType() == OP_BUYSTOP) gd_380 = gda_396[g_index_336] - gd_468 * g_point_460;
if (gda_368[g_index_336] != 0.0 && OrderType() == OP_BUYLIMIT) gd_352 = gda_368[g_index_336] - gd_468 * g_point_460;
if (gda_396[g_index_336] != 0.0 && OrderType() == OP_BUYLIMIT) gd_380 = gda_396[g_index_336] - gd_468 * g_point_460;
if (OrderType() == OP_BUY) {
if (g_bid_444 - gd_352 > gd_476 && gd_352 != 0.0) g_price_360 = gd_352;
if (gd_380 - g_bid_444 > gd_476 && gd_380 != 0.0) g_price_388 = gd_380;
}
if (OrderType() == OP_BUYSTOP) {
if (g_bid_444 - gd_352 > gd_476 && gd_352 != 0.0) g_price_360 = gd_352;
if (gd_380 - g_bid_444 > gd_476 && gd_380 != 0.0) g_price_388 = gd_380;
}
if (OrderType() == OP_BUYLIMIT) {
if (g_bid_444 - gd_352 > gd_476 && gd_352 != 0.0) g_price_360 = gd_352;
if (gd_380 - g_bid_444 > gd_476 && gd_380 != 0.0) g_price_388 = gd_380;
}
if (OrderType() == OP_SELL) {
if (gd_352 - g_ask_436 > gd_476 && gd_352 != 0.0) g_price_360 = gd_352;
if (g_ask_436 - gd_380 > gd_476 && gd_380 != 0.0) g_price_388 = gd_380;
}
if (OrderType() == OP_SELLSTOP) {
if (gd_352 - g_ask_436 > gd_476 && gd_352 != 0.0) g_price_360 = gd_352;
if (g_ask_436 - gd_380 > gd_476 && gd_380 != 0.0) g_price_388 = gd_380;
}
if (OrderType() == OP_SELLLIMIT) {
if (gd_352 - g_ask_436 > gd_476 && gd_352 != 0.0) g_price_360 = gd_352;
if (g_ask_436 - gd_380 > gd_476 && gd_380 != 0.0) g_price_388 = gd_380;
}
if (g_price_360 != OrderStopLoss() || g_price_388 != OrderTakeProfit()) {
gi_316 = OrderModify(OrderTicket(), OrderOpenPrice(), g_price_360, g_price_388, 0, Yellow);
if (gi_316 > 0 && g_price_360 == gd_352 && g_price_388 == gd_380) {
gia_220[g_index_336] = 0;
break;
}
}
}
}
if (!gi_508) gia_220[g_index_336] = 0;
}
gi_496 = FALSE;
}
}
}
if (gi_496) Sleep(100);
Sleep(100);
}
}
int start() {
init();
return (0); }。