#property copyright "Copyright © 2006-2009, VICTORIOUS VIP" #property link "http://www.victorious-vip.com" extern double BuyStopPrice = 0.0; extern int TimeFrame = 60; extern int OrdersLevel = 50; extern int Magic_N = 444; extern int CountOrders = 10; extern bool Show_Alerts = TRUE; extern bool Send_Email = FALSE; extern double Lots_1 = 0.1; extern double Lots_2 = 0.2; extern double Lots_3 = 0.3; extern double Lots_4 = 0.6; extern double Lots_5 = 1.2; extern double Lots_6 = 2.4; extern double Lots_7 = 4.8; extern double Lots_8 = 9.0; extern double Lots_9 = 10.0; extern double Lots_10 = 10.0; extern bool InfoOn = TRUE; extern color InfoColor = Yellow; int gia_196[] = {66279, 11111111, 111111}; string gs_200 = "2009.07.29"; int gi_208 = 16748574; string gs_212 = "VIP Signals"; int gi_220; int gi_224; int gi_unused_228; double gd_240; double gda_248[10]; int gi_252; double g_ord_open_price_256; int g_ticket_268; string gs_272; string g_comment_280; double g_ord_stoploss_288; double g_ord_takeprofit_296; string gs_304; string gs_312 = "AccInfSymbInf_Lbl_"; int g_datetime_320 = 0; int g_datetime_324 = 0; int g_datetime_328 = 0; int g_datetime_332 = 0; int g_datetime_336 = 0; int g_datetime_340 = 0; int g_datetime_344 = 0; int g_datetime_348 = 0; int g_datetime_352 = 0; int gia_356[]; int gia_360[]; int init() { bool li_0; if (!IsTesting() && !IsDemo()) { li_0 = FALSE; for (int l_index_4 = 0; l_index_4 < ArraySize(gia_196); l_index_4++) { if (gia_196[l_index_4] == AccountNumber()) { li_0 = TRUE; break; } } if (!li_0) Alert("Система VIP Signals - неверный номер счета!"); } if (TimeCurrent() > StrToTime(gs_200)) Alert("Система VIP Signals - срок работы закончился!"); gs_304 = "VF_Signals_" + Symbol() + "_" + Magic_N + "_"; if (IsTesting()) gs_304 = gs_304 + "t_"; if (IsDemo()) gs_304 = gs_304 + "d_"; if (IsTesting()) { for (l_index_4 = GlobalVariablesTotal() - 1; l_index_4 >= 0; l_index_4--) if (StringFind(GlobalVariableName(l_index_4), gs_304, 0) == 0) GlobalVariableDel(GlobalVariableName(l_index_4)); } gda_248[1] = Lots_2; gda_248[2] = Lots_3; gda_248[3] = Lots_4; gda_248[4] = Lots_5; gda_248[5] = Lots_6; gda_248[6] = Lots_7; gda_248[7] = Lots_8; gda_248[8] = Lots_9; gda_248[9] = Lots_10; gi_unused_228 = OrdersLevel; gi_220 = OrdersLevel; gi_224 = OrdersLevel; if (TimeFrame == 0) TimeFrame = Period(); Comment(""); return (0); } int deinit() { if (IsTesting()) { for (int li_0 = GlobalVariablesTotal() - 1; li_0 >= 0; li_0--) if (StringFind(GlobalVariableName(li_0), gs_304, 0) == 0) GlobalVariableDel(GlobalVariableName(li_0)); } Comment(""); fObjDeleteByPrefix(gs_312); return (0); } int start() { bool li_0; int li_8; int li_12; int li_16; int li_20; int li_40; if (!IsTesting() && !IsDemo()) { li_0 = FALSE; for (int l_index_4 = 0; l_index_4 < ArraySize(gia_196); l_index_4++) { if (gia_196[l_index_4] == AccountNumber()) { li_0 = TRUE; break; } } if (!li_0) { Alert("Система VIP Signals - неверный номер счета!"); return (0); } } if (TimeCurrent() > StrToTime(gs_200)) { Alert("Система VIP Signals - срок работы закончился!"); return (0); } if (InfoOn) AccountAndSymbolLbls(); fSignasSLTPPend(); int l_count_24 = fCountOrders(li_8, li_12, li_16, li_20); if (l_count_24 == -1) return (0); string ls_28 = ""; if (l_count_24 == 0) { if (BuyStopPrice == 0.0) { GlobalVariableDel(gs_304 + "BLOCK"); ls_28 = "Система готова к вводу BuyStopPrice"; } else if (GlobalVariableCheck(gs_304 + "BLOCK")) ls_28 = "Система блокирована. Обнулите BuyStopPrice"; } Comment(ls_28); int l_global_var_36 = 0; if (GlobalVariableCheck(gs_304 + "BLOCK")) l_global_var_36 = GlobalVariableGet(gs_304 + "BLOCK"); if (l_global_var_36 == 0 && BuyStopPrice > 0.0) { l_count_24 = fCountOrders(li_8, li_12, li_16, li_20); if (l_count_24 == -1) return (0); if (l_count_24 == 0) { gd_240 = Lots_1; g_comment_280 = "=1="; if (fOrderSetBuyStop(ND(BuyStopPrice), ND(BuyStopPrice - Point * gi_220)) > 0) { l_count_24++; li_16++; Sleep(3000); } } if (l_count_24 == 1 && li_16 == 1) { RefreshRates(); gd_240 = Lots_1; g_comment_280 = "=1="; if (fOrderSetSellStop(ND(BuyStopPrice - Point * gi_220), ND(BuyStopPrice)) > 0) { l_global_var_36 = 1; GlobalVariableSet(gs_304 + "BLOCK", l_global_var_36); } } return (0); } if (l_global_var_36 == 1) { l_count_24 = fCountOrders(li_8, li_12, li_16, li_20); if (li_16 == 0 && li_20 == 1) { if (fDeleteSellStops() != 0) return (0); l_global_var_36 = 2; GlobalVariableSet(gs_304 + "BLOCK", l_global_var_36); } if (li_20 == 0 && li_16 == 1) { if (fDeleteBuyStops() != 0) return (0); l_global_var_36 = 2; GlobalVariableSet(gs_304 + "BLOCK", l_global_var_36); } } if (!(l_global_var_36 == 2 || BuyStopPrice == 0.0)) return (0); l_count_24 = fCountOrders(li_8, li_12, li_16, li_20); if (l_count_24 != -1) { if (li_8 + li_12 == 0) { if (li_16 + li_20 == 1) if (fDeleteAllPendings() == 0) l_count_24 = 0; } if (li_8 + li_12 > 0) { if (li_16 + li_20 == 0) { if (gi_252 == -1) { li_40 = fGetOrderIndex(g_ticket_268, gs_272); if (li_40 > 0 && CountOrders > li_40) { gd_240 = gda_248[li_40]; g_comment_280 = "=" + ((li_40 + 1)) + "="; fOrderSetBuyStop(ND(g_ord_stoploss_288), ND(g_ord_open_price_256)); } } if (gi_252 == 1) { li_40 = fGetOrderIndex(g_ticket_268, gs_272); if (li_40 > 0 && CountOrders > li_40) { gd_240 = gda_248[li_40]; g_comment_280 = "=" + ((li_40 + 1)) + "="; fOrderSetSellStop(ND(g_ord_stoploss_288), ND(g_ord_open_price_256)); } } } } } fObjLabel("VIP_Signal_Obj_Lbl", 4, 1, "“VICTORIOUS VIP” Professional Trading", 2, gi_208, 8, 0, "Arial", FALSE); return (0); } void fObjLabel(string a_name_0, int a_x_8, int a_y_12, string a_text_16, int a_corner_24 = 0, color a_color_28 = 255, int a_fontsize_32 = 9, int a_window_36 = 0, string a_fontname_40 = "Arial", bool a_bool_48 = FALSE) { if (ObjectFind(a_name_0) != a_window_36) ObjectCreate(a_name_0, OBJ_LABEL, a_window_36, 0, 0); ObjectSet(a_name_0, OBJPROP_XDISTANCE, a_x_8); ObjectSet(a_name_0, OBJPROP_YDISTANCE, a_y_12); ObjectSetText(a_name_0, a_text_16, a_fontsize_32, a_fontname_40, a_color_28); ObjectSet(a_name_0, OBJPROP_BACK, a_bool_48); ObjectSet(a_name_0, OBJPROP_CORNER, a_corner_24); } int fGetOrderIndex(int ai_unused_0, string as_4) { int li_12 = StringFind(as_4, "=", 0); int li_16 = StringFind(as_4, "=", 1); if (li_12 == 0 && li_16 > 1) return (StrToInteger(StringSubstr(as_4, li_12 + 1, li_16 - li_12 - 1))); return (-1); } int fOrderSetBuyStop(double a_price_0, double a_price_8, int a_datetime_16 = 0) { double l_lots_28; double l_price_36; int l_ticket_44; RefreshRates(); double ld_20 = ND(Ask + Point * MarketInfo(Symbol(), MODE_STOPLEVEL)); if (a_price_0 >= ld_20) { l_lots_28 = fGetLotsSimple(OP_BUY); if (l_lots_28 > 0.0) { if (!IsTradeContextBusy()) { l_price_36 = ND(a_price_0 + Point * gi_224); if (gi_224 == 0) l_price_36 = 0; l_ticket_44 = OrderSend(Symbol(), OP_BUYSTOP, l_lots_28, a_price_0, 0, a_price_8, l_price_36, g_comment_280, Magic_N, a_datetime_16, CLR_NONE); if (l_ticket_44 > 0) { if (Show_Alerts) Alert(gs_212 + "(" + Symbol() + ",Magic=" + Magic_N + "): Set BUYSTOP " + DS2(l_lots_28) + " at " + DS(a_price_0)); if (Send_Email) SendMail(gs_212 + "(" + Symbol() + ",Magic=" + Magic_N + ")", "BUYSTOP " + DS2(l_lots_28) + " at " + DS(a_price_0)); return (l_ticket_44); } Print("Error set BUYSTOP. " + fMyErDesc(GetLastError())); return (-1); } if (g_datetime_320 != iTime(NULL, 0, 0)) { g_datetime_320 = iTime(NULL, 0, 0); Print("Need set buystop. Trade Context Busy"); } return (-2); } if (g_datetime_324 != iTime(NULL, 0, 0)) { g_datetime_324 = iTime(NULL, 0, 0); if (l_lots_28 == -1.0) Print("Need set buystop. No money"); if (l_lots_28 == -2.0) Print("Need set buystop. Wrong lots size"); } return (-3); } if (g_datetime_328 != iTime(NULL, 0, 0)) { g_datetime_328 = iTime(NULL, 0, 0); Print("Need set buystop. Wrong price level ", ld_20, " ", Ask); } return (-4); } int fOrderSetSellStop(double a_price_0, double a_price_8, int a_datetime_16 = 0) { double l_lots_28; double l_price_36; int l_ticket_44; RefreshRates(); double ld_20 = ND(Bid - Point * MarketInfo(Symbol(), MODE_STOPLEVEL)); if (a_price_0 <= ld_20) { l_lots_28 = fGetLotsSimple(OP_SELL); if (l_lots_28 > 0.0) { if (!IsTradeContextBusy()) { l_price_36 = ND(a_price_0 - Point * gi_224); if (gi_224 == 0) l_price_36 = 0; l_ticket_44 = OrderSend(Symbol(), OP_SELLSTOP, l_lots_28, a_price_0, 0, a_price_8, l_price_36, g_comment_280, Magic_N, a_datetime_16, CLR_NONE); if (l_ticket_44 > 0) { if (Show_Alerts) Alert(gs_212 + "(" + Symbol() + ",Magic=" + Magic_N + "): Set SELLSTOP " + DS2(l_lots_28) + " at " + DS(a_price_0)); if (Send_Email) SendMail(gs_212 + "(" + Symbol() + ",Magic=" + Magic_N + ")", "SELLSTOP " + DS2(l_lots_28) + " at " + DS(a_price_0)); return (l_ticket_44); } Print("Error set SELLSTOP. " + fMyErDesc(GetLastError())); return (-1); } if (g_datetime_332 != iTime(NULL, 0, 0)) { g_datetime_332 = iTime(NULL, 0, 0); Print("Need set sellstop. Trade Context Busy"); } return (-2); } if (g_datetime_336 != iTime(NULL, 0, 0)) { g_datetime_336 = iTime(NULL, 0, 0); if (l_lots_28 == -1.0) Print("Need set sellstop. No money"); if (l_lots_28 == -2.0) Print("Need set sellstop. Wrong lots size"); } return (-3); } if (g_datetime_340 != iTime(NULL, 0, 0)) { g_datetime_340 = iTime(NULL, 0, 0); Print("Need set sellstop. Wrong price level"); } return (-4); } string DS2(double ad_0) { return (DoubleToStr(ad_0, 2)); } string DS(double ad_0) { return (DoubleToStr(ad_0, Digits)); } int fCountOrders(int &a_count_0, int &a_count_4, int &a_count_8, int &a_count_12) { a_count_0 = 0; a_count_4 = 0; a_count_8 = 0; a_count_12 = 0; gi_252 = 0; for (int l_pos_16 = 0; l_pos_16 < OrdersTotal(); l_pos_16++) { if (OrderSelect(l_pos_16, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic_N) { switch (OrderType()) { case OP_BUY: a_count_0++; gi_252 = 1; g_ticket_268 = OrderTicket(); gs_272 = OrderComment(); g_ord_open_price_256 = OrderOpenPrice(); g_ord_stoploss_288 = OrderStopLoss(); g_ord_takeprofit_296 = OrderTakeProfit(); break; case OP_SELL: a_count_4++; gi_252 = -1; g_ticket_268 = OrderTicket(); gs_272 = OrderComment(); g_ord_open_price_256 = OrderOpenPrice(); g_ord_stoploss_288 = OrderStopLoss(); g_ord_takeprofit_296 = OrderTakeProfit(); break; case OP_BUYSTOP: a_count_8++; break; case OP_SELLSTOP: a_count_12++; } } } else return (-1); } return (a_count_0 + a_count_4 + a_count_8 + a_count_12); } double fGetLotsSimple(int a_cmd_0) { if (AccountFreeMarginCheck(Symbol(), a_cmd_0, gd_240) <= 0.0) return (-1); if (GetLastError() == 134/* NOT_ENOUGH_MONEY */) return (-2); return (gd_240); } double ND(double ad_0) { return (NormalizeDouble(ad_0, Digits)); } int fDeleteAllPendings() { int li_ret_0 = 0; for (int l_pos_4 = OrdersTotal() - 1; l_pos_4 >= 0; l_pos_4--) { if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic_N) { if (OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP) { RefreshRates(); if (!IsTradeContextBusy()) { if (!OrderDelete(OrderTicket())) { Print("Error delete order " + OrderTicket() + " " + fMyErDesc(GetLastError())); li_ret_0 = -1; } } else { if (g_datetime_344 != iTime(NULL, 0, 0)) { g_datetime_344 = iTime(NULL, 0, 0); Print("Need delete order " + OrderTicket() + ". Trade Context Busy"); } return (-2); } } } } } return (li_ret_0); } int fDeleteBuyStops() { int li_ret_0 = 0; for (int l_pos_4 = OrdersTotal() - 1; l_pos_4 >= 0; l_pos_4--) { if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic_N) { if (OrderType() == OP_BUYSTOP) { RefreshRates(); if (!IsTradeContextBusy()) { if (!OrderDelete(OrderTicket())) { Print("Error delete order " + OrderTicket() + " " + fMyErDesc(GetLastError())); li_ret_0 = -1; } } else { if (g_datetime_348 != iTime(NULL, 0, 0)) { g_datetime_348 = iTime(NULL, 0, 0); Print("Need delete order " + OrderTicket() + ". Trade Context Busy"); } return (-2); } } } } } return (li_ret_0); } int fDeleteSellStops() { int li_ret_0 = 0; for (int l_pos_4 = OrdersTotal() - 1; l_pos_4 >= 0; l_pos_4--) { if (OrderSelect(l_pos_4, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic_N) { if (OrderType() == OP_SELLSTOP) { RefreshRates(); if (!IsTradeContextBusy()) { if (!OrderDelete(OrderTicket())) { Print("Error delete order " + OrderTicket() + " " + fMyErDesc(GetLastError())); li_ret_0 = -1; } } else { if (g_datetime_352 != iTime(NULL, 0, 0)) { g_datetime_352 = iTime(NULL, 0, 0); Print("Need delete order " + OrderTicket() + ". Trade Context Busy"); } return (-2); } } } } } return (li_ret_0); } string fMyErDesc(int ai_0) { string ls_4 = "Err Num: " + ai_0 + " - "; switch (ai_0) { case 0: return (ls_4 + "NO ERROR"); case 1: return (ls_4 + "NO RESULT"); case 2: return (ls_4 + "COMMON ERROR"); case 3: return (ls_4 + "INVALID TRADE PARAMETERS"); case 4: return (ls_4 + "SERVER BUSY"); case 5: return (ls_4 + "OLD VERSION"); case 6: return (ls_4 + "NO CONNECTION"); case 7: return (ls_4 + "NOT ENOUGH RIGHTS"); case 8: return (ls_4 + "TOO FREQUENT REQUESTS"); case 9: return (ls_4 + "MALFUNCTIONAL TRADE"); case 64: return (ls_4 + "ACCOUNT DISABLED"); case 65: return (ls_4 + "INVALID ACCOUNT"); case 128: return (ls_4 + "TRADE TIMEOUT"); case 129: return (ls_4 + "INVALID PRICE"); case 130: return (ls_4 + "INVALID STOPS"); case 131: return (ls_4 + "INVALID TRADE VOLUME"); case 132: return (ls_4 + "MARKET CLOSED"); case 133: return (ls_4 + "TRADE DISABLED"); case 134: return (ls_4 + "NOT ENOUGH MONEY"); case 135: return (ls_4 + "PRICE CHANGED"); case 136: return (ls_4 + "OFF QUOTES"); case 137: return (ls_4 + "BROKER BUSY"); case 138: return (ls_4 + "REQUOTE"); case 139: return (ls_4 + "ORDER LOCKED"); case 140: return (ls_4 + "LONG POSITIONS ONLY ALLOWED"); case 141: return (ls_4 + "TOO MANY REQUESTS"); case 145: return (ls_4 + "TRADE MODIFY DENIED"); case 146: return (ls_4 + "TRADE CONTEXT BUSY"); case 147: return (ls_4 + "TRADE EXPIRATION DENIED"); case 148: return (ls_4 + "TRADE TOO MANY ORDERS"); case 4000: return (ls_4 + "NO MQLERROR"); case 4001: return (ls_4 + "WRONG FUNCTION POINTER"); case 4002: return (ls_4 + "ARRAY INDEX OUT OF RANGE"); case 4003: return (ls_4 + "NO MEMORY FOR FUNCTION CALL STACK"); case 4004: return (ls_4 + "RECURSIVE STACK OVERFLOW"); case 4005: return (ls_4 + "NOT ENOUGH STACK FOR PARAMETER"); case 4006: return (ls_4 + "NO MEMORY FOR PARAMETER STRING"); case 4007: return (ls_4 + "NO MEMORY FOR TEMP STRING"); case 4008: return (ls_4 + "NOT INITIALIZED STRING"); case 4009: return (ls_4 + "NOT INITIALIZED ARRAYSTRING"); case 4010: return (ls_4 + "NO MEMORY FOR ARRAYSTRING"); case 4011: return (ls_4 + "TOO LONG STRING"); case 4012: return (ls_4 + "REMAINDER FROM ZERO DIVIDE"); case 4013: return (ls_4 + "ZERO DIVIDE"); case 4014: return (ls_4 + "UNKNOWN COMMAND"); case 4015: return (ls_4 + "WRONG JUMP"); case 4016: return (ls_4 + "NOT INITIALIZED ARRAY"); case 4017: return (ls_4 + "DLL CALLS NOT ALLOWED"); case 4018: return (ls_4 + "CANNOT LOAD LIBRARY"); case 4019: return (ls_4 + "CANNOT CALL FUNCTION"); case 4020: return (ls_4 + "EXTERNAL EXPERT CALLS NOT ALLOWED"); case 4021: return (ls_4 + "NOT ENOUGH MEMORY FOR RETURNED STRING"); case 4022: return (ls_4 + "SYSTEM BUSY"); case 4050: return (ls_4 + "INVALID FUNCTION PARAMETERS COUNT"); case 4051: return (ls_4 + "INVALID FUNCTION PARAMETER VALUE"); case 4052: return (ls_4 + "STRING FUNCTION INTERNAL ERROR"); case 4053: return (ls_4 + "SOME ARRAY ERROR"); case 4054: return (ls_4 + "INCORRECT SERIES ARRAY USING"); case 4055: return (ls_4 + "CUSTOM INDICATOR ERROR"); case 4056: return (ls_4 + "INCOMPATIBLE ARRAYS"); case 4057: return (ls_4 + "GLOBAL VARIABLES PROCESSING ERROR"); case 4058: return (ls_4 + "GLOBAL VARIABLE NOT FOUND"); case 4059: return (ls_4 + "FUNCTION NOT ALLOWED IN TESTING MODE"); case 4060: return (ls_4 + "FUNCTION NOT CONFIRMED"); case 4061: return (ls_4 + "SEND MAIL ERROR"); case 4062: return (ls_4 + "STRING PARAMETER EXPECTED"); case 4063: return (ls_4 + "INTEGER PARAMETER EXPECTED"); case 4064: return (ls_4 + "DOUBLE PARAMETER EXPECTED"); case 4065: return (ls_4 + "ARRAY AS PARAMETER EXPECTED"); case 4066: return (ls_4 + "HISTORY WILL UPDATED"); case 4067: return (ls_4 + "TRADE ERROR"); case 4099: return (ls_4 + "END OF FILE"); case 4100: return (ls_4 + "SOME FILE ERROR"); case 4101: return (ls_4 + "WRONG FILE NAME"); case 4102: return (ls_4 + "TOO MANY OPENED FILES"); case 4103: return (ls_4 + "CANNOT OPEN FILE"); case 4104: return (ls_4 + "INCOMPATIBLE ACCESS TO FILE"); case 4105: return (ls_4 + "NO ORDER SELECTED"); case 4106: return (ls_4 + "UNKNOWN SYMBOL"); case 4107: return (ls_4 + "INVALID PRICE PARAM"); case 4108: return (ls_4 + "INVALID TICKET"); case 4109: return (ls_4 + "TRADE NOT ALLOWED"); case 4110: return (ls_4 + "LONGS NOT ALLOWED"); case 4111: return (ls_4 + "SHORTS NOT ALLOWED"); case 4200: return (ls_4 + "OBJECT ALREADY EXISTS"); case 4201: return (ls_4 + "UNKNOWN OBJECT PROPERTY"); case 4202: return (ls_4 + "OBJECT DOES NOT EXIST"); case 4203: return (ls_4 + "UNKNOWN OBJECT TYPE"); case 4204: return (ls_4 + "NO OBJECT NAME"); case 4205: return (ls_4 + "OBJECT COORDINATES ERROR"); case 4206: return (ls_4 + "NO SPECIFIED SUBWINDOW"); case 4207: return (ls_4 + "SOME OBJECT ERROR"); } return (ls_4 + "WRONG ERR NUM"); } void fSignasSLTPPend() { int lia_0[]; int lia_4[]; double lda_8[]; bool li_16; bool li_20; double ld_28; string ls_36; if (Show_Alerts || Send_Email) { ArrayResize(lia_0, 0); ArrayResize(lia_4, 0); ArrayResize(lda_8, 0); for (int l_pos_12 = 0; l_pos_12 < OrdersTotal(); l_pos_12++) { if (!(OrderSelect(l_pos_12, SELECT_BY_POS, MODE_TRADES))) return; if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic_N) { ArrayResize(lia_0, ArraySize(lia_0) + 1); lia_0[ArraySize(lia_0) - 1] = OrderTicket(); ArrayResize(lia_4, ArraySize(lia_4) + 1); lia_4[ArraySize(lia_4) - 1] = OrderType(); ArrayResize(lda_8, ArraySize(lda_8) + 1); lda_8[ArraySize(lda_8) - 1] = OrderLots(); } } for (l_pos_12 = 0; l_pos_12 < ArraySize(gia_356); l_pos_12++) { li_16 = FALSE; li_20 = FALSE; for (int l_index_24 = 0; l_index_24 < ArraySize(lia_0); l_index_24++) { if (gia_356[l_pos_12] == lia_0[l_index_24]) { li_16 = TRUE; if (gia_360[l_pos_12] == lia_4[l_index_24]) break; ld_28 = lda_8[l_index_24]; li_20 = TRUE; break; } } if (li_20) { ls_36 = ""; if (gia_360[l_pos_12] == 4) ls_36 = "BUYSTOP " + DS2(ld_28) + " -> BUY"; if (gia_360[l_pos_12] == 5) ls_36 = "SELLSTOP " + DS2(ld_28) + " -> SELL"; if (Show_Alerts) Alert(gs_212 + "(" + Symbol() + ",Magic=" + Magic_N + "): " + ls_36); if (Send_Email) SendMail(gs_212 + "(" + Symbol() + ",Magic=" + Magic_N + ")", ls_36); } else { if (!li_16) { if (OrderSelect(gia_356[l_pos_12], SELECT_BY_TICKET)) { if (OrderType() == OP_BUY) { if (OrderStopLoss() != 0.0) { if (ND(OrderClosePrice()) <= ND(OrderStopLoss())) { if (Show_Alerts) Alert(gs_212 + "(" + Symbol() + ",Magic=" + Magic_N + "): BUY " + OrderTicket() + " closed by stoploss. Profit: " + DS2(OrderProfit())); if (Send_Email) SendMail(gs_212 + "(" + Symbol() + ",Magic=" + Magic_N + ")", "BUY " + OrderTicket() + " closed by stoploss. Profit: " + DS2(OrderProfit())); } } if (OrderTakeProfit() != 0.0) { if (ND(OrderClosePrice()) >= ND(OrderTakeProfit())) { if (Show_Alerts) Alert(gs_212 + "(" + Symbol() + ",Magic=" + Magic_N + "): BUY " + OrderTicket() + " closed by takeprofit. Profit: " + DS2(OrderProfit())); if (Send_Email) SendMail(gs_212 + "(" + Symbol() + ",Magic=" + Magic_N + ")", "BUY " + OrderTicket() + " closed by takeprofit. Profit: " + DS2(OrderProfit())); } } } if (OrderType() == OP_SELL) { if (OrderStopLoss() != 0.0) { if (ND(OrderClosePrice()) >= ND(OrderStopLoss())) { if (Show_Alerts) Alert(gs_212 + "(" + Symbol() + ",Magic=" + Magic_N + "): SELL " + OrderTicket() + " closed by stoploss. Profit: " + DS2(OrderProfit())); if (Send_Email) SendMail(gs_212 + "(" + Symbol() + ",Magic=" + Magic_N + ")", "SELL " + OrderTicket() + " closed by stoploss. Profit: " + DS2(OrderProfit())); } } if (OrderTakeProfit() != 0.0) { if (ND(OrderClosePrice()) <= ND(OrderTakeProfit())) { if (Show_Alerts) Alert(gs_212 + "(" + Symbol() + ",Magic=" + Magic_N + "): SELLL " + OrderTicket() + " closed by takeprofit. Profit: " + DS2(OrderProfit())); if (Send_Email) SendMail(gs_212 + "(" + Symbol() + ",Magic=" + Magic_N + ")", "SELL " + OrderTicket() + " closed by takeprofit. Profit: " + DS2(OrderProfit())); } } } } } } } ArrayResize(gia_356, ArraySize(lia_0)); ArrayResize(gia_360, ArraySize(lia_0)); if (ArraySize(lia_0) > 0) ArrayCopy(gia_356, lia_0, 0, 0, ArraySize(lia_0)); if (ArraySize(lia_0) > 0) ArrayCopy(gia_360, lia_4, 0, 0, ArraySize(lia_0)); } } void AccountAndSymbolLbls() { string lsa_192[13]; string ls_0 = Symbol(); string ls_8 = MarketType(ls_0); string ls_16 = AccountCurrency(); string ls_24 = ls_0; if (ls_8 == "Forex") ls_24 = StringSubstr(ls_0, 0, 3); double l_free_magrin_32 = AccountFreeMargin(); double l_lotsize_40 = MarketInfo(ls_0, MODE_LOTSIZE); double ld_48 = 0; double ld_56 = 0; double ld_64 = 0; double l_ask_72 = MarketInfo(ls_0, MODE_ASK); double l_bid_80 = MarketInfo(ls_0, MODE_BID); if (ls_8 == "Forex") { if (ls_24 == ls_16) { l_ask_72 = 1; l_bid_80 = 1; } else { l_ask_72 = MarketInfo(ls_24 + ls_16, MODE_ASK); l_bid_80 = MarketInfo(ls_24 + ls_16, MODE_BID); } } double l_leverage_88 = 0; if (ls_8 == "Forex") l_leverage_88 = AccountLeverage(); if (ls_8 == "Metalls") l_leverage_88 = 10; if (ls_8 == "CFD") l_leverage_88 = 10; if (l_leverage_88 > 0.0) ld_48 = l_lotsize_40 / l_leverage_88; ld_56 = ld_48 * l_ask_72; ld_64 = ld_48 * l_bid_80; if (ls_8 == "Futures") { ld_48 = FuturesLotMargin(ls_0); ld_56 = ld_48; ld_64 = ld_48; } string ls_96 = DoubleToStr(ld_56, 2) + " " + ls_16; string ls_104 = DoubleToStr(ld_64, 2) + " " + ls_16; if (ls_8 == "Forex" && ls_24 != ls_16) { ls_96 = ls_96 + " (" + DoubleToStr(ld_48, 2) + " " + ls_24 + ")"; ls_104 = ls_104 + " (" + DoubleToStr(ld_48, 2) + " " + ls_24 + ")"; } double ld_112 = 0; double ld_120 = 0; if (ld_56 > 0.0 && l_free_magrin_32 > 0.0) ld_112 = l_free_magrin_32 / ld_56; if (ld_64 > 0.0 && l_free_magrin_32 > 0.0) ld_120 = l_free_magrin_32 / ld_64; double l_minlot_128 = MarketInfo(ls_0, MODE_MINLOT); bool li_136 = FALSE; if (l_minlot_128 > 0.0) li_136 = ld_112 / l_minlot_128; bool li_140 = FALSE; if (l_minlot_128 > 0.0) li_140 = ld_120 / l_minlot_128; ld_112 = l_minlot_128 * li_136; ld_120 = l_minlot_128 * li_140; double l_tickvalue_144 = MarketInfo(ls_0, MODE_TICKVALUE); double ld_152 = 0; if (l_minlot_128 > 0.0) ld_152 = MarketInfo(ls_0, MODE_SWAPLONG) / l_minlot_128; double ld_160 = 0; if (l_minlot_128 > 0.0) ld_160 = MarketInfo(ls_0, MODE_SWAPSHORT) / l_minlot_128; double ld_168 = 0; if (l_tickvalue_144 > 0.0) ld_168 = ld_152 / l_tickvalue_144; double ld_176 = 0; if (l_tickvalue_144 > 0.0) ld_176 = ld_160 / l_tickvalue_144; string ls_184 = "Реал"; if (IsDemo()) ls_184 = "Демо"; lsa_192[0] = "Тип счета: " + ls_184; lsa_192[1] = "Номер счета: " + AccountNumber(); lsa_192[2] = "Плечо: " + AccountLeverage(); lsa_192[3] = "Баланс: " + DoubleToStr(AccountBalance(), 2) + " " + ls_16; lsa_192[4] = "Средства: " + DoubleToStr(AccountEquity(), 2) + " " + ls_16; lsa_192[5] = "Залог: " + DoubleToStr(AccountMargin(), 2) + " " + ls_16; lsa_192[6] = "Символ: " + ls_0; lsa_192[7] = "Свободно лотов для BUY : " + DoubleToStr(ld_112, 1); lsa_192[8] = "Свободно лотов для SELL: " + DoubleToStr(ld_120, 1); lsa_192[9] = "Залог за лот для BUY : " + ls_96; lsa_192[10] = "Залог за лот для SELL: " + ls_104; lsa_192[11] = "Спред: " + DoubleToStr(MarketInfo(ls_0, MODE_SPREAD), 0); lsa_192[12] = "Точность: " + DoubleToStr(MarketInfo(ls_0, MODE_DIGITS), 0); int li_196 = 4; int li_200 = 22; for (int l_index_204 = 0; l_index_204 < 13; l_index_204++) fObjLabel(gs_312 + l_index_204, li_196, li_200 + 10 * l_index_204, lsa_192[l_index_204], 0, InfoColor, 8, 0, "Arial", FALSE); ObjectsRedraw(); } string MarketType(string as_0) { string ls_12; int l_str_len_8 = StringLen(as_0); if (StringSubstr(as_0, 0, 1) == "_") return ("Indexes"); if (StringSubstr(as_0, 0, 1) == "#") { ls_12 = StringSubstr(as_0, l_str_len_8 - 1, 1); if (ls_12 == "0") return ("Futures"); if (ls_12 == "1") return ("Futures"); if (ls_12 == "2") return ("Futures"); if (ls_12 == "3") return ("Futures"); if (ls_12 == "4") return ("Futures"); if (ls_12 == "5") return ("Futures"); if (ls_12 == "6") return ("Futures"); if (ls_12 == "7") return ("Futures"); if (ls_12 == "8") return ("Futures"); if (ls_12 == "9") return ("Futures"); return ("CFD"); } if (as_0 == "GOLD") return ("Metalls"); if (as_0 == "SILVER") return ("Metalls"); if (l_str_len_8 == 6) { ls_12 = StringSubstr(as_0, 0, 3); if (ls_12 == "AUD") return ("Forex"); if (ls_12 == "CAD") return ("Forex"); if (ls_12 == "CHF") return ("Forex"); if (ls_12 == "EUR") return ("Forex"); if (ls_12 == "GBP") return ("Forex"); if (ls_12 == "LFX") return ("Forex"); if (ls_12 == "NZD") return ("Forex"); if (ls_12 == "SGD") return ("Forex"); if (ls_12 == "USD") return ("Forex"); } return (""); } double FuturesLotMargin(string as_0) { double ld_ret_8 = 0; string ls_16 = AccountCurrency(); double l_bid_24 = 1; if (ls_16 != "USD") l_bid_24 = MarketInfo(ls_16 + "USD", MODE_BID); int l_str_len_32 = StringLen(as_0); string ls_36 = StringSubstr(as_0, 0, l_str_len_32 - 2); if (ls_36 == "#ENQ") ld_ret_8 = 3750.0 * l_bid_24; if (ls_36 == "#EP") ld_ret_8 = 3938.0 * l_bid_24; if (ls_36 == "#SLV") ld_ret_8 = 5063.0 * l_bid_24; if (ls_36 == "#GOLD") ld_ret_8 = 2363.0 * l_bid_24; if (ls_36 == "#CL") ld_ret_8 = 4725.0 * l_bid_24; if (ls_36 == "#NG") ld_ret_8 = 8100.0 * l_bid_24; if (ls_36 == "#W") ld_ret_8 = 608.0 * l_bid_24; if (ls_36 == "#S") ld_ret_8 = 1148.0 * l_bid_24; if (ls_36 == "#C") ld_ret_8 = 473.0 * l_bid_24; return (ld_ret_8); } void fObjDeleteByPrefix(string as_0) { for (int li_8 = ObjectsTotal() - 1; li_8 >= 0; li_8--) if (StringFind(ObjectName(li_8), as_0, 0) == 0) ObjectDelete(ObjectName(li_8)); }