Navigation:Home > Content >

ICs_EA.mq4

Time: 2013-10-16 | Download file:ICs_EA.mq4

#property copyright "Copyright © 2011"
#property link      "http://www.metaquotes.net"
#property show_inputs

#include 

extern string Configuration = "* Config";
extern bool Show_Debug = FALSE;
extern bool Verbose = FALSE;
extern bool Mode_HighSpeed = TRUE;
extern bool Mode_Safe = FALSE;
extern bool Mode_MaxOrders = TRUE;
bool True_False_1 = FALSE;
extern int Magic = 111223;
extern string OrderCmt = "IC'sEA";
extern double TakeProfit = 30.0;
extern double StopLoss = 45.0;
extern double distance = 3.0;
extern string Money_Management = "* Money Management";
double Lots = 0.1;
bool True_False_2 = TRUE;
extern double Min_Lots = 0.01;
extern double Max_Lots = 1000;
extern double Risk = 15.0;
double Equity = 100000000000.0;
string gs_unused_180 = "* Scalping Factors";
double Scalp_factor_1 = 15.0;
double Scalp_factor_2 = 40.0;
double Scalp_factor_3 = 145.0;
double Scalp_factor_4 = 270.0;
double Scalp_factor_5 = 0.4;
double Scalp_factor_6 = 0.3333333333;
double Scalp_factor_7 = 0.0;
extern string SL_TP_Trailing = "* SL / TP / Trailing";
extern double Trailing_Resolution = 0;
extern int BB_Per = 3;
extern double BB_Dev = 2.0;
extern int BBDistance = 100;
double gd_260 = 0.0;
double gd_268 = 20.0;
extern bool Trailing_Stop = TRUE;
bool True_False_3 = TRUE;
string gs_304;
int digits = 0;
double digits_liczba_00001 = 0.0;
int g_slippage_324 = 60;
double gda_328[30];
double gda_332[30];
int gia_336[30];
double gd_340 = 1.0;
double gd_348;
bool gi_356;
double gd_360;
bool True_False_4 = FALSE;
double gd_372 = 1.0;
double Comission_na_profit_w_pips = 0.0;
int gi_388 = 0;
int g_time_392 = 0;
int g_count_396 = 0;
double Spred_pozycji[600];
int Ilosc_pozycji_spred = 0;
bool True_False_5 = TRUE;
double SL_3 = 5.0;
double SL_2 = 10.0;
double SL_1 = 40.0;
bool True_False_6 = FALSE;
double SL_mh_2 = 5.0;
double SL_mh_3 = 10.0;
double SL_mh_4 = 40.0;
bool gi_464 = FALSE;
bool gi_unused_468 = FALSE;
string gs_472 = "Valid user";
string gs_480;
int gia_488[] = {0};
int gia_492[] = {0};
int AccNum;

int init() {
   ArrayInitialize(Spred_pozycji, 0);
   digits = 5;
   digits_liczba_00001 = 0.00001;
   if (Digits < 5) g_slippage_324 = 0;
   else gi_388 = -1;
   gia_492[0]=1;
   start();
   return (0);
}

int start() {
   if (digits == 0) {
      init();
      return;
   }
   if (gia_492[0] == TRUE) {
         f0_2(gda_328, gda_332, gia_336, gd_340);
         f0_0(Period());
   }
   return (0);
}

void f0_0(int a_timeframe_0) {
   int ticket_16;
   int li_24;
   double Cena_pierwszej_poz_BUY;
   double Cena_pierwszej_poz_SELL;
   bool bool_28;
   double Profit_w_pips;
   bool Stop_level_1;
   double Stop_Level_2;
   double Stop_Level_3;
   double Stop_level_Scalping;
   int datetime_236;
   int li_240;
   double LOT_wyliczenie_wielkosci;
   double order_stoploss_260;
   double order_takeprofit_268;
   double Profit_minOP_minCommision;
   int li_292;
   int li_296;
   string ls_300;
   bool li_308;
   if (g_time_392 < Time[0]) {
      g_time_392 = Time[0];
      g_count_396 = 0;
   } else g_count_396++;
   double ihigh_64 = iHigh(Symbol(), a_timeframe_0, 0);
   double ilow_72 = iLow(Symbol(), a_timeframe_0, 0); 
   double ibands_Upper = iBands(Symbol(), a_timeframe_0, BB_Per, BB_Dev, 0, PRICE_OPEN, MODE_UPPER, 0);  
   double ibands_Lower= iBands(Symbol(), a_timeframe_0, BB_Per, BB_Dev, 0, PRICE_OPEN, MODE_LOWER, 0);   
   double ibands_kanal = ibands_Upper -ibands_Lower ;
   bool Cena_wybicia_gora = Bid >= ibands_Lower + ibands_kanal / 2.0;
   if (!True_False_4) {
      for (int Pozycje_ilosc = OrdersTotal() - 1; Pozycje_ilosc >= 0; Pozycje_ilosc--) {
         OrderSelect(Pozycje_ilosc, SELECT_BY_POS, MODE_TRADES);
         if (OrderSymbol() == Symbol() && OrderCloseTime() != 0 && OrderClosePrice() != OrderOpenPrice() && OrderProfit() != 0.0 && OrderComment() != "partial close" && StringFind(OrderComment(), "[sl]from #") == -1 &&
            StringFind(OrderComment(), "[tp]from #") == -1) {
            True_False_4 = TRUE;
            Profit_w_pips = MathAbs(OrderProfit() / (OrderClosePrice() - OrderOpenPrice()));
            gd_372 = Profit_w_pips / OrderLots() / MarketInfo(Symbol(), MODE_LOTSIZE);
            Comission_na_profit_w_pips = (-OrderCommission()) / Profit_w_pips;
            Print("Commission_Rate : " + f0_3(Comission_na_profit_w_pips));
            break;
         }
      }
   }
   if (!True_False_4) {
      for (Pozycje_ilosc = OrdersHistoryTotal() - 1; Pozycje_ilosc >= 0; Pozycje_ilosc--) {
         OrderSelect(Pozycje_ilosc, SELECT_BY_POS, MODE_HISTORY);
         if (OrderSymbol() == Symbol() && OrderCloseTime() != 0 && OrderClosePrice() != OrderOpenPrice() && OrderProfit() != 0.0 && OrderComment() != "partial close" && StringFind(OrderComment(), "[sl]from #") == -1 &&
            StringFind(OrderComment(), "[tp]from #") == -1) {
            True_False_4 = TRUE;
            Profit_w_pips = MathAbs(OrderProfit() / (OrderClosePrice() - OrderOpenPrice()));
            gd_372 = Profit_w_pips / OrderLots() / MarketInfo(Symbol(), MODE_LOTSIZE);
            Comission_na_profit_w_pips = (-OrderCommission()) / Profit_w_pips;
            Print("Commission_Rate : " + f0_3(Comission_na_profit_w_pips));
            break;
         }
      }
   }
   double Broker_Stop_Level = MarketInfo(Symbol(), MODE_STOPLEVEL) * Point;
   double spred_1 = Ask - Bid;
  // double Stop_Level_4 = 0.5;
   double Stop_Level_4 = gd_260 * digits_liczba_00001;
   if (Stop_Level_4 < Broker_Stop_Level - 5.0 * digits_liczba_00001) {
      Stop_level_1 = True_False_6;
      Stop_Level_2 = SL_1 * digits_liczba_00001;
      Stop_Level_4 = SL_2 * digits_liczba_00001;
      Stop_Level_3 = SL_3 * digits_liczba_00001;
   } else {
      if (!Mode_HighSpeed) {
         Stop_level_1 = gi_464;
         Stop_Level_2 = SL_mh_4 * digits_liczba_00001;
         Stop_Level_4 = SL_mh_3 * digits_liczba_00001;
         Stop_Level_3 = SL_mh_2 * digits_liczba_00001;
      } else {
         Stop_level_1 = True_False_3;
         Stop_Level_2 = gd_268 * digits_liczba_00001;
         Stop_Level_4 = gd_260 * digits_liczba_00001;
         Stop_Level_3 = Trailing_Resolution * digits_liczba_00001;
      }
   }
   Stop_Level_2 = MathMax(Stop_Level_2, Broker_Stop_Level);
   if (Stop_level_1) Stop_Level_4 = MathMax(Stop_Level_4, Broker_Stop_Level);
   double ld_unused_144 = Spred_pozycji[0];
   ArrayCopy(Spred_pozycji, Spred_pozycji, 0, 1, 29);
   Spred_pozycji[29] = spred_1;
   if (Ilosc_pozycji_spred < 600) Ilosc_pozycji_spred++;
   double Spred_Suma_Pozycji = 0;
   Pozycje_ilosc = 29;
   for (int count_8 = 0; count_8 < Ilosc_pozycji_spred; count_8++) {
      Spred_Suma_Pozycji += Spred_pozycji[Pozycje_ilosc];
      Pozycje_ilosc--;
   }
   double ld_160 = Spred_Suma_Pozycji / Ilosc_pozycji_spred;
   if (!True_False_4 && ld_160 < 15.0 * digits_liczba_00001) Comission_na_profit_w_pips = 15.0 * digits_liczba_00001 - ld_160;
   double Cena_Ask_plusComission = f0_5(Ask + Comission_na_profit_w_pips);
   double Cena_Bid_minusComission = f0_5(Bid - Comission_na_profit_w_pips);
   double ld_184 = ld_160 + Comission_na_profit_w_pips;
   
   double ld_192;
   double ld_200;
   double ld_208 = ihigh_64 - ilow_72;

   double limitTe;
   string mode=Mode_HighSpeed+"-"+Mode_Safe+"-0"; 
        if(mode=="0-0-0") { ld_192=0.24; ld_200=0.0018; limitTe=0.00250; }
   else if(mode=="0-1-0") { ld_192=0.68; ld_200=0.0023; limitTe=0.00300; }
   else if(mode=="1-0-0") { ld_192=0.28; ld_200=0.0018; limitTe=0.00100; }
   else if(mode=="1-1-0") { ld_192=0.56; ld_200=0.0022; limitTe=0.00250; }
   
   if(ld_208>limitTe) { 
   if (Bid < ibands_Lower -BBDistance*Point)   int Bid_mnMAhigh_wieMAlow=-1; 
   else if (Bid > ibands_Upper +BBDistance*Point) Bid_mnMAhigh_wieMAlow=1;
    }    
   if (Scalp_factor_7 == 0.0) Stop_level_Scalping = Scalp_factor_6 * ld_200;
   else Stop_level_Scalping = Scalp_factor_7 * digits_liczba_00001;
   Stop_level_Scalping = MathMax(Broker_Stop_Level, Stop_level_Scalping);
   if (Bid == 0.0 || MarketInfo(Symbol(), MODE_LOTSIZE) == 0.0) Stop_level_Scalping = 0;
   double ld_228 = Stop_level_Scalping + ld_160 + Comission_na_profit_w_pips;
   if (True_False_5) datetime_236 = TimeCurrent() + 60.0 * MathMax(10 * a_timeframe_0, 60);
   else datetime_236 = 0;
   if (MarketInfo(Symbol(), MODE_LOTSTEP) == 0.0) li_240 = 5;
   else li_240 = f0_7(0.1, MarketInfo(Symbol(), MODE_LOTSTEP));
   if (True_False_2) {
      if (Risk < 0.001 || Risk > 1000.0) {
         Comment("ERROR -- Invalid Risk Value.");
         return;
      }
      if (AccountBalance() <= 0.0) {
         Comment("ERROR -- Account Balance is " + DoubleToStr(MathRound(AccountBalance()), 0));
         return;
      }
      if (Stop_level_Scalping != 0.0) {
         Equity = MathMax(AccountBalance(), Equity);
         LOT_wyliczenie_wielkosci = MathMin(AccountFreeMargin() * AccountLeverage() / 2.0, Equity * Risk / 100.0 * Bid / ld_228);
         Lots = LOT_wyliczenie_wielkosci / MarketInfo(Symbol(), MODE_LOTSIZE);
         Lots = NormalizeDouble(Lots, li_240);
         Lots = MathMax(Min_Lots, Lots);
         Lots = MathMax(MarketInfo(Symbol(), MODE_MINLOT), Lots);
         Lots = MathMin(Max_Lots, Lots);
         Lots = MathMin(MarketInfo(Symbol(), MODE_MAXLOT), Lots);
      }
   }
   int count_252 = 0;
   int count_256 = 0;
   for (Pozycje_ilosc = 0; Pozycje_ilosc < OrdersTotal(); Pozycje_ilosc++) {
      OrderSelect(Pozycje_ilosc, SELECT_BY_POS, MODE_TRADES);
      if (OrderMagicNumber() == Magic && OrderCloseTime() == 0) {
         if (OrderSymbol() != Symbol()) {
            count_256++;
            continue;
         }
         switch (OrderType()) {
         case OP_BUY:
            while (Trailing_Stop) {
               order_stoploss_260 = OrderStopLoss();
               order_takeprofit_268 = OrderTakeProfit();
               if (!(order_takeprofit_268 < f0_5(Cena_Ask_plusComission + Stop_Level_2) && Cena_Ask_plusComission + Stop_Level_2 - order_takeprofit_268 > Stop_Level_3)) break;
               order_stoploss_260 = f0_5(Bid - Stop_Level_2);
               order_takeprofit_268 = f0_5(Cena_Ask_plusComission + Stop_Level_2);
               bool_28 = OrderModify(OrderTicket(), 0, order_stoploss_260, order_takeprofit_268, datetime_236, Lime);
               if (bool_28) break;
               li_24 = f0_1();
               if (!(li_24)) break;
            }
            count_252++;
            break;
         case OP_SELL:
            while (Trailing_Stop) {
               order_stoploss_260 = OrderStopLoss();
               order_takeprofit_268 = OrderTakeProfit();
               if (!(order_takeprofit_268 > f0_5(Cena_Bid_minusComission - Stop_Level_2) && order_takeprofit_268 - Cena_Bid_minusComission + Stop_Level_2 > Stop_Level_3)) break;
               order_stoploss_260 = f0_5(Ask + Stop_Level_2);
               order_takeprofit_268 = f0_5(Cena_Bid_minusComission - Stop_Level_2);
               bool_28 = OrderModify(OrderTicket(), 0, order_stoploss_260, order_takeprofit_268, datetime_236, Orange);
               if (bool_28) break;
               li_24 = f0_1();
               if (!(li_24)) break;
            }
            count_252++;
            break;
         case OP_BUYSTOP:
            if (!Cena_wybicia_gora) {
               Profit_minOP_minCommision = OrderTakeProfit() - OrderOpenPrice() - Comission_na_profit_w_pips;
               while (true) {
                  if (!(f0_5(Ask + Stop_Level_4) < OrderOpenPrice() && OrderOpenPrice() - Ask - Stop_Level_4 > Stop_Level_3)) break;
                  bool_28 = OrderModify(OrderTicket(), f0_5(Ask + Stop_Level_4), f0_5(Bid + Stop_Level_4 - Profit_minOP_minCommision), f0_5(Cena_Ask_plusComission + Stop_Level_4 + Profit_minOP_minCommision), 0, Lime);
                  if (bool_28) break;
                  li_24 = f0_1();
                  if (!(li_24)) break;
               }
               count_252++;
            } else OrderDelete(OrderTicket());
            break;
         case OP_SELLSTOP:
            if (Cena_wybicia_gora) {
               Profit_minOP_minCommision = OrderOpenPrice() - OrderTakeProfit() - Comission_na_profit_w_pips;
               while (true) {
                  if (!(f0_5(Bid - Stop_Level_4) > OrderOpenPrice() && Bid - Stop_Level_4 - OrderOpenPrice() > Stop_Level_3)) break;
                  bool_28 = OrderModify(OrderTicket(), f0_5(Bid - Stop_Level_4), f0_5(Ask - Stop_Level_4 + Profit_minOP_minCommision), f0_5(Cena_Bid_minusComission - Stop_Level_4 - Profit_minOP_minCommision), 0, Orange);
                  if (bool_28) break;
                  li_24 = f0_1();
                  if (!(li_24)) break;
               }
               count_252++;
            } else OrderDelete(OrderTicket());
         }
      }
   }
   bool li_288 = FALSE;
   if (gi_388 >= 0 || gi_388 == -2) {
      li_292 = NormalizeDouble(Bid / digits_liczba_00001, 0);
      li_296 = NormalizeDouble(Ask / digits_liczba_00001, 0);
      if (li_292 % 10 != 0 || li_296 % 10 != 0) gi_388 = -1;
      else {
         if (gi_388 >= 0 && gi_388 < 10) gi_388++;
         else gi_388 = -2;
      }
   }
   if (Stop_level_Scalping != 0.0 && count_252 == 0 && Bid_mnMAhigh_wieMAlow != 0 && f0_5(ld_184) <= f0_5(Scalp_factor_2 * digits_liczba_00001) && gi_388 == -1) {
      if (Bid_mnMAhigh_wieMAlow < 0) {
         if (Stop_level_1) {
         Cena_pierwszej_poz_BUY = Ask + distance * Point;
            ticket_16 = OrderSend(Symbol(), OP_BUYSTOP, Lots, Cena_pierwszej_poz_BUY, g_slippage_324, Cena_pierwszej_poz_BUY - StopLoss * Point, Cena_pierwszej_poz_BUY + TakeProfit * Point, OrderCmt, Magic, datetime_236, Lime);
            if (ticket_16 < 0) {
               li_288 = TRUE;
               Print("ERROR BUYSTOP : " + f0_3(Ask + Stop_Level_4) + " SL:" + f0_3(Bid + Stop_Level_4 - Stop_level_Scalping) + " TP:" + f0_3(Cena_Ask_plusComission + Stop_Level_4 + Stop_level_Scalping));
            } else {
               PlaySound("news.wav");
               Print("BUYSTOP : " + f0_3(Ask + Stop_Level_4) + " SL:" + f0_3(Bid + Stop_Level_4 - Stop_level_Scalping) + " TP:" + f0_3(Cena_Ask_plusComission + Stop_Level_4 + Stop_level_Scalping));
            }
         } else {
            if (Bid - ilow_72  && gd_348 > 0.0) {
               ticket_16 = OrderSend(Symbol(), OP_BUY, Lots, Ask, g_slippage_324, 0, 0, OrderCmt, Magic, datetime_236, Lime);
               if (ticket_16 < 0) {
                  li_288 = TRUE;
                  Print("ERROR BUY Ask:" + f0_3(Ask) + " SL:" + f0_3(Bid - Stop_level_Scalping) + " TP:" + f0_3(Cena_Ask_plusComission + Stop_level_Scalping));
               } else {
                  while (true) {
                     bool_28 = OrderModify(ticket_16, 0, f0_5(Bid - Stop_level_Scalping), f0_5(Cena_Ask_plusComission + Stop_level_Scalping), datetime_236, Lime);
                     if (bool_28) break;
                     li_24 = f0_1();
                     if (!(li_24)) break;
                  }
                  PlaySound("news.wav");
                  Print("BUY Ask:" + f0_3(Ask) + " SL:" + f0_3(Bid - Stop_level_Scalping) + " TP:" + f0_3(Cena_Ask_plusComission + Stop_level_Scalping));
               }
            }
         }
      } else {
         if (Bid_mnMAhigh_wieMAlow > 0) {
            if (Stop_level_1) {
            Cena_pierwszej_poz_SELL =NormalizeDouble(Bid - distance * Point,Digits);
               ticket_16 = OrderSend(Symbol(), OP_SELLSTOP, Lots, Cena_pierwszej_poz_SELL, g_slippage_324, Cena_pierwszej_poz_SELL + StopLoss * Point, Cena_pierwszej_poz_SELL - TakeProfit * Point, OrderCmt, Magic, datetime_236, Orange);
               if (ticket_16 < 0) {
                  li_288 = TRUE;
                  Print("ERROR SELLSTOP : " + f0_3(Bid - Stop_Level_4) + " SL:" + f0_3(Ask - Stop_Level_4 + Stop_level_Scalping) + " TP:" + f0_3(Cena_Bid_minusComission - Stop_Level_4 - Stop_level_Scalping));
               } else {
                  PlaySound("news.wav");
                  Print("SELLSTOP : " + f0_3(Bid - Stop_Level_4) + " SL:" + f0_3(Ask - Stop_Level_4 + Stop_level_Scalping) + " TP:" + f0_3(Cena_Bid_minusComission - Stop_Level_4 - Stop_level_Scalping));
               }
            } else {
               if (ihigh_64 - Bid  && gd_348 < 0.0) {
                  ticket_16 = OrderSend(Symbol(), OP_SELL, Lots, Bid, g_slippage_324, 0, 0, OrderCmt, Magic, datetime_236, Orange);
                  if (ticket_16 < 0) {
                     li_288 = TRUE;
                     Print("ERROR SELL Bid:" + f0_3(Bid) + " SL:" + f0_3(Ask + Stop_level_Scalping) + " TP:" + f0_3(Cena_Bid_minusComission - Stop_level_Scalping));
                  } else {
                     while (true) {
                        bool_28 = OrderModify(ticket_16, 0, f0_5(Ask + Stop_level_Scalping), f0_5(Cena_Bid_minusComission - Stop_level_Scalping), datetime_236, Orange);
                        if (bool_28) break;
                        li_24 = f0_1();
                        if (!(li_24)) break;
                     }
                     PlaySound("news.wav");
                     Print("SELL Bid:" + f0_3(Bid) + " SL:" + f0_3(Ask + Stop_level_Scalping) + " TP:" + f0_3(Cena_Bid_minusComission - Stop_level_Scalping));
                  }
               }
            }
         }
      }
   }
   if (gi_388 >= 0) Comment("Robot is initializing...");
   else {
      if (gi_388 == -2) Comment("ERROR -- Instrument " + Symbol() + " prices should have " + digits + " fraction digits on broker account");
      else {
         ls_300 = TimeToStr(TimeCurrent()) + " tick:" + f0_6(g_count_396);
         if (Show_Debug || Verbose) {
            ls_300 = ls_300 
               + "\n" 
            + f0_3(ld_200) + " " + f0_3(Stop_level_Scalping) + " digits:" + digits + " " + gi_388 + " stopLevel:" + f0_3(Broker_Stop_Level);
            ls_300 = ls_300 
               + "\n" 
            + Bid_mnMAhigh_wieMAlow + " " + f0_3(ibands_Lower) + " " + f0_3(ibands_Upper) + " " + f0_3(Scalp_factor_5) + " exp:" + TimeToStr(datetime_236, TIME_MINUTES) + " numOrders:" + count_252 + " shouldRepeat:" + li_288;
            ls_300 = ls_300 
            + "\ntrailingLimit:" + f0_3(Stop_Level_4) + " trailingDist:" + f0_3(Stop_Level_2) + " trailingResolution:" + f0_3(Stop_Level_3) + " useStopOrders:" + Stop_level_1;
         }
         ls_300 = ls_300 
         + "\nBid:" + f0_3(Bid) + " Ask:" + f0_3(Ask) + " avgSpread:" + f0_3(ld_160) + "  Commission rate:" + f0_3(Comission_na_profit_w_pips) + "  Real avg. spread:" + f0_3(ld_184) + "  Lots:" + f0_4(Lots, li_240);
         if (Mode_HighSpeed) ls_300 = ls_300 + "   HIGH SPEED";
         if (Mode_Safe) ls_300 = ls_300 + "   SAFE";
         if (Mode_MaxOrders) ls_300 = ls_300 + "   MAX";
         if (f0_5(ld_184) > f0_5(Scalp_factor_2 * digits_liczba_00001)) {
            ls_300 = ls_300 
               + "\n" 
            + "Robot is OFF :: Real avg. spread is too high for this scalping strategy ( " + f0_3(ld_184) + " > " + f0_3(Scalp_factor_2 * digits_liczba_00001) + " )";
         }
         Comment(ls_300);
         if (count_252 != 0 || Bid_mnMAhigh_wieMAlow != 0 || Verbose) f0_8(ls_300);
      }
   }
   if (li_288) {
      li_308 = f0_1();
      if (li_308) f0_0(a_timeframe_0);
   }
}

int f0_1() {
   return (0);
}

void f0_2(double &BID_[30], double &ASK_[30], int &Tick_ilosc_[30], double zmiana_znaku) {
   double ld_52;
   if (Tick_ilosc_[0] == 0 || MathAbs(Bid - BID_[0]) >= zmiana_znaku * digits_liczba_00001) {
      for (int li_20 = 29; li_20 > 0; li_20--) {
         BID_[li_20] = BID_[li_20 - 1];
         ASK_[li_20] = ASK_[li_20 - 1];
         Tick_ilosc_[li_20] = Tick_ilosc_[li_20 - 1];
      }
      BID_[0] = Bid;
      ASK_[0] = Ask;
      Tick_ilosc_[0] = GetTickCount();
   }
   gd_348 = 0;
   gi_356 = FALSE;
   double ld_24 = 0;
   int li_32 = 0;
   double ld_36 = 0;
   int li_44 = 0;
   int li_unused_48 = 0;
   for (li_20 = 1; li_20 < 30; li_20++) {
      if (Tick_ilosc_[li_20] == 0) break;
      ld_52 = BID_[0] - BID_[li_20];
      if (ld_52 < ld_24) {
         ld_24 = ld_52;
         li_32 = Tick_ilosc_[0] - Tick_ilosc_[li_20];
      }
      if (ld_52 > ld_36) {
         ld_36 = ld_52;
         li_44 = Tick_ilosc_[0] - Tick_ilosc_[li_20];
      }
      if (ld_24 < 0.0 && ld_36 > 0.0 && ld_24 < 3.0 * ((-zmiana_znaku) * digits_liczba_00001) || ld_36 > 3.0 * (zmiana_znaku * digits_liczba_00001)) {
         if ((-ld_24) / ld_36 < 0.5) {
            gd_348 = ld_36;
            gi_356 = li_44;
            break;
         }
         if ((-ld_36) / ld_24 < 0.5) {
            gd_348 = ld_24;
            gi_356 = li_32;
         }
      } else {
         if (ld_36 > 5.0 * (zmiana_znaku * digits_liczba_00001)) {
            gd_348 = ld_36;
            gi_356 = li_44;
         } else {
            if (ld_24 < 5.0 * ((-zmiana_znaku) * digits_liczba_00001)) {
               gd_348 = ld_24;
               gi_356 = li_32;
               break;
            }
         }
      }
   }
   if (gi_356 == FALSE) {
      gd_360 = 0;
      return;
   }
   gd_360 = 1000.0 * gd_348 / gi_356;
}

string f0_3(double ad_0) {
   return (DoubleToStr(ad_0, digits));
}

string f0_4(double ad_0, int ai_8) {
   return (DoubleToStr(ad_0, ai_8));
}

double f0_5(double ad_0) {
   return (NormalizeDouble(ad_0, digits));
}

string f0_6(int ai_0) {
   if (ai_0 < 10) return ("00" + ai_0);
   if (ai_0 < 100) return ("0" + ai_0);
   return ("" + ai_0);
}

double f0_7(double ad_0, double ad_8) {
   return (MathLog(ad_8) / MathLog(ad_0));
}

void f0_8(string as_0) {
   int li_12;
   int li_8 = -1;
   while (li_8 < StringLen(as_0)) {
      li_12 = li_8 + 1;
      li_8 = StringFind(as_0, 
      "\n", li_12);
      if (li_8 == -1) {
         Print(StringSubstr(as_0, li_12));
         return;
      }
      Print(StringSubstr(as_0, li_12, li_8 - li_12));
   }
}

Recommend