Navigation:Home > Content >

FINEXX_Cor~.mq4

Time: 2017-07-22 | Download file:FINEXX_Cor~.mq4

/*
   G e n e r a t e d  by ex4-to-mq4 decompiler FREEWARE 4.0.509.5
   Website: h Ttp : / / WwW. M e t a QU o t ES. nEt
   E-mail :  S U PP O R t @ M E T aq U O t eS .NET
*/
#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 int MagicNo = 7;
extern bool ShowStatus = TRUE;
bool Gi_208 = FALSE;
int G_slippage_212;
int G_slippage_216;
int G_slippage_220;
int G_slippage_224;
int G_cmd_228 = -1;
int G_cmd_232 = -1;
int G_cmd_236 = -1;
int G_cmd_240 = -1;
int Gi_244;
int G_period_248 = 12;
int G_period_252 = 5;
double Gd_256;
double G_price_264;
double G_price_272;
double G_price_280;
double G_price_288;
double G_lots_296;
double G_lots_304;
double G_lots_312;
double G_lots_320;
double G_swapshort_328;
double G_swaplong_336;
double G_swapshort_344;
double G_swapshort_352;
double G_swapshort_360;
double G_swaplong_368;
double G_swaplong_376;
double G_swaplong_384;
double Gd_392;
double Gd_400;
double Gd_408;
double Gd_416;
double Gd_424;
double Gd_432;
double Gd_440;
bool Gi_448 = FALSE;
bool Gi_452 = FALSE;
bool Gi_456;
bool Gi_460;
bool Gi_464;
bool Gi_unused_468 = TRUE;
string Gs_472 = "";
string Gs_480 = "";
string Gs_488 = "";
string G_comment_496 = "";
string Gs_eurusd_504 = "EURUSD";
int Gi_512 = D'24.02.2007 01:59';

int init() {
   G_swapshort_328 = MarketInfo(Gs_eurusd_504, MODE_SWAPSHORT);
   G_swaplong_336 = MarketInfo(Gs_eurusd_504, MODE_SWAPLONG);
   G_swapshort_344 = MarketInfo(Gs_usdchf_108, MODE_SWAPSHORT);
   G_swaplong_368 = MarketInfo(Gs_usdchf_108, MODE_SWAPLONG);
   G_swapshort_352 = MarketInfo(Gs_usdchf_140, MODE_SWAPSHORT);
   G_swaplong_376 = MarketInfo(Gs_usdchf_140, MODE_SWAPLONG);
   G_swapshort_360 = MarketInfo(Gs_usdjpy_172, MODE_SWAPSHORT);
   G_swaplong_384 = MarketInfo(Gs_usdjpy_172, MODE_SWAPLONG);
   Gd_416 = 100.0 * LotSize;
   Gd_424 = 250.0 * LotSize;
   Gd_432 = 1000.0 * LotSize;
   return (0);
}

int start() {
   bool Li_0;
   bool Li_4;
   bool Li_8;
   Gd_440 = Gd_416;
   if (SMA(0) > SMA(1) && SMA(1) > SMA(2)) Gi_244 = 1;
   else {
      if (SMA(0) < SMA(1) && SMA(1) < SMA(2)) Gi_244 = -1;
      else Gi_244 = 0;
   }
   if (Gi_80) {
      G_lots_296 = Lots(Gs_eurusd_504, Gd_88);
      G_lots_304 = Lots(Gs_usdchf_108, Gd_88 * Gd_120);
      G_lots_312 = Lots(Gs_usdchf_140, Gd_88 * Gd_152);
      G_lots_320 = Lots(Gs_usdjpy_172, Gd_88 * Gd_184);
   } else {
      G_lots_296 = LotSize;
      G_lots_304 = NormalizeDouble(LotSize * Gd_120, 1);
      G_lots_312 = NormalizeDouble(LotSize * Gd_152, 1);
      G_lots_320 = NormalizeDouble(LotSize * Gd_184, 1);
   }
   G_slippage_212 = MarketInfo(Gs_eurusd_504, MODE_SPREAD);
   if (G_slippage_212 == 0) G_slippage_212 = MathRound((MarketInfo(Gs_eurusd_504, MODE_ASK) - MarketInfo(Gs_eurusd_504, MODE_BID)) / MarketInfo(Gs_eurusd_504, MODE_POINT));
   if (Gi_244 == 1) {
      G_cmd_228 = 0;
      G_price_264 = MarketInfo(Gs_eurusd_504, MODE_ASK);
   }
   if (Gi_244 == -1) {
      G_cmd_228 = 1;
      G_price_264 = MarketInfo(Gs_eurusd_504, MODE_BID);
   }
   if (Gs_usdchf_108 != "" && Gi_104) {
      Gd_392 = Cor(Gs_eurusd_504, Gs_usdchf_108);
      G_slippage_216 = MarketInfo(Gs_usdchf_108, MODE_SPREAD);
      if (G_slippage_216 == 0) G_slippage_216 = 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_392 <= Gd_128 && Gd_432 > DailyProfit(MagicNo) + DailyProfit(MagicNo + 1) + DailyProfit(MagicNo + 2)) Li_0 = TRUE;
      else {
         if (Gd_128 < 0.0 && Gd_392 >= Gd_128 && Gd_432 > DailyProfit(MagicNo) + DailyProfit(MagicNo + 1) + DailyProfit(MagicNo + 2)) Li_0 = TRUE;
         else Li_0 = FALSE;
      }
      if (Gi_244 == 1) {
         if (Gi_116) {
            G_cmd_232 = 0;
            G_price_272 = MarketInfo(Gs_usdchf_108, MODE_ASK);
            Gi_456 = G_swaplong_336 * G_lots_296 + G_swaplong_368 * G_lots_304 > 0.0;
         } else {
            G_cmd_232 = 1;
            G_price_272 = MarketInfo(Gs_usdchf_108, MODE_BID);
            Gi_456 = G_swaplong_336 * G_lots_296 + G_swapshort_344 * G_lots_304 > 0.0;
         }
      }
      if (Gi_244 == -1) {
         if (Gi_116) {
            G_cmd_232 = 1;
            G_price_272 = MarketInfo(Gs_usdchf_108, MODE_BID);
            Gi_456 = G_swaplong_336 * G_lots_296 + G_swapshort_344 * G_lots_304 > 0.0;
         } else {
            G_cmd_232 = 0;
            G_price_272 = MarketInfo(Gs_usdchf_108, MODE_ASK);
            Gi_456 = G_swaplong_336 * G_lots_296 + G_swaplong_368 * G_lots_304 > 0.0;
         }
      }
      Gs_472 = "\n--------------------------------" 
         + "\n" 
         + Gs_eurusd_504 + "->" + Val2String(G_cmd_228) + " ~ " + Gs_usdchf_108 + "->" + Val2String(G_cmd_232) 
         + "\n" 
         + Gs_eurusd_504 + "->" + DoubleToStr(G_lots_296, 2) + " ~ " + Gs_usdchf_108 + "->" + DoubleToStr(G_lots_304, 2) 
         + "\nMagic No. : " + MagicNo 
      + "\nOverAllProfit : " + DoubleToStr(TotalSwapnProfit(MagicNo), 2);
   } else Gs_472 = "";
   if (Gs_usdchf_140 != "" && Gi_136) {
      Gd_400 = Cor(Gs_eurusd_504, Gs_usdchf_140);
      G_slippage_220 = MarketInfo(Gs_usdchf_140, MODE_SPREAD);
      if (G_slippage_220 == 0) G_slippage_220 = 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_400 <= Gd_160 && Gd_432 > DailyProfit(MagicNo) + DailyProfit(MagicNo + 1) + DailyProfit(MagicNo + 2)) Li_4 = TRUE;
      else {
         if (Gd_160 < 0.0 && Gd_400 >= Gd_160 && Gd_432 > DailyProfit(MagicNo) + DailyProfit(MagicNo + 1) + DailyProfit(MagicNo + 2)) Li_4 = TRUE;
         else Li_4 = FALSE;
      }
      if (Gi_244 == 1) {
         if (Gi_148) {
            G_cmd_236 = 0;
            G_price_280 = MarketInfo(Gs_usdchf_140, MODE_ASK);
            Gi_460 = G_swaplong_336 * G_lots_296 + G_swaplong_376 * G_lots_312 > 0.0;
         } else {
            G_cmd_236 = 1;
            G_price_280 = MarketInfo(Gs_usdchf_140, MODE_BID);
            Gi_460 = G_swaplong_336 * G_lots_296 + G_swapshort_352 * G_lots_312 > 0.0;
         }
      }
      if (Gi_244 == -1) {
         if (Gi_148) {
            G_cmd_236 = 1;
            G_price_280 = MarketInfo(Gs_usdchf_140, MODE_BID);
            Gi_460 = G_swaplong_336 * G_lots_296 + G_swapshort_352 * G_lots_312 > 0.0;
         } else {
            G_cmd_236 = 0;
            G_price_280 = MarketInfo(Gs_usdchf_140, MODE_ASK);
            Gi_460 = G_swaplong_336 * G_lots_296 + G_swaplong_376 * G_lots_312 > 0.0;
         }
      }
      Gs_480 = "\n--------------------------------" 
         + "\n" 
         + Gs_eurusd_504 + "->" + Val2String(G_cmd_228) + " ~ " + Gs_usdchf_140 + "->" + Val2String(G_cmd_236) 
         + "\n" 
         + Gs_eurusd_504 + "->" + DoubleToStr(G_lots_296, 2) + " ~ " + Gs_usdchf_140 + "->" + DoubleToStr(G_lots_312, 2) 
         + "\nMagic No. : " + DoubleToStr(MagicNo + 1, 0) 
         + "\nOverAllProfit : " + DoubleToStr(TotalSwapnProfit(MagicNo + 1), 2) 
      + "\nTotalprofit: " + DoubleToStr(DailyProfit(MagicNo + 1), 2);
   } else Gs_480 = "";
   if (Gs_usdjpy_172 != "" && Gi_168) {
      Gd_408 = Cor(Gs_eurusd_504, Gs_usdjpy_172);
      G_slippage_224 = MarketInfo(Gs_usdjpy_172, MODE_SPREAD);
      if (G_slippage_224 == 0) G_slippage_224 = 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_408 <= Gd_192 && Gd_432 > DailyProfit(MagicNo) + DailyProfit(MagicNo + 1) + DailyProfit(MagicNo + 2)) Li_8 = TRUE;
      else {
         if (Gd_192 < 0.0 && Gd_408 >= Gd_192 && Gd_432 > DailyProfit(MagicNo) + DailyProfit(MagicNo + 1) + DailyProfit(MagicNo + 2)) Li_8 = TRUE;
         else Li_8 = FALSE;
      }
      if (Gi_244 == 1) {
         if (Gi_180) {
            G_cmd_240 = 0;
            G_price_288 = MarketInfo(Gs_usdjpy_172, MODE_ASK);
            Gi_464 = G_swaplong_336 * G_lots_296 + G_swaplong_384 * G_lots_320 > 0.0;
         } else {
            G_cmd_240 = 1;
            G_price_288 = MarketInfo(Gs_usdjpy_172, MODE_BID);
            Gi_464 = G_swaplong_336 * G_lots_296 + G_swapshort_360 * G_lots_320 > 0.0;
         }
      }
      if (Gi_244 == -1) {
         if (Gi_180) {
            G_cmd_240 = 1;
            G_price_288 = MarketInfo(Gs_usdjpy_172, MODE_BID);
            Gi_464 = G_swaplong_336 * G_lots_296 + G_swapshort_360 * G_lots_320 > 0.0;
         } else {
            G_cmd_240 = 0;
            G_price_288 = MarketInfo(Gs_usdjpy_172, MODE_ASK);
            Gi_464 = G_swaplong_336 * G_lots_296 + G_swaplong_384 * G_lots_320 > 0.0;
         }
      }
      Gs_488 = "\n--------------------------------" 
         + "\n" 
         + Gs_eurusd_504 + "->" + Val2String(G_cmd_228) + " ~ " + Gs_usdjpy_172 + "->" + Val2String(G_cmd_240) 
         + "\n" 
         + Gs_eurusd_504 + "->" + DoubleToStr(G_lots_296, 2) + " ~ " + Gs_usdjpy_172 + "->" + DoubleToStr(G_lots_320, 2) 
         + "\nMagic No. : " + DoubleToStr(MagicNo + 2, 0) 
         + "\nOverAllProfit : " + DoubleToStr(TotalSwapnProfit(MagicNo + 2), 2) 
      + "\nTotalprofit: " + DoubleToStr(DailyProfit(MagicNo + 2), 2);
   } else Gs_488 = "";
   if (TimeCurrent() > Gi_512) Alert("EA expired");
   else {
      if (TradingAllowed && Gi_244 == 1 || Gi_244 == -1) {
         if (Gs_usdchf_108 != "" && Li_0 && Gi_104) {
            if (ExistPositions(Gs_eurusd_504, G_cmd_228, MagicNo) == 0) {
               G_comment_496 = DoubleToStr(MagicNo, 0) + ":B, Finexx_Cor";
               if (OrderSend(Gs_eurusd_504, G_cmd_228, G_lots_296, G_price_264, G_slippage_212, 0, 0, G_comment_496, MagicNo, -1) > 0) {
                  if (Gi_208) PlaySound("expert.wav");
               } else Print(Gs_eurusd_504, ": ", Val2String(G_cmd_228), ", ", MagicNo, " : ", ErrorDescription(GetLastError()));
            }
            if (ExistPositions(Gs_usdchf_108, G_cmd_232, MagicNo) == 0) {
               G_comment_496 = DoubleToStr(MagicNo, 0) + ":H, Finexx_Cor";
               if (OrderSend(Gs_usdchf_108, G_cmd_232, G_lots_304, G_price_272, G_slippage_216, 0, 0, G_comment_496, MagicNo, -1) > 0) {
                  if (Gi_208) PlaySound("expert.wav");
               } else Print(Gs_usdchf_108, ": ", Val2String(G_cmd_232), ", ", MagicNo, " : ", ErrorDescription(GetLastError()));
            }
         }
         if (Gs_usdchf_140 != "" && Li_4 && Gi_136) {
            if (ExistPositions(Gs_eurusd_504, G_cmd_228, MagicNo + 1) == 0) {
               G_comment_496 = DoubleToStr(MagicNo + 1, 0) + ":B";
               if (OrderSend(Gs_eurusd_504, G_cmd_228, G_lots_296, G_price_264, G_slippage_212, 0, 0, G_comment_496, MagicNo + 1, -1) > 0) {
                  if (Gi_208) PlaySound("expert.wav");
               } else Print(Gs_eurusd_504, ": ", Val2String(G_cmd_228), ", ", MagicNo + 1, " : ", ErrorDescription(GetLastError()));
            }
            if (ExistPositions(Gs_usdchf_140, G_cmd_236, MagicNo + 1) == 0) {
               G_comment_496 = DoubleToStr(MagicNo + 1, 0) + ":H";
               if (OrderSend(Gs_usdchf_140, G_cmd_236, G_lots_312, G_price_280, G_slippage_220, 0, 0, G_comment_496, MagicNo + 1, -1) > 0) {
                  if (Gi_208) PlaySound("expert.wav");
               } else Print(Gs_usdchf_140, ": ", Val2String(G_cmd_236), ", ", MagicNo + 1, " : ", ErrorDescription(GetLastError()));
            }
         }
         if (Gs_usdjpy_172 != "" && Li_8 && Gi_168) {
            if (ExistPositions(Gs_eurusd_504, G_cmd_228, MagicNo + 2) == 0) {
               G_comment_496 = DoubleToStr(MagicNo + 2, 0) + ":B";
               if (OrderSend(Gs_eurusd_504, G_cmd_228, G_lots_296, G_price_264, G_slippage_212, 0, 0, G_comment_496, MagicNo + 2, -1) > 0) {
                  if (Gi_208) PlaySound("expert.wav");
               } else Print(Gs_eurusd_504, ": ", Val2String(G_cmd_228), ", ", MagicNo + 2, " : ", ErrorDescription(GetLastError()));
            }
            if (ExistPositions(Gs_usdjpy_172, G_cmd_240, MagicNo + 2) == 0) {
               G_comment_496 = DoubleToStr(MagicNo + 3, 0) + ":H";
               if (OrderSend(Gs_usdjpy_172, G_cmd_240, G_lots_320, G_price_288, G_slippage_224, 0, 0, G_comment_496, MagicNo + 2, -1) > 0) {
                  if (Gi_208) PlaySound("expert.wav");
               } else Print(Gs_usdjpy_172, ": ", Val2String(G_cmd_240), ", ", MagicNo + 2, " : ", ErrorDescription(GetLastError()));
            }
         }
      }
   }
   if (Gi_456) {
      if (TotalCurProfit(MagicNo) > Gd_440) {
         if (CloseHedge(MagicNo)) {
         }
      }
   } else {
      if (TotalSwapnProfit(MagicNo) > Gd_440) {
         if (CloseHedge(MagicNo)) {
         }
      }
   }
   if (Gi_460) {
      if (TotalCurProfit(MagicNo + 1) > Gd_440) {
         if (CloseHedge(MagicNo + 1)) {
         }
      }
   } else {
      if (TotalSwapnProfit(MagicNo + 1) > Gd_440) {
         if (CloseHedge(MagicNo + 1)) {
         }
      }
   }
   if (Gi_464) {
      if (TotalCurProfit(MagicNo + 2) > Gd_440) {
         if (CloseHedge(MagicNo + 2)) {
         }
      }
   } else {
      if (TotalSwapnProfit(MagicNo + 2) > Gd_440) {
         if (CloseHedge(MagicNo + 2)) {
         }
      }
   }
   if (ShowStatus) {
      Comment("\nTradingAllowed : ", bool2string(TradingAllowed) + Gs_472 + Gs_480 + Gs_488 
         + "\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_512, TIME_DATE));
   } else Comment("");
   if (Gd_424 > 0.0)
      if (TotalSwapnProfit(MagicNo) <= -Gd_424) CloseHedge(MagicNo);
   if (TotalSwapnProfit(MagicNo + 1) <= -Gd_424) CloseHedge(MagicNo + 1);
   if (TotalSwapnProfit(MagicNo + 2) <= -Gd_424) 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_448 = TRUE;
   }
   if (Gi_448 || Gi_452) {
      if (!(Gi_208)) 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_256 = NormalizeDouble(Base(Gi_84) * Ad_8 / AccountLeverage() / 10.0, 2);
   Gd_256 = NormalizeDouble(Gd_256 / lotstep_32, 0) * lotstep_32;
   if (Gd_256 < Ld_16) Gd_256 = Ld_16;
   if (Gd_256 > Ld_24) Gd_256 = Ld_24;
   return (Gd_256);
}

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 SMA(int Ai_0) {
   double ima_4;
   ima_4 = iMA(Gs_eurusd_504, 0, G_period_248, 0, MODE_SMA, PRICE_CLOSE, Ai_0);
   return (ima_4);
}

double symboldif(string A_symbol_0, int Ai_8) {
   return (iClose(A_symbol_0, 0, Ai_8) - iMA(A_symbol_0, 0, G_period_252, 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_252 - 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