/*
   G e n e r a t e d  by ex4-to-mq4 decompiler FREEWARE 4.0.509.5
   Website:  H tT p:/ / Www. me TaqUO T E S.N E T
   E-mail :  s U ppOr T @m e taquO tes . neT
*/
#property copyright "Copyright © 2005, Shurka"
#property link      "http://shforex.narod.ru"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red

extern int AllBars = 0;
extern int Otstup = 17;
extern double Per = 13.0;
extern string Alert_Setting = "---------- Alert Setting";
extern bool EnableAlert = TRUE;
extern string SoundFilename = "alert.wav";
int Gi_112;
int Gi_116;
int Gi_120;
int Gi_124;
int G_count_128 = 0;
int G_count_132 = 0;
int Gi_unused_136 = 0;
int Gi_unused_140 = 0;
double Gd_144;
double G_high_152;
double G_low_160;
double G_ibuf_168[];
double G_ibuf_172[];

int init() {
   if (Bars < AllBars + Per || AllBars == 0) Gi_116 = Bars - Per;
   else Gi_116 = AllBars;
   IndicatorBuffers(2);
   IndicatorShortName("SHI_SilverTrendSig");
   SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID, 2);
   SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID, 2);
   SetIndexArrow(0, 159);
   SetIndexArrow(1, 159);
   SetIndexBuffer(0, G_ibuf_172);
   SetIndexBuffer(1, G_ibuf_168);
   SetIndexDrawBegin(0, Bars - Gi_116);
   SetIndexDrawBegin(1, Bars - Gi_116);
   ArrayInitialize(G_ibuf_168, 0.0);
   ArrayInitialize(G_ibuf_172, 0.0);
   return (0);
}

int deinit() {
   return (0);
}

int start() {
   string Ls_4;
   int ind_counted_0 = IndicatorCounted();
   if (ind_counted_0 < 0) return (-1);
   if (Gi_116 > Bars - ind_counted_0) Gi_116 = Bars - ind_counted_0;
   for (Gi_112 = 1; Gi_112 < Gi_116; Gi_112++) {
      Gd_144 = 0;
      for (Gi_120 = Gi_112; Gi_120 < Gi_112 + 10; Gi_120++) Gd_144 += (Gi_112 + 10 - Gi_120) * (High[Gi_120] - Low[Gi_120]);
      Gd_144 /= 55.0;
      G_high_152 = High[iHighest(NULL, 0, MODE_HIGH, Per, Gi_112)];
      G_low_160 = Low[iLowest(NULL, 0, MODE_LOW, Per, Gi_112)];
      if (Close[Gi_112] > G_high_152 - (G_high_152 - G_low_160) * Otstup / 100.0 && Gi_124 != 1) {
         G_ibuf_168[Gi_112] = High[Gi_112] + Gd_144 / 2.0;
         if (Close[Gi_112] > G_high_152 - (G_high_152 - G_low_160) * Otstup / 100.0 && Gi_124 != 1) Gi_124 = 1;
         if (Close[Gi_112] > G_high_152 - (G_high_152 - G_low_160) * Otstup / 100.0 && Gi_124 != 1) G_count_132 = 0;
      } else {
         if (Close[Gi_112] < G_low_160 + (G_high_152 - G_low_160) * Otstup / 100.0 && Gi_124 != -1) {
            G_ibuf_172[Gi_112] = Low[Gi_112] - Gd_144 / 2.0;
            if (Close[Gi_112] < G_low_160 + (G_high_152 - G_low_160) * Otstup / 100.0 && Gi_124 != -1) Gi_124 = -1;
            if (Close[Gi_112] < G_low_160 + (G_high_152 - G_low_160) * Otstup / 100.0 && Gi_124 != -1) G_count_128 = 0;
         }
      }
   }
   if (EnableAlert) {
      if (Gi_124 == 1 && G_count_128 == 1) Alert(Symbol(), " - ", "BUY - UP DIRECTION !");
      if (Gi_124 == 1 && G_count_128 == 1) Alert(Ls_4);
      if (Gi_124 == 1 && G_count_128 == 1) PlaySound(SoundFilename);
      if (Gi_124 == 1 && G_count_128 == 1) G_count_128++;
      if (Gi_124 == -1 && G_count_132 == 1) Alert(Symbol(), " - ", "SELL - DOWN DIRECTION !");
      if (Gi_124 == -1 && G_count_132 == 1) Alert(Ls_4);
      if (Gi_124 == -1 && G_count_132 == 1) PlaySound(SoundFilename);
      if (Gi_124 == -1 && G_count_132 == 1) G_count_132++;
   }
   return (0);
}
