#property copyright "5美金炒外汇黄金,白送的http://goo.gl/sGDvh"
#property link "http://www.forex4you.cn/?affid=491fbb3"
#import "stdlib.ex4"
string ErrorDescription(int a0);
#import
extern string HeadLine = "外汇投资开户qq63511088";
extern string BuyBlock = "无交易员美分账户开户http://www.forex4you.cn/?affid=491fbb3群84446947";
extern bool Trade_on_all_currencies = TRUE;
extern int Trade_on_TimeFrame = 60;
extern double LotSize = 0.1;
extern int Max_Spread_pips = 10;
extern int Max_StopLevel_pips = 30;
extern bool UseTrailingStop = TRUE;
extern int Trailing_Step = 15;
extern int Manual_Stop_Loss = 50;
extern int Take_Profit = 0;
extern int Slip_page = 2;
extern int MagicNumber = 19881;
extern int ADX.Period = 14;
extern int BB.Period = 20;
extern int BB.Deviation = 2;
extern int MA.Period = 20;
extern int MA.Method = 0;
extern int MA.Price = 0;
extern double SAR.Step = 0.02;
extern double SAR.Max = 0.2;
extern int SignalBar = 1;
string gsa_168[];
int gia_172[];
int g_slippage_176 = 0;
int gi_180 = 0;
int gi_184 = 0;
int gi_unused_188 = -1;
string gs_200;
int g_datetime_208 = 0;
int init() {
int li_0;
int li_4;
if (Trade_on_all_currencies) {
li_0 = f0_2();
li_4 = f0_6();
gs_200 = gs_200 + "H1 Multitrader EA Loaded on " + li_4 + " of " + li_0 + " currency pairs.\n";
} else {
ArrayResize(gsa_168, 1);
gsa_168[0] = Symbol();
gs_200 = gs_200 + "H1 Multitrader EA Loaded only on " + gsa_168[0]
+ "\n";
}
gs_200 = gs_200 + "H1 Multitrader EA Loaded on " + Trade_on_TimeFrame + "m. time frame.\n";
if (IsTradeAllowed()) gs_200 = gs_200 + " @ Live Trading Enabled @";
if (!IsTradeAllowed()) gs_200 = gs_200 + " @ Alerts Mode Only @";
ArrayResize(gia_172, ArraySize(gsa_168));
return (0);
}
int deinit() {
Comment("");
gs_200 = "";
return (0);
}
int start() {
ads();
string ls_unused_0;
double icustom_12;
double icustom_20;
if (f0_0(10)) {
for (int index_8 = 0; index_8 < ArraySize(gsa_168); index_8++) {
if (MarketInfo(gsa_168[index_8], MODE_DIGITS) == 5.0 || MarketInfo(gsa_168[index_8], MODE_DIGITS) == 3.0) {
g_slippage_176 = 10 * Slip_page;
gi_180 = 10 * Manual_Stop_Loss;
gi_184 = 10 * Take_Profit;
} else {
g_slippage_176 = Slip_page;
gi_180 = Manual_Stop_Loss;
gi_184 = Take_Profit;
}
Comment(gs_200
+ "\n Scanning " + gsa_168[index_8] + " , period: " + Trade_on_TimeFrame + " min.");
icustom_12 = iCustom(gsa_168[index_8], Trade_on_TimeFrame, "Momentum Indicator", ADX.Period, BB.Period, BB.Deviation, MA.Period, MA.Method, MA.Price, SAR.Step, SAR.Max,
0, SignalBar);
icustom_20 = iCustom(gsa_168[index_8], Trade_on_TimeFrame, "Momentum Indicator", ADX.Period, BB.Period, BB.Deviation, MA.Period, MA.Method, MA.Price, SAR.Step, SAR.Max,
1, SignalBar);
if (icustom_12 > 0.0 && icustom_12 != EMPTY_VALUE) {
f0_7(OP_SELL, gsa_168[index_8]);
if (!f0_3(-1, gsa_168[index_8])) f0_4("外汇投资qq63511088", gsa_168[index_8]);
if (gia_172[index_8] != 0) {
Alert(gsa_168[index_8] + " BUY Signal @ " + DoubleToStr(MarketInfo(gsa_168[index_8], MODE_ASK), MarketInfo(gsa_168[index_8], MODE_DIGITS)));
gia_172[index_8] = 0;
}
}
if (icustom_20 > 0.0 && icustom_20 != EMPTY_VALUE) {
f0_7(OP_BUY, gsa_168[index_8]);
if (!f0_3(-1, gsa_168[index_8])) f0_5("外汇投资qq63511088", gsa_168[index_8]);
if (gia_172[index_8] != 1) {
Alert(gsa_168[index_8] + " SELL Signal @ " + DoubleToStr(MarketInfo(gsa_168[index_8], MODE_BID), MarketInfo(gsa_168[index_8], MODE_DIGITS)));
gia_172[index_8] = 1;
}
}
}
}
f0_1();
Comment(gs_200);
return (0);
}
int f0_6() {
string lsa_0[];
int li_4;
int li_8;
for (int index_12 = 0; index_12 < ArraySize(gsa_168); index_12++) {
if (MarketInfo(gsa_168[index_12], MODE_DIGITS) == 3.0 || MarketInfo(gsa_168[index_12], MODE_DIGITS) == 5.0) {
li_4 = 10 * Max_Spread_pips;
li_8 = 10 * Max_StopLevel_pips;
} else {
li_4 = Max_Spread_pips;
li_8 = Max_StopLevel_pips;
}
if (MarketInfo(gsa_168[index_12], MODE_SPREAD) <= li_4 && MarketInfo(gsa_168[index_12], MODE_STOPLEVEL) <= li_8 && MarketInfo(gsa_168[index_12], MODE_PROFITCALCMODE) == 0.0 &&
StringFind(gsa_168[index_12], "XAU") < 0 && StringFind(gsa_168[index_12], "XAG") < 0) {
ArrayResize(lsa_0, ArraySize(lsa_0) + 1);
lsa_0[ArraySize(lsa_0) - 1] = gsa_168[index_12];
}
}
ArrayResize(gsa_168, ArraySize(lsa_0));
for (int index_16 = 0; index_16 < ArraySize(lsa_0); index_16++) gsa_168[index_16] = lsa_0[index_16];
ArrayResize(lsa_0, 0);
return (ArraySize(gsa_168));
}
void f0_1() {
int li_0;
if (Trailing_Step <= 0 || UseTrailingStop == FALSE) return;
for (int pos_4 = OrdersTotal() - 1; pos_4 >= 0; pos_4--) {
if (OrderSelect(pos_4, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber() == MagicNumber) {
if (MarketInfo(OrderSymbol(), MODE_DIGITS) == 5.0 || MarketInfo(OrderSymbol(), MODE_DIGITS) == 3.0) li_0 = 10 * Trailing_Step;
else li_0 = Trailing_Step;
if (MarketInfo(OrderSymbol(), MODE_STOPLEVEL) > li_0) li_0 = MarketInfo(OrderSymbol(), MODE_STOPLEVEL);
if (OrderType() == OP_BUY && MarketInfo(OrderSymbol(), MODE_BID) > OrderOpenPrice() + li_0 * MarketInfo(OrderSymbol(), MODE_POINT)) {
if (OrderStopLoss() < OrderOpenPrice()) {
if (!(!OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, Yellow))) break;
Print(OrderSymbol(), " Error modifying buy trade ", OrderTicket(), ". Error: ", ErrorDescription(GetLastError()));
return;
}
if (MarketInfo(OrderSymbol(), MODE_BID) - OrderStopLoss() > 2.0 * (MarketInfo(OrderSymbol(), MODE_POINT) * li_0))
if (!OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss() + MarketInfo(OrderSymbol(), MODE_POINT) * li_0, OrderTakeProfit(), 0, Yellow)) Print(OrderSymbol(), " Error modifying buy trade ", OrderTicket(), ". Error: ", ErrorDescription(GetLastError()));
}
if (OrderType() == OP_SELL && MarketInfo(OrderSymbol(), MODE_ASK) < OrderOpenPrice() - li_0 * MarketInfo(OrderSymbol(), MODE_POINT)) {
if (OrderStopLoss() > OrderOpenPrice() || OrderStopLoss() < MarketInfo(OrderSymbol(), MODE_POINT)) {
if (!(!OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, Yellow))) break;
Print(OrderSymbol(), " Error modifying sell trade ", OrderTicket(), ". Error: ", ErrorDescription(GetLastError()));
return;
}
if (OrderStopLoss() - MarketInfo(OrderSymbol(), MODE_ASK) > 2.0 * (MarketInfo(OrderSymbol(), MODE_POINT) * li_0))
if (!OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss() - MarketInfo(OrderSymbol(), MODE_POINT) * li_0, OrderTakeProfit(), 0, Yellow)) Print(OrderSymbol(), " Error modifying sell trade ", OrderTicket(), ". Error: ", ErrorDescription(GetLastError()));
}
}
}
}
int f0_4(string a_comment_0, string a_symbol_8) {
double price_24;
double price_32;
int ticket_16 = -1;
int count_20 = 0;
if (IsTradeContextBusy()) {
Print("Warning: Trade Context Busy!\nOrders can not be executed");
return (0);
}
while (ticket_16 <= 0 && count_20 < 5) {
RefreshRates();
price_32 = MarketInfo(a_symbol_8, MODE_ASK) + gi_184 * MarketInfo(a_symbol_8, MODE_POINT);
if (price_32 < MarketInfo(a_symbol_8, MODE_BID) + MarketInfo(a_symbol_8, MODE_STOPLEVEL) * MarketInfo(a_symbol_8, MODE_POINT)) price_32 = MarketInfo(a_symbol_8, MODE_BID) + MarketInfo(a_symbol_8, MODE_STOPLEVEL) * MarketInfo(a_symbol_8, MODE_POINT);
if (gi_184 < MarketInfo(a_symbol_8, MODE_POINT)) price_32 = 0;
price_24 = iLow(a_symbol_8, Trade_on_TimeFrame, SignalBar);
if (MarketInfo(a_symbol_8, MODE_ASK) - price_24 < gi_180 * MarketInfo(a_symbol_8, MODE_POINT)) price_24 = MarketInfo(a_symbol_8, MODE_ASK) - gi_180 * MarketInfo(a_symbol_8, MODE_POINT);
if (price_24 > MarketInfo(a_symbol_8, MODE_BID) - MarketInfo(a_symbol_8, MODE_STOPLEVEL) * MarketInfo(a_symbol_8, MODE_POINT)) price_24 = MarketInfo(a_symbol_8, MODE_BID) - MarketInfo(a_symbol_8, MODE_STOPLEVEL) * MarketInfo(a_symbol_8, MODE_POINT);
if (!IsTradeAllowed()) return (0);
ticket_16 = OrderSend(a_symbol_8, OP_BUY, LotSize, MarketInfo(a_symbol_8, MODE_ASK), g_slippage_176, 0, 0, a_comment_0, MagicNumber, 0, Blue);
if (GetLastError() == 132/* MARKET_CLOSED */) {
Print(a_symbol_8, " Unable to open buy trade! Market is CLOSED!");
return (0);
}
if (ticket_16 <= 0) Sleep(500);
count_20++;
}
if (ticket_16 > 0 && OrderSelect(ticket_16, SELECT_BY_TICKET)) {
if (!(price_24 > 0.0 || price_32 > 0.0)) return (1);
while (!OrderModify(OrderTicket(), OrderOpenPrice(), price_24, price_32, 0, CLR_NONE) && count_20 < 10) {
Print(a_symbol_8, " Unable to set SL/TP! Error: ", ErrorDescription(GetLastError()));
Print("Ask: " + MarketInfo(a_symbol_8, MODE_ASK), " SL: ", price_24, " TP: ", price_32);
count_20++;
Sleep(500);
}
return (1);
}
Print(a_symbol_8, " Unable to open buy trade! Error: ", ErrorDescription(GetLastError()));
return (0);
}
int f0_5(string a_comment_0, string a_symbol_8) {
double price_24;
double price_32;
int ticket_16 = -1;
int count_20 = 0;
if (IsTradeContextBusy()) {
Print("Warning: Trade Context Busy!\nOrders can not be executed");
return (0);
}
while (ticket_16 <= 0 && count_20 < 5) {
RefreshRates();
price_32 = MarketInfo(a_symbol_8, MODE_BID) - gi_184 * MarketInfo(a_symbol_8, MODE_POINT);
if (price_32 > MarketInfo(a_symbol_8, MODE_ASK) - MarketInfo(a_symbol_8, MODE_STOPLEVEL) * MarketInfo(a_symbol_8, MODE_POINT)) price_32 = MarketInfo(a_symbol_8, MODE_ASK) - MarketInfo(a_symbol_8, MODE_STOPLEVEL) * MarketInfo(a_symbol_8, MODE_POINT);
if (gi_184 < MarketInfo(a_symbol_8, MODE_POINT)) price_32 = 0;
price_24 = iHigh(a_symbol_8, Trade_on_TimeFrame, SignalBar);
if (price_24 - MarketInfo(a_symbol_8, MODE_BID) < gi_180 * MarketInfo(a_symbol_8, MODE_POINT)) price_24 = MarketInfo(a_symbol_8, MODE_BID) + gi_180 * MarketInfo(a_symbol_8, MODE_POINT);
if (price_24 > 0.0 && price_24 < MarketInfo(a_symbol_8, MODE_ASK) + MarketInfo(a_symbol_8, MODE_STOPLEVEL) * MarketInfo(a_symbol_8, MODE_POINT)) price_24 = MarketInfo(a_symbol_8, MODE_ASK) + MarketInfo(a_symbol_8, MODE_STOPLEVEL) * MarketInfo(a_symbol_8, MODE_POINT);
if (!IsTradeAllowed()) return (0);
ticket_16 = OrderSend(a_symbol_8, OP_SELL, LotSize, MarketInfo(a_symbol_8, MODE_BID), g_slippage_176, 0, 0, a_comment_0, MagicNumber, 0, Red);
if (GetLastError() == 132/* MARKET_CLOSED */) {
Print(a_symbol_8, " Unable to open sell trade! Market is CLOSED!");
return (0);
}
if (ticket_16 <= 0) Sleep(500);
count_20++;
}
if (ticket_16 > 0 && OrderSelect(ticket_16, SELECT_BY_TICKET)) {
if (!(price_24 > 0.0 || price_32 > 0.0)) return (1);
while (!OrderModify(OrderTicket(), OrderOpenPrice(), price_24, price_32, 0, CLR_NONE) && count_20 < 10) {
Print(a_symbol_8, " Unable to set SL/TP! Error: ", ErrorDescription(GetLastError()));
Print("Bid: ", MarketInfo(a_symbol_8, MODE_BID), " SL: ", price_24, " TP: ", price_32);
count_20++;
Sleep(500);
}
return (1);
}
Print(a_symbol_8, " Unable to open sell trade! Error: ", ErrorDescription(GetLastError()));
return (0);
}
void f0_7(int a_cmd_0, string a_symbol_4) {
int li_12;
bool is_closed_16 = FALSE;
for (int pos_20 = OrdersTotal() - 1; pos_20 >= 0; pos_20--) {
if (OrderSelect(pos_20, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == a_symbol_4 && OrderMagicNumber() == MagicNumber) {
if (OrderType() == a_cmd_0) {
while (!IsTradeAllowed()) Sleep(100);
while (IsTradeContextBusy()) Sleep(100);
while (!is_closed_16 && li_12 < 5) {
RefreshRates();
is_closed_16 = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), g_slippage_176, White);
li_12++;
Sleep(500);
}
}
}
}
}
int f0_2() {
string name_8 = "symbols.sel";
int file_16 = FileOpenHistory(name_8, FILE_BIN|FILE_READ);
if (file_16 < 0) return (-1);
int li_ret_4 = (FileSize(file_16) - 4) / 128;
int li_0 = 116;
ArrayResize(gsa_168, li_ret_4);
FileSeek(file_16, 4, SEEK_SET);
for (int index_20 = 0; index_20 < li_ret_4; index_20++) {
gsa_168[index_20] = FileReadString(file_16, 12);
FileSeek(file_16, li_0, SEEK_CUR);
}
FileClose(file_16);
return (li_ret_4);
}
int f0_0(int ai_0) {
int datetime_4 = TimeCurrent();
if (datetime_4 - g_datetime_208 > ai_0) {
g_datetime_208 = datetime_4;
return (1);
}
return (0);
}
bool f0_3(int a_cmd_0, string a_symbol_4) {
for (int pos_12 = OrdersTotal() - 1; pos_12 >= 0; pos_12--) {
if (OrderSelect(pos_12, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == a_symbol_4 && OrderMagicNumber() == MagicNumber)
if (OrderType() == a_cmd_0 || a_cmd_0 == -1) return (TRUE);
}
for (pos_12 = OrdersHistoryTotal() - 1; pos_12 >= 0; pos_12--) {
if (OrderSelect(pos_12, SELECT_BY_POS, MODE_HISTORY) && OrderSymbol() == a_symbol_4 && OrderMagicNumber() == MagicNumber)
if (OrderType() == a_cmd_0 || a_cmd_0 == -1 && iBarShift(a_symbol_4, Trade_on_TimeFrame, OrderOpenTime(), TRUE) == 0) return (TRUE);
}
return (FALSE);
}
void SetLab(string name, int x, int y, int corner, string text, int fontsize, string fontname, color clr = -1) {
ObjectCreate(name, OBJ_LABEL, 0, 0, 0);
ObjectSet(name, OBJPROP_XDISTANCE, x);
ObjectSet(name, OBJPROP_YDISTANCE, y);
ObjectSet(name, OBJPROP_CORNER, corner);
ObjectSetText(name, text, fontsize, fontname, clr);
}
void ads() {
SetLab("ads03", 20, 15, 2, "外汇投资开户qq63511088", 14, "Arial", Aqua);
} |