//*******************************************************************//
#property description "Платим за каждую сделку Forex из 30+ брокеров"
#property description "Перед Вами новый инструмент трейдера ,Сервис, осуществляющий мгновенный возврат до 95% от спреда (рибейт) более чем в 30 самых надежных и проверенных брокеров с мировыми именами_"
#property description  "http://fxcash_ru/?id=X53657"
#property description  "http://fxcash_ru/?id=fxgeneral"
#property copyright "http://fxcash_ru/?id=_spred    "
#property link "http://www_roboforex_ru/?a=bywt "
//*******************************************************************//

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Magenta
#property indicator_color2 Magenta

#include <WinUser32.mqh>

extern int Limit = 1500;
extern bool ShowConfAlert = TRUE;
extern bool SendmailConfAlert = TRUE;
extern string OtherTimeFrames = "Select below 0=current tf,1,5,15,30,60,240,1440,10080,43200";
extern int select_other_tf_to_show = 0;
int Gi_100 = 1;
int Gi_104 = 50;
int Gi_108 = 12;
int Gi_112 = 3;
int Gi_116 = 0;
extern int eintPeriod = 20;
extern double edblHigh1 = 0.4;
extern double edblLow1 = -0.4;
extern int atrPeriod = 100;
int Gi_144 = 16777215;
int Gi_148 = 1;
int Gi_152 = 25;
int Gi_156 = 3;
int Gi_160 = 14;
int Gi_164 = 11;
int Gi_168 = 1;
int Gi_172 = 1;
int Gi_176 = 3;
double G_ibuf_180[];
double G_ibuf_184[];
int Gi_192;
int G_datetime_196;
datetime G_time_204;
int Gi_208 = 0;

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   int Li_4;
   SetIndexBuffer(0, G_ibuf_180);
   SetIndexBuffer(1, G_ibuf_184);
   SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID, 2);
   SetIndexBuffer(0, G_ibuf_180);
   SetIndexArrow(0, 234);
   SetIndexLabel(0, "ConfDn");
   SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID, 2);
   SetIndexBuffer(1, G_ibuf_184);
   SetIndexArrow(1, 233);
   SetIndexLabel(1, "ConfUp");
   IndicatorShortName("LRFF-10.2 TmaSlope v.8 arrow");
   G_datetime_196 = TimeCurrent();
   Gi_208 = WindowHandle(Symbol(), Period());
   switch (Period()) {
   case PERIOD_M1:
      Gi_192 = 1;
      break;
   case PERIOD_M5:
      Gi_192 = 2;
      break;
   case PERIOD_M15:
      Gi_192 = 10;
      break;
   case PERIOD_M30:
      Gi_192 = 19;
      break;
   case PERIOD_H1:
      Gi_192 = 25;
      break;
   case PERIOD_H4:
      Gi_192 = 40;
      break;
   case PERIOD_D1:
      Gi_192 = 80;
      break;
   case PERIOD_W1:
      Gi_192 = 100;
      break;
   case PERIOD_MN1:
      Gi_192 = 400;
   }
   int Li_8 = MarketInfo(Symbol(), MODE_DIGITS);
   if (Li_8 == 2 || Li_8 == 4) Li_4 = 1;
   if (Li_8 == 3 || Li_8 == 5) Li_4 = 10;
   Gi_192 *= Li_4;
   return (0);
}

// 52D46093050F38C27267BCE42543EF60
int deinit() {
   Comment("");
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   int Li_12;
   double icustom_20;
   double icustom_28;
   bool Li_36;
   bool Li_40;
   bool Li_44;
   bool Li_48;
   double icustom_56;
   bool Li_64;
   bool Li_68;
   int ind_counted_4 = IndicatorCounted();
   int Li_8 = Bars - ind_counted_4 + 1;
   if (TimeCurrent() >= G_datetime_196 + 300 && Gi_208 != 0) {
      switch (Period()) {
      case PERIOD_M1:
         Li_12 = 33137;
         break;
      case PERIOD_M5:
         Li_12 = 33138;
         break;
      case PERIOD_M15:
         Li_12 = 33139;
         break;
      case PERIOD_M30:
         Li_12 = 33140;
         break;
      case PERIOD_H1:
         Li_12 = 33135;
         break;
      case PERIOD_H4:
         Li_12 = 33136;
         break;
      case PERIOD_D1:
         Li_12 = 33134;
         break;
      case PERIOD_W1:
         Li_12 = 33141;
         break;
      default:
         Li_12 = 33137;
      }
      PostMessageA(Gi_208, WM_COMMAND, 33141, 0);
      PostMessageA(Gi_208, WM_COMMAND, Li_12, 0);
      G_datetime_196 = TimeCurrent();
   }
   if (Li_8 > Limit) Li_8 = Limit;
   for (int count_0 = 0; count_0 < Li_8; count_0++) {
      icustom_20 = iCustom(Symbol(), 0, "LRFF-10.2 TmaSlope v.8_2", OtherTimeFrames, select_other_tf_to_show, Gi_100, Gi_104, Gi_108, Gi_112, Gi_116, eintPeriod, edblHigh1,
         edblLow1, atrPeriod, Gi_144, Gi_148, Gi_152, Gi_156, Gi_160, Gi_164, Gi_168, Gi_172, Gi_176, 6, count_0 + 1);
      icustom_28 = iCustom(Symbol(), 0, "LRFF-10.2 TmaSlope v.8_2", OtherTimeFrames, select_other_tf_to_show, Gi_100, Gi_104, Gi_108, Gi_112, Gi_116, eintPeriod, edblHigh1,
         edblLow1, atrPeriod, Gi_144, Gi_148, Gi_152, Gi_156, Gi_160, Gi_164, Gi_168, Gi_172, Gi_176, 6, count_0 + 2);
      Li_36 = FALSE;
      Li_40 = FALSE;
      if (icustom_20 > icustom_28) Li_36 = TRUE;
      if (icustom_20 < icustom_28) Li_40 = TRUE;
      Li_44 = FALSE;
      Li_48 = FALSE;
      for (int Li_52 = count_0 + 2; Li_52 < Bars - atrPeriod; Li_52++) {
         icustom_56 = iCustom(Symbol(), 0, "LRFF-10.2 TmaSlope v.8_2", OtherTimeFrames, select_other_tf_to_show, Gi_100, Gi_104, Gi_108, Gi_112, Gi_116, eintPeriod, edblHigh1,
            edblLow1, atrPeriod, Gi_144, Gi_148, Gi_152, Gi_156, Gi_160, Gi_164, Gi_168, Gi_172, Gi_176, 6, Li_52);
         if (icustom_56 >= edblHigh1) {
            Li_48 = TRUE;
            break;
         }
         if (icustom_56 <= edblLow1) {
            Li_44 = TRUE;
            break;
         }
      }
      Li_64 = FALSE;
      Li_68 = FALSE;
      if (Li_36 && icustom_20 >= edblHigh1 && icustom_28 < edblHigh1 && Li_44) Li_64 = TRUE;
      if (Li_40 && icustom_20 <= edblLow1 && icustom_28 > edblLow1 && Li_48) Li_68 = TRUE;
      if (Li_64) {
         G_ibuf_184[count_0 + 1] = Low[count_0 + 1] - Gi_192 * Point;
         G_ibuf_180[count_0 + 1] = EMPTY_VALUE;
         if (count_0 == 1 && G_time_204 != Time[0]) {
            if (ShowConfAlert) Alert("LRFF-10.2 TmaSlope v.8 arrow is confirmed bullish, " + Symbol() + "(" + Period() + ")");
            if (SendmailConfAlert) {
               SendMail("LRFF-10.2 TmaSlope v.8 arrow is confirmed Bullish, " + Symbol() + "(" + Period() + ")", "LRFF-10.2 TmaSlope v.8 arrow is confirmed Bullish, " + Symbol() +
                  "(" + Period() + ") " + TimeToStr(Time[0], TIME_DATE|TIME_SECONDS));
            }
            G_time_204 = Time[0];
         }
      }
      if (Li_68) {
         G_ibuf_180[count_0 + 1] = High[count_0 + 1] + Gi_192 * Point;
         G_ibuf_184[count_0 + 1] = EMPTY_VALUE;
         if (count_0 == 1 && G_time_204 != Time[0]) {
            if (ShowConfAlert) Alert("LRFF-10.2 TmaSlope v.8 arrow is confirmed Bearish, " + Symbol() + "(" + Period() + ")");
            if (SendmailConfAlert) {
               SendMail("LRFF-10.2 TmaSlope v.8 arrow is confirmed Bearish, " + Symbol() + "(" + Period() + ")", "LRFF-10.2 TmaSlope v.8 arrow is confirmed Bearish, " + Symbol() +
                  "(" + Period() + ") " + TimeToStr(Time[0], TIME_DATE|TIME_SECONDS));
            }
            G_time_204 = Time[0];
         }
      }
   }
   return (0);
}
