Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- G e n e r a t e d by ex4-to-mq4 decompiler FREEWARE 4.0.509.5
- Website: h Ttp ://Ww w . m ETa QU O t Es. Net
- E-mail : S uP pOr t@m e TA Q u O Te S . ne T
- */
- #property copyright "Copyright © 2013, Rita Lasker"
- #property link "http://www.ritalasker.com"
- #include <WinUser32.mqh>
- #import "kernel32.dll"
- void GetSystemTime(int& a0[]);
- #import
- extern double LotSize = 0.1;
- int Gi_84 = 70;
- int Gi_88 = 70;
- extern int Magic = 111001;
- string G_comment_96 = "Forex1000pips gbpusd";
- extern bool Auto_UTC_OFFSET = TRUE;
- int Gi_108 = 0;
- int Gi_112 = 1;
- int Gi_116 = 3;
- int Gi_120 = 23;
- int G_period_124 = 8;
- int Gi_128 = 1;
- int Gi_132 = 1;
- int Gi_136 = 6;
- int Gi_140 = 20;
- double Gd_144 = 2.0;
- double Gd_152 = 25.0;
- double Gd_160 = 3.0;
- int G_slippage_168 = 2;
- int Gi_172;
- datetime G_time_176;
- int Gi_184;
- int Gi_188;
- bool Gi_192 = TRUE;
- int Gi_196;
- int G_slippage_200;
- double Gd_204;
- int G_stoplevel_212;
- // E37F0136AA3FFAF149B351F6A4C948E9
- int init() {
- G_slippage_200 = G_slippage_168;
- Gi_172 = 1;
- Gd_204 = Point;
- if (MarketInfo(Symbol(), MODE_DIGITS) == 5.0 || MarketInfo(Symbol(), MODE_DIGITS) == 3.0) {
- Gi_172 = 10 * Gi_172;
- G_slippage_200 = 10 * G_slippage_200;
- Gd_204 = 10.0 * Gd_204;
- }
- Gi_192 = TRUE;
- return (0);
- }
- // EA2B2676C28C0DB26D39331A336C6B92
- int start() {
- double Ld_16;
- double price_28;
- if ((!IsTradeAllowed()) || IsTradeContextBusy() || (!IsConnected()) || (!Gi_192)) return (0);
- G_stoplevel_212 = MarketInfo(Symbol(), MODE_STOPLEVEL);
- int Li_8 = Gi_140;
- if (Li_8 < G_stoplevel_212 / Gi_172 + 3) Li_8 = G_stoplevel_212 / Gi_172 + 3;
- if (Gi_112 > 0 && Gi_116 != Gi_120) {
- if (IsTesting()) {
- if (Auto_UTC_OFFSET) {
- Alert("Auto_UTC_OFFSET should be false at the test mode.");
- Gi_192 = FALSE;
- return (0);
- }
- Gi_196 = Gi_108;
- }
- Gi_196 = Gi_108;
- if (Auto_UTC_OFFSET) Gi_196 = f0_8();
- }
- for (int pos_12 = 0; pos_12 < OrdersTotal(); pos_12++) {
- if (OrderSelect(pos_12, SELECT_BY_POS, MODE_TRADES)) {
- if (OrderMagicNumber() == Magic + Period() && Symbol() == OrderSymbol()) {
- if (OrderType() == OP_BUY) {
- if (OrderOpenPrice() + Li_8 * Gi_172 * Point < Bid && OrderStopLoss() < OrderOpenPrice()) {
- if (OrderModify(OrderTicket(), OrderOpenPrice(), f0_5(OrderOpenPrice() + 3.0 * Gd_204), OrderTakeProfit(), 0, Blue))
- if (!IsOptimization()) Print("Order Modify Error ", GetLastError());
- }
- }
- if (OrderType() == OP_SELL) {
- if (OrderOpenPrice() - Li_8 * Gi_172 * Point > Ask && OrderStopLoss() > OrderOpenPrice() || OrderStopLoss() == 0.0) {
- if (OrderModify(OrderTicket(), OrderOpenPrice(), f0_5(OrderOpenPrice() - 3.0 * Gd_204), OrderTakeProfit(), 0, Blue))
- if (!IsOptimization()) Print("Order Modify Error ", GetLastError());
- }
- }
- }
- }
- }
- if (Gd_152 > 0.0) {
- Ld_16 = MathMax(Gd_152, G_stoplevel_212 * Point / Gd_204);
- for (int pos_24 = 0; pos_24 < OrdersTotal(); pos_24++) {
- OrderSelect(pos_24, SELECT_BY_POS, MODE_TRADES);
- if (OrderMagicNumber() == Magic + Period()) {
- if (OrderType() <= OP_SELL && OrderSymbol() == Symbol()) {
- if (OrderType() == OP_BUY) {
- if (!IsTesting()) RefreshRates();
- if (Bid - OrderOpenPrice() <= Gd_204 * (Ld_16 + Gd_144)) continue;
- price_28 = f0_5(Bid - Gd_204 * Ld_16);
- if (f0_5(OrderStopLoss()) >= price_28) continue;
- if (!(!OrderModify(OrderTicket(), OrderOpenPrice(), price_28, OrderTakeProfit(), 0, Blue))) continue;
- if (!(!IsOptimization())) continue;
- Print("TrailingStop Order Modify Error ", GetLastError());
- continue;
- }
- if (!IsTesting()) RefreshRates();
- if (OrderOpenPrice() - Ask > Gd_204 * (Ld_16 + Gd_144)) {
- price_28 = f0_5(Ask + Gd_204 * Ld_16);
- if (f0_5(OrderStopLoss()) > price_28 || OrderStopLoss() == 0.0) {
- if (!OrderModify(OrderTicket(), OrderOpenPrice(), price_28, OrderTakeProfit(), 0, Red))
- if (!IsOptimization()) Print("TrailingStop Order Modify Error ", GetLastError());
- }
- }
- }
- }
- }
- }
- double ima_0 = iMA(Symbol(), 0, G_period_124, 0, MODE_EMA, PRICE_CLOSE, 1);
- for (Gi_184 = 1; iMA(Symbol(), 0, G_period_124, 0, MODE_EMA, PRICE_CLOSE, Gi_184) < Low[Gi_184] - Gi_128 * Gi_172 * Point; Gi_184++) {
- }
- for (Gi_188 = 1; iMA(Symbol(), 0, G_period_124, 0, MODE_EMA, PRICE_CLOSE, Gi_188) > High[Gi_188] + Gi_128 * Gi_172 * Point; Gi_188++) {
- }
- if (f0_7() && G_time_176 != Time[1] && f0_9() == 0) {
- if (Gi_184 >= Gi_132 && Gi_184 < Gi_136 && Ask < ima_0 + Gi_128 * Gi_172 * Point) f0_1(OP_BUY);
- if (Gi_188 >= Gi_132 && Gi_188 < Gi_136 && Bid > ima_0 - Gi_128 * Gi_172 * Point) f0_1(OP_SELL);
- }
- Comment("GMT_OFFSET = " + Gi_196);
- return (0);
- }
- // 76657B14F61FB22008F7F0A3ECD17B0B
- double f0_4(double Ad_0) {
- double Ld_ret_8;
- if (LotSize == 0.0) {
- Ld_ret_8 = AccountBalance() * Gd_160 / (100.0 * (Ad_0 * Gi_172 * MarketInfo(Symbol(), MODE_LOTSIZE)));
- Ld_ret_8 = MathRound(Ld_ret_8 / MarketInfo(Symbol(), MODE_LOTSTEP)) * MarketInfo(Symbol(), MODE_LOTSTEP);
- Print(Ld_ret_8);
- if (Ld_ret_8 > MarketInfo(Symbol(), MODE_MAXLOT)) Ld_ret_8 = MarketInfo(Symbol(), MODE_MAXLOT);
- if (Ld_ret_8 < MarketInfo(Symbol(), MODE_MINLOT)) Ld_ret_8 = MarketInfo(Symbol(), MODE_MINLOT);
- } else Ld_ret_8 = LotSize;
- return (Ld_ret_8);
- }
- // EECC5240709741B0055E5D4E5197C899
- int f0_9(int A_cmd_0 = -1) {
- int Li_ret_4;
- for (int pos_8 = OrdersTotal() - 1; pos_8 >= 0; pos_8--) {
- OrderSelect(pos_8, SELECT_BY_POS, MODE_TRADES);
- if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic + Period() && OrderType() <= OP_SELL && OrderType() == A_cmd_0 || A_cmd_0 == -1) Li_ret_4++;
- }
- return (Li_ret_4);
- }
- // 32DD001F3588B056DFB819F074CBB255
- int f0_3() {
- int Lia_0[4];
- GetSystemTime(Lia_0);
- string Ls_4 = (Lia_0[0] & 65535) + "." + (Lia_0[0] >> 16) + "." + (Lia_0[1] >> 16) + " " + (Lia_0[2] & 65535) + ":" + (Lia_0[2] >> 16) + ":" + (Lia_0[3] & 65535);
- return (StrToTime(Ls_4));
- }
- // DE8222960353C69960E4A4C410BBF5B5
- int f0_8() {
- int Li_0 = f0_3();
- double Ld_4 = TimeCurrent() - Li_0;
- Ld_4 /= 3600.0;
- Ld_4 = MathRound(Ld_4);
- int Li_ret_12 = Ld_4;
- return (Li_ret_12);
- }
- // CB992171608A1E190EC5C8B8E8F0B0D5
- int f0_7() {
- if (Gi_112 <= 0 || Gi_116 == Gi_120) return (1);
- int Li_0 = Gi_116 + Gi_196;
- int Li_4 = Gi_120 + Gi_196;
- if (Li_0 > 23) Li_0 -= 24;
- if (Li_4 > 23) Li_4 -= 24;
- if (Li_0 < 0) Li_0 += 24;
- if (Li_4 < 0) Li_4 += 24;
- bool Li_ret_8 = FALSE;
- if (Li_0 < Li_4) {
- if (Li_0 <= Hour() && Hour() < Li_4) Li_ret_8 = TRUE;
- } else
- if (Li_0 <= Hour() || Hour() < Li_4) Li_ret_8 = TRUE;
- return (Li_ret_8);
- }
- // 0917FA48FB170A05280272D934078AA4
- void f0_1(int A_cmd_0) {
- color color_16;
- double price_20;
- int ticket_28;
- double price_32;
- double price_40;
- double lots_4 = f0_4(Gi_88 * Gi_172 * Point);
- for (int count_12 = 0; count_12 <= 3; count_12++) {
- while (!IsTradeAllowed()) Sleep(5000);
- RefreshRates();
- if (A_cmd_0 == OP_BUY) {
- color_16 = Blue;
- price_20 = f0_5(Ask);
- }
- if (A_cmd_0 == OP_SELL) {
- color_16 = Red;
- price_20 = f0_5(Bid);
- }
- ticket_28 = OrderSend(Symbol(), A_cmd_0, lots_4, price_20, G_slippage_200, 0, 0, G_comment_96, Magic + Period(), 0, color_16);
- if (ticket_28 >= 0) {
- G_time_176 = Time[1];
- Print("Opened Order ", OrderType(), " ", ticket_28);
- OrderSelect(ticket_28, SELECT_BY_TICKET, MODE_TRADES);
- if (Gi_88 > 0) {
- if (A_cmd_0 == OP_BUY) price_32 = f0_6(0, OrderOpenPrice());
- if (A_cmd_0 == OP_SELL) price_32 = f0_6(1, OrderOpenPrice());
- if (!OrderModify(OrderTicket(), OrderOpenPrice(), price_32, 0, 0, color_16))
- if (!IsOptimization()) Print("StopLoss Modify Error ", GetLastError());
- }
- if (Gi_84 <= 0) break;
- if (A_cmd_0 == OP_BUY) price_40 = f0_0(0, OrderOpenPrice());
- if (A_cmd_0 == OP_SELL) price_40 = f0_0(1, OrderOpenPrice());
- if (!(!OrderModify(OrderTicket(), OrderOpenPrice(), price_32, price_40, 0, color_16))) break;
- if (!(!IsOptimization())) break;
- Print("TakeProfit Modify Error ", GetLastError());
- return;
- }
- if (f0_2(GetLastError(), A_cmd_0) != 1) break;
- }
- }
- // B0A149E811F2D51B441305E67D8076BE
- double f0_6(int Ai_0, double Ad_4) {
- double Ld_ret_12;
- if (Ai_0 == 0) {
- if (Gi_88 > 0) Ld_ret_12 = f0_5(Ad_4 - Gi_88 * Gd_204);
- else Ld_ret_12 = 0;
- if (Ld_ret_12 > f0_5(Bid - G_stoplevel_212 * Point)) Ld_ret_12 = f0_5(Bid - G_stoplevel_212 * Point);
- }
- if (Ai_0 == 1) {
- if (Gi_88 > 0) Ld_ret_12 = f0_5(Ad_4 + Gi_88 * Gd_204);
- else Ld_ret_12 = 0;
- if (Ld_ret_12 < f0_5(Ask + G_stoplevel_212 * Point) && Ld_ret_12 > 0.0) Ld_ret_12 = f0_5(Ask + G_stoplevel_212 * Point);
- }
- return (Ld_ret_12);
- }
- // 05A64A7383193B4952B035B8116AC6AF
- double f0_0(int Ai_0, double Ad_4) {
- double Ld_ret_12;
- if (Ai_0 == 0) {
- if (Gi_84 <= 0) Ld_ret_12 = 0;
- else Ld_ret_12 = f0_5(Ad_4 + Gi_84 * Gd_204);
- if (Ld_ret_12 < f0_5(Bid + G_stoplevel_212 * Point) && Ld_ret_12 > 0.0) Ld_ret_12 = f0_5(Bid + G_stoplevel_212 * Point);
- }
- if (Ai_0 == 1) {
- if (Gi_84 <= 0) Ld_ret_12 = 0;
- else Ld_ret_12 = f0_5(Ad_4 - Gi_84 * Gd_204);
- if (Ld_ret_12 > f0_5(Ask - G_stoplevel_212 * Point)) Ld_ret_12 = f0_5(Ask - G_stoplevel_212 * Point);
- }
- return (Ld_ret_12);
- }
- // 195677E88BAA51D8B3E188E8E36789FC
- int f0_2(int Ai_0, int Ai_4) {
- switch (Ai_0) {
- case 4:
- Alert(Symbol(), ": Trade server is busy. Try repeat...");
- Sleep(3000);
- return (1);
- case 6:
- Alert(Symbol(), ": No connection with trade server. Try repeat...");
- Sleep(5000);
- return (1);
- case 128:
- Alert(Symbol(), ": Trade timeout. Try repeat...");
- Sleep(66000);
- if (Ai_4 > 1) return (1);
- if (f0_9(Ai_4) > 0) return (0);
- return (1);
- case 142:
- Alert(Symbol(), ": Trade timeout. Try repeat...");
- Sleep(66000);
- if (Ai_4 > 1) return (1);
- if (f0_9(Ai_4) > 0) return (0);
- return (1);
- case 143:
- Alert(Symbol(), ": Trade timeout. Try repeat...");
- Sleep(66000);
- if (Ai_4 > 1) return (1);
- if (f0_9(Ai_4) > 0) return (0);
- return (1);
- case 129:
- Alert(Symbol(), ": Invalid price. Try repeat...");
- Sleep(3000);
- return (1);
- case 135:
- Alert(Symbol(), ": Price changed. Try repeat...");
- RefreshRates();
- return (1);
- case 136:
- Alert(Symbol(), ": Off quotes. Wait new tick...");
- while (!RefreshRates()) Sleep(1);
- return (1);
- case 137:
- Alert(Symbol(), ": Broker is busy. Try repeat...");
- Sleep(3000);
- return (1);
- case 138:
- Alert(Symbol(), ": Requote. Try repeat...");
- Sleep(5000);
- return (1);
- case 146:
- Alert(Symbol(), ": Trade context is busy. Try repeat...");
- Sleep(500);
- return (1);
- case 2:
- Alert("Common error.");
- return (0);
- case 5:
- Alert("Old version of the client terminal.");
- Gi_192 = FALSE;
- return (0);
- case 64:
- Alert("Account disabled.");
- Gi_192 = FALSE;
- return (0);
- case 133:
- Alert("Trade is disabled.");
- return (0);
- case 134:
- Alert(Symbol(), ": Not enough money.");
- return (0);
- }
- Alert(Symbol(), ": Is other error ", Ai_0);
- return (0);
- }
- // 9A116C50D133C8648404081885194300
- double f0_5(double Ad_0) {
- return (NormalizeDouble(Ad_0, Digits));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement