Navigation:Home > Content >

FINEXX_Cor_V2.2~.mq4

Time: 2012-06-11 | Download file:FINEXX_Cor_V2.2~.mq4

/*
   G e n e r a t e d  by ex4-to-mq4 decompiler FREEWARE 4.0.509.5
   Website:  H Tt P: // WW w .M e T AQ uOtE s.n E t
   E-mail :  S Up P ort@mETAqu o t ES . nE t
*/
#property copyright "Copyright © 2006, Finexx"
#property link      "http://www.finexx.de"

//#include 
#import "stdlib.ex4"
   string ErrorDescription(int a0); // DA69CBAFF4D38B87377667EEC549DE5A
#import

extern bool TradingAllowed = TRUE;
bool Gi_80 = FALSE;
int Gi_84 = 3;
double Gd_88 = 0.1;
extern double LotSize = 0.1;
bool Gi_104 = TRUE;
string Gs_usdchf_108 = "USDCHF";
bool Gi_116 = TRUE;
double Gd_120 = 1.0;
double Gd_128 = -0.01;
bool Gi_136 = FALSE;
string Gs_usdchf_140 = "USDCHF";
bool Gi_148 = TRUE;
double Gd_152 = 1.0;
double Gd_160 = -0.01;
bool Gi_168 = FALSE;
string Gs_usdjpy_172 = "USDJPY";
bool Gi_180 = TRUE;
double Gd_184 = 1.0;
double Gd_192 = -0.01;
extern double STOP = 2500.0;
extern double PROFIT = 100.0;
extern double DailyPROFIT = 1000.0;
extern int MagicNo = 21;
extern bool ShowStatus = TRUE;
bool Gi_232 = FALSE;
int G_slippage_236;
int G_slippage_240;
int G_slippage_244;
int G_slippage_248;
int G_cmd_252 = -1;
int G_cmd_256 = -1;
int G_cmd_260 = -1;
int G_cmd_264 = -1;
int Gi_268;
int Gi_unused_272 = 12;
int G_period_276 = 5;
double Gd_280;
double G_price_288;
double G_price_296;
double G_price_304;
double G_price_312;
double G_lots_320;
double G_lots_328;
double G_lots_336;
double G_lots_344;
double G_swapshort_352;
double G_swaplong_360;
double G_swapshort_368;
double G_swapshort_376;
double G_swapshort_384;
double G_swaplong_392;
double G_swaplong_400;
double G_swaplong_408;
double Gd_416;
double Gd_424;
double Gd_432;
double Gd_440;
double Gd_448;
double Gd_456;
double Gd_464;
bool Gi_472 = FALSE;
bool Gi_476 = FALSE;
bool Gi_480;
bool Gi_484;
bool Gi_488;
bool Gi_unused_492 = TRUE;
string Gs_496 = "";
string Gs_504 = "";
string Gs_512 = "";
string G_comment_520 = "";
string Gs_eurusd_528 = "EURUSD";
int Gi_536 = D'24.06.2007 02:59';

int init() {
   G_swapshort_352 = MarketInfo(Gs_eurusd_528, MODE_SWAPSHORT);
   G_swaplong_360 = MarketInfo(Gs_eurusd_528, MODE_SWAPLONG);
   G_swapshort_368 = MarketInfo(Gs_usdchf_108, MODE_SWAPSHORT);
   G_swaplong_392 = MarketInfo(Gs_usdchf_108, MODE_SWAPLONG);
   G_swapshort_376 = MarketInfo(Gs_usdchf_140, MODE_SWAPSHORT);
   G_swaplong_400 = MarketInfo(Gs_usdchf_140, MODE_SWAPLONG);
   G_swapshort_384 = MarketInfo(Gs_usdjpy_172, MODE_SWAPSHORT);
   G_swaplong_408 = MarketInfo(Gs_usdjpy_172, MODE_SWAPLONG);
   Gd_440 = LotSize * PROFIT;
   Gd_448 = STOP * LotSize;
   Gd_456 = DailyPROFIT * LotSize;
   return (0);
}

int start() {
   bool Li_0;
   bool Li_4;
   bool Li_8;
   Gd_464 = Gd_440;
   if (iMA(NULL, PERIOD_H1, 12, 0, MODE_EMA, PRICE_CLOSE, 0) > iMA(NULL, PERIOD_H1, 12, 0, MODE_EMA, PRICE_CLOSE, 1) && iMA(NULL, PERIOD_H1, 12, 0, MODE_EMA, PRICE_CLOSE,
      1) > iMA(NULL, PERIOD_H1, 12, 0, MODE_EMA, PRICE_CLOSE, 2)) Gi_268 = 1;
   else {
      if (iMA(NULL, PERIOD_H1, 12, 0, MODE_EMA, PRICE_CLOSE, 0) < iMA(NULL, PERIOD_H1, 12, 0, MODE_EMA, PRICE_CLOSE, 1) && iMA(NULL, PERIOD_H1, 12, 0, MODE_EMA, PRICE_CLOSE,
         1) < iMA(NULL, PERIOD_H1, 12, 0, MODE_EMA, PRICE_CLOSE, 2)) Gi_268 = -1;
      else Gi_268 = 0;
   }
   if (Gi_80) {
      G_lots_320 = Lots(Gs_eurusd_528, Gd_88);
      G_lots_328 = Lots(Gs_usdchf_108, Gd_88 * Gd_120);
      G_lots_336 = Lots(Gs_usdchf_140, Gd_88 * Gd_152);
      G_lots_344 = Lots(Gs_usdjpy_172, Gd_88 * Gd_184);
   } else {
      G_lots_320 = LotSize;
      G_lots_328 = NormalizeDouble(LotSize * Gd_120, 1);
      G_lots_336 = NormalizeDouble(LotSize * Gd_152, 1);
      G_lots_344 = NormalizeDouble(LotSize * Gd_184, 1);
   }
   G_slippage_236 = MarketInfo(Gs_eurusd_528, MODE_SPREAD);
   if (G_slippage_236 == 0) G_slippage_236 = MathRound((MarketInfo(Gs_eurusd_528, MODE_ASK) - MarketInfo(Gs_eurusd_528, MODE_BID)) / MarketInfo(Gs_eurusd_528, MODE_POINT));
   if (Gi_268 == 1) {
      G_cmd_252 = 0;
      G_price_288 = MarketInfo(Gs_eurusd_528, MODE_ASK);
   }
   if (Gi_268 == -1) {
      G_cmd_252 = 1;
      G_price_288 = MarketInfo(Gs_eurusd_528, MODE_BID);
   }
   if (Gs_usdchf_108 != "" && Gi_104) {
      Gd_416 = Cor(Gs_eurusd_528, Gs_usdchf_108);
      G_slippage_240 = MarketInfo(Gs_usdchf_108, MODE_SPREAD);
      if (G_slippage_240 == 0) G_slippage_240 = MathRound((MarketInfo(Gs_usdchf_108, MODE_ASK) - MarketInfo(Gs_usdchf_108, MODE_BID)) / MarketInfo(Gs_usdchf_108, MODE_POINT));
      if (Gd_128 > 0.0 && Gd_416 <= Gd_128 && Gd_456 > DailyProfit(MagicNo) + DailyProfit(MagicNo + 1) + DailyProfit(MagicNo + 2)) Li_0 = TRUE;
      else {
         if (Gd_128 < 0.0 && Gd_416 >= Gd_128 && Gd_456 > DailyProfit(MagicNo) + DailyProfit(MagicNo + 1) + DailyProfit(MagicNo + 2)) Li_0 = TRUE;
         else Li_0 = FALSE;
      }
      if (Gi_268 == 1) {
         if (Gi_116) {
            G_cmd_256 = 0;
            G_price_296 = MarketInfo(Gs_usdchf_108, MODE_ASK);
            Gi_480 = G_swaplong_360 * G_lots_320 + G_swaplong_392 * G_lots_328 > 0.0;
         } else {
            G_cmd_256 = 1;
            G_price_296 = MarketInfo(Gs_usdchf_108, MODE_BID);
            Gi_480 = G_swaplong_360 * G_lots_320 + G_swapshort_368 * G_lots_328 > 0.0;
         }
      }
      if (Gi_268 == -1) {
         if (Gi_116) {
            G_cmd_256 = 1;
            G_price_296 = MarketInfo(Gs_usdchf_108, MODE_BID);
            Gi_480 = G_swaplong_360 * G_lots_320 + G_swapshort_368 * G_lots_328 > 0.0;
         } else {
            G_cmd_256 = 0;
            G_price_296 = MarketInfo(Gs_usdchf_108, MODE_ASK);
            Gi_480 = G_swaplong_360 * G_lots_320 + G_swaplong_392 * G_lots_328 > 0.0;
         }
      }
      Gs_496 = "\n--------------------------------" 
         + "\n" 
         + Gs_eurusd_528 + "->" + Val2String(G_cmd_252) + " ~ " + Gs_usdchf_108 + "->" + Val2String(G_cmd_256) 
         + "\n" 
         + Gs_eurusd_528 + "->" + DoubleToStr(G_lots_320, 2) + " ~ " + Gs_usdchf_108 + "->" + DoubleToStr(G_lots_328, 2) 
         + "\nMagic No. : " + MagicNo 
      + "\nOverAllProfit : " + DoubleToStr(TotalSwapnProfit(MagicNo), 2);
   } else Gs_496 = "";
   if (Gs_usdchf_140 != "" && Gi_136) {
      Gd_424 = Cor(Gs_eurusd_528, Gs_usdchf_140);
      G_slippage_244 = MarketInfo(Gs_usdchf_140, MODE_SPREAD);
      if (G_slippage_244 == 0) G_slippage_244 = MathRound((MarketInfo(Gs_usdchf_140, MODE_ASK) - MarketInfo(Gs_usdchf_140, MODE_BID)) / MarketInfo(Gs_usdchf_140, MODE_POINT));
      if (Gd_160 > 0.0 && Gd_424 <= Gd_160 && Gd_456 > DailyProfit(MagicNo) + DailyProfit(MagicNo + 1) + DailyProfit(MagicNo + 2)) Li_4 = TRUE;
      else {
         if (Gd_160 < 0.0 && Gd_424 >= Gd_160 && Gd_456 > DailyProfit(MagicNo) + DailyProfit(MagicNo + 1) + DailyProfit(MagicNo + 2)) Li_4 = TRUE;
         else Li_4 = FALSE;
      }
      if (Gi_268 == 1) {
         if (Gi_148) {
            G_cmd_260 = 0;
            G_price_304 = MarketInfo(Gs_usdchf_140, MODE_ASK);
            Gi_484 = G_swaplong_360 * G_lots_320 + G_swaplong_400 * G_lots_336 > 0.0;
         } else {
            G_cmd_260 = 1;
            G_price_304 = MarketInfo(Gs_usdchf_140, MODE_BID);
            Gi_484 = G_swaplong_360 * G_lots_320 + G_swapshort_376 * G_lots_336 > 0.0;
         }
      }
      if (Gi_268 == -1) {
         if (Gi_148) {
            G_cmd_260 = 1;
            G_price_304 = MarketInfo(Gs_usdchf_140, MODE_BID);
            Gi_484 = G_swaplong_360 * G_lots_320 + G_swapshort_376 * G_lots_336 > 0.0;
         } else {
            G_cmd_260 = 0;
            G_price_304 = MarketInfo(Gs_usdchf_140, MODE_ASK);
            Gi_484 = G_swaplong_360 * G_lots_320 + G_swaplong_400 * G_lots_336 > 0.0;
         }
      }
      Gs_504 = "\n--------------------------------" 
         + "\n" 
         + Gs_eurusd_528 + "->" + Val2String(G_cmd_252) + " ~ " + Gs_usdchf_140 + "->" + Val2String(G_cmd_260) 
         + "\n" 
         + Gs_eurusd_528 + "->" + DoubleToStr(G_lots_320, 2) + " ~ " + Gs_usdchf_140 + "->" + DoubleToStr(G_lots_336, 2) 
         + "\nMagic No. : " + DoubleToStr(MagicNo + 1, 0) 
         + "\nOverAllProfit : " + DoubleToStr(TotalSwapnProfit(MagicNo + 1), 2) 
      + "\nTotalprofit: " + DoubleToStr(DailyProfit(MagicNo + 1), 2);
   } else Gs_504 = "";
   if (Gs_usdjpy_172 != "" && Gi_168) {
      Gd_432 = Cor(Gs_eurusd_528, Gs_usdjpy_172);
      G_slippage_248 = MarketInfo(Gs_usdjpy_172, MODE_SPREAD);
      if (G_slippage_248 == 0) G_slippage_248 = MathRound((MarketInfo(Gs_usdjpy_172, MODE_ASK) - MarketInfo(Gs_usdjpy_172, MODE_BID)) / MarketInfo(Gs_usdjpy_172, MODE_POINT));
      if (Gd_192 > 0.0 && Gd_432 <= Gd_192 && Gd_456 > DailyProfit(MagicNo) + DailyProfit(MagicNo + 1) + DailyProfit(MagicNo + 2)) Li_8 = TRUE;
      else {
         if (Gd_192 < 0.0 && Gd_432 >= Gd_192 && Gd_456 > DailyProfit(MagicNo) + DailyProfit(MagicNo + 1) + DailyProfit(MagicNo + 2)) Li_8 = TRUE;
         else Li_8 = FALSE;
      }
      if (Gi_268 == 1) {
         if (Gi_180) {
            G_cmd_264 = 0;
            G_price_312 = MarketInfo(Gs_usdjpy_172, MODE_ASK);
            Gi_488 = G_swaplong_360 * G_lots_320 + G_swaplong_408 * G_lots_344 > 0.0;
         } else {
            G_cmd_264 = 1;
            G_price_312 = MarketInfo(Gs_usdjpy_172, MODE_BID);
            Gi_488 = G_swaplong_360 * G_lots_320 + G_swapshort_384 * G_lots_344 > 0.0;
         }
      }
      if (Gi_268 == -1) {
         if (Gi_180) {
            G_cmd_264 = 1;
            G_price_312 = MarketInfo(Gs_usdjpy_172, MODE_BID);
            Gi_488 = G_swaplong_360 * G_lots_320 + G_swapshort_384 * G_lots_344 > 0.0;
         } else {
            G_cmd_264 = 0;
            G_price_312 = MarketInfo(Gs_usdjpy_172, MODE_ASK);
            Gi_488 = G_swaplong_360 * G_lots_320 + G_swaplong_408 * G_lots_344 > 0.0;
         }
      }
      Gs_512 = "\n--------------------------------" 
         + "\n" 
         + Gs_eurusd_528 + "->" + Val2String(G_cmd_252) + " ~ " + Gs_usdjpy_172 + "->" + Val2String(G_cmd_264) 
         + "\n" 
         + Gs_eurusd_528 + "->" + DoubleToStr(G_lots_320, 2) + " ~ " + Gs_usdjpy_172 + "->" + DoubleToStr(G_lots_344, 2) 
         + "\nMagic No. : " + DoubleToStr(MagicNo + 2, 0) 
         + "\nOverAllProfit : " + DoubleToStr(TotalSwapnProfit(MagicNo + 2), 2) 
      + "\nTotalprofit: " + DoubleToStr(DailyProfit(MagicNo + 2), 2);
   } else Gs_512 = "";
   if (TimeCurrent() > Gi_536) Alert("EA expired");
   else {
      if (TradingAllowed && Gi_268 == 1 || Gi_268 == -1) {
         if (Gs_usdchf_108 != "" && Li_0 && Gi_104) {
            if (ExistPositions(Gs_eurusd_528, G_cmd_252, MagicNo) == 0) {
               G_comment_520 = DoubleToStr(MagicNo, 0) + ":B, Finexx_Cor";
               if (OrderSend(Gs_eurusd_528, G_cmd_252, G_lots_320, G_price_288, G_slippage_236, 0, 0, G_comment_520, MagicNo, -1) > 0) {
                  if (Gi_232) PlaySound("expert.wav");
               } else Print(Gs_eurusd_528, ": ", Val2String(G_cmd_252), ", ", MagicNo, " : ", ErrorDescription(GetLastError()));
            }
            if (ExistPositions(Gs_usdchf_108, G_cmd_256, MagicNo) == 0) {
               G_comment_520 = DoubleToStr(MagicNo, 0) + ":H, Finexx_Cor";
               if (OrderSend(Gs_usdchf_108, G_cmd_256, G_lots_328, G_price_296, G_slippage_240, 0, 0, G_comment_520, MagicNo, -1) > 0) {
                  if (Gi_232) PlaySound("expert.wav");
               } else Print(Gs_usdchf_108, ": ", Val2String(G_cmd_256), ", ", MagicNo, " : ", ErrorDescription(GetLastError()));
            }
         }
         if (Gs_usdchf_140 != "" && Li_4 && Gi_136) {
            if (ExistPositions(Gs_eurusd_528, G_cmd_252, MagicNo + 1) == 0) {
               G_comment_520 = DoubleToStr(MagicNo + 1, 0) + ":B";
               if (OrderSend(Gs_eurusd_528, G_cmd_252, G_lots_320, G_price_288, G_slippage_236, 0, 0, G_comment_520, MagicNo + 1, -1) > 0) {
                  if (Gi_232) PlaySound("expert.wav");
               } else Print(Gs_eurusd_528, ": ", Val2String(G_cmd_252), ", ", MagicNo + 1, " : ", ErrorDescription(GetLastError()));
            }
            if (ExistPositions(Gs_usdchf_140, G_cmd_260, MagicNo + 1) == 0) {
               G_comment_520 = DoubleToStr(MagicNo + 1, 0) + ":H";
               if (OrderSend(Gs_usdchf_140, G_cmd_260, G_lots_336, G_price_304, G_slippage_244, 0, 0, G_comment_520, MagicNo + 1, -1) > 0) {
                  if (Gi_232) PlaySound("expert.wav");
               } else Print(Gs_usdchf_140, ": ", Val2String(G_cmd_260), ", ", MagicNo + 1, " : ", ErrorDescription(GetLastError()));
            }
         }
         if (Gs_usdjpy_172 != "" && Li_8 && Gi_168) {
            if (ExistPositions(Gs_eurusd_528, G_cmd_252, MagicNo + 2) == 0) {
               G_comment_520 = DoubleToStr(MagicNo + 2, 0) + ":B";
               if (OrderSend(Gs_eurusd_528, G_cmd_252, G_lots_320, G_price_288, G_slippage_236, 0, 0, G_comment_520, MagicNo + 2, -1) > 0) {
                  if (Gi_232) PlaySound("expert.wav");
               } else Print(Gs_eurusd_528, ": ", Val2String(G_cmd_252), ", ", MagicNo + 2, " : ", ErrorDescription(GetLastError()));
            }
            if (ExistPositions(Gs_usdjpy_172, G_cmd_264, MagicNo + 2) == 0) {
               G_comment_520 = DoubleToStr(MagicNo + 3, 0) + ":H";
               if (OrderSend(Gs_usdjpy_172, G_cmd_264, G_lots_344, G_price_312, G_slippage_248, 0, 0, G_comment_520, MagicNo + 2, -1) > 0) {
                  if (Gi_232) PlaySound("expert.wav");
               } else Print(Gs_usdjpy_172, ": ", Val2String(G_cmd_264), ", ", MagicNo + 2, " : ", ErrorDescription(GetLastError()));
            }
         }
      }
   }
   if (Gi_480) {
      if (TotalCurProfit(MagicNo) > Gd_464) {
         if (CloseHedge(MagicNo)) {
         }
      }
   } else {
      if (TotalSwapnProfit(MagicNo) > Gd_464) {
         if (CloseHedge(MagicNo)) {
         }
      }
   }
   if (Gi_484) {
      if (TotalCurProfit(MagicNo + 1) > Gd_464) {
         if (CloseHedge(MagicNo + 1)) {
         }
      }
   } else {
      if (TotalSwapnProfit(MagicNo + 1) > Gd_464) {
         if (CloseHedge(MagicNo + 1)) {
         }
      }
   }
   if (Gi_488) {
      if (TotalCurProfit(MagicNo + 2) > Gd_464) {
         if (CloseHedge(MagicNo + 2)) {
         }
      }
   } else {
      if (TotalSwapnProfit(MagicNo + 2) > Gd_464) {
         if (CloseHedge(MagicNo + 2)) {
         }
      }
   }
   if (ShowStatus) {
      Comment("\nTradingAllowed : ", bool2string(TradingAllowed) + Gs_496 + Gs_504 + Gs_512 
         + "\n--------------------------------" 
         + "\nCurBalance: ", DoubleToStr(AccountBalance(), 2) 
         + "\nCurEquity : ", DoubleToStr(AccountEquity(), 2) 
         + "\nProfit/Loss: " + DoubleToStr(DailyProfit(MagicNo + 1) + DailyProfit(MagicNo) + DailyProfit(MagicNo + 2), 2) 
         + "\n" 
      + "\nExpire date: " + TimeToStr(Gi_536, TIME_DATE));
   } else Comment("");
   if (Gd_448 > 0.0)
      if (TotalSwapnProfit(MagicNo) <= -Gd_448) CloseHedge(MagicNo);
   if (TotalSwapnProfit(MagicNo + 1) <= -Gd_448) CloseHedge(MagicNo + 1);
   if (TotalSwapnProfit(MagicNo + 2) <= -Gd_448) CloseHedge(MagicNo + 2);
   return (0);
}

int CloseHedge(int A_magic_0) {
   for (int pos_4 = OrdersTotal() - 1; pos_4 >= 0; pos_4--) {
      if (OrderSelect(pos_4, SELECT_BY_POS, MODE_TRADES) && OrderMagicNumber() == A_magic_0)
         if (OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), MarketInfo(OrderSymbol(), MODE_SPREAD), CLR_NONE)) Gi_472 = TRUE;
   }
   if (Gi_472 || Gi_476) {
      if (!(Gi_232)) return (1);
      PlaySound("ok.wav");
      return (1);
   }
   Print("CloseHedge Error: ", ErrorDescription(GetLastError()));
   RefreshRates();
   return (0);
}

double Lots(string A_symbol_0, double Ad_8) {
   if (Ad_8 > 1.0) Ad_8 = 1;
   double Ld_16 = MarketInfo(A_symbol_0, MODE_MINLOT);
   double Ld_24 = MarketInfo(A_symbol_0, MODE_MAXLOT);
   double lotstep_32 = MarketInfo(A_symbol_0, MODE_LOTSTEP);
   Gd_280 = NormalizeDouble(Base(Gi_84) * Ad_8 / AccountLeverage() / 10.0, 2);
   Gd_280 = NormalizeDouble(Gd_280 / lotstep_32, 0) * lotstep_32;
   if (Gd_280 < Ld_16) Gd_280 = Ld_16;
   if (Gd_280 > Ld_24) Gd_280 = Ld_24;
   return (Gd_280);
}

double Base(int Ai_0) {
   int Li_4 = Ai_0;
   if (Li_4 != 1) return (0.0);
   return (AccountBalance());
}

double TotalCurProfit(int A_magic_0) {
   double Ld_ret_4 = 0;
   for (int pos_12 = 0; pos_12 < OrdersTotal(); pos_12++) {
      OrderSelect(pos_12, SELECT_BY_POS, MODE_TRADES);
      if (OrderMagicNumber() == A_magic_0) Ld_ret_4 += OrderProfit();
   }
   return (Ld_ret_4);
}

double TotalSwapnProfit(int A_magic_0) {
   double Ld_4 = 0;
   double Ld_12 = 0;
   for (int pos_20 = 0; pos_20 < OrdersTotal(); pos_20++) {
      OrderSelect(pos_20, SELECT_BY_POS, MODE_TRADES);
      if (OrderMagicNumber() == A_magic_0) {
         Ld_4 += OrderProfit();
         Ld_12 += OrderSwap();
      }
   }
   return (Ld_4 + Ld_12);
}

double DailyProfit(int A_magic_0) {
   double Ld_ret_4 = 0;
   int hist_total_12 = OrdersHistoryTotal();
   for (int pos_16 = 0; pos_16 < hist_total_12; pos_16++) {
      OrderSelect(pos_16, SELECT_BY_POS, MODE_HISTORY);
      if (OrderMagicNumber() == A_magic_0)
         if (TimeDayOfYear(OrderCloseTime()) == DayOfYear() && TimeYear(OrderCloseTime()) == Year()) Ld_ret_4 += OrderProfit();
   }
   return (Ld_ret_4);
}

string Val2String(int Ai_0) {
   string Ls_ret_4;
   switch (Ai_0) {
   case 0:
      Ls_ret_4 = "BUY";
      break;
   case 1:
      Ls_ret_4 = "SELL";
      break;
   case 2:
      Ls_ret_4 = "BUYLIMIT";
      break;
   case 3:
      Ls_ret_4 = "SELLLIMIT";
      break;
   case 4:
      Ls_ret_4 = "BUYSTOP";
      break;
   case 5:
      Ls_ret_4 = "SELLSTOP";
      break;
   default:
      Ls_ret_4 = "NONE";
   }
   return (Ls_ret_4);
}

string bool2string(bool Ai_0) {
   if (Ai_0) return ("Yes");
   return ("No");
}

double symboldif(string A_symbol_0, int Ai_8) {
   return (iClose(A_symbol_0, 0, Ai_8) - iMA(A_symbol_0, 0, G_period_276, 0, MODE_SMA, PRICE_CLOSE, Ai_8));
}

double powdif(double Ad_0) {
   return (MathPow(Ad_0, 2));
}

double u(double Ad_0, double Ad_8) {
   return (Ad_0 * Ad_8);
}

double Cor(string As_0, string As_8) {
   double Ld_16 = 0;
   double Ld_24 = 0;
   double Ld_32 = 0;
   for (int Li_40 = G_period_276 - 1; Li_40 >= 0; Li_40--) {
      Ld_16 += u(symboldif(As_0, Li_40), symboldif(As_8, Li_40));
      Ld_24 += powdif(symboldif(As_0, Li_40));
      Ld_32 += powdif(symboldif(As_8, Li_40));
   }
   double Ld_44 = MathSqrt(Ld_24 * Ld_32);
   if (Ld_44 > 0.0) return (Ld_16 / Ld_44);
   return (0.0);
}

int ExistPositions(string A_symbol_0, int Ai_unused_8, int A_magic_12) {
   int count_16 = 0;
   for (int pos_20 = 0; pos_20 < OrdersTotal(); pos_20++)
      if (OrderSelect(pos_20, SELECT_BY_POS, MODE_TRADES) && OrderSymbol() == A_symbol_0 && OrderMagicNumber() == A_magic_12) count_16++;
   return (count_16);
}

Recommend