Navigation´╝ÜHome > Content >

my_filter.mq4

Time: 2011-05-09 | Download file:my_filter.mq4

#property copyright "Mr. X"
#property link      "www.metaquotes.net"

#property indicator_separate_window
#property indicator_levelcolor DimGray
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_level1 25.0
#property indicator_level2 15.0

extern int Len = 150;
extern int HistoryBars = 500;
extern int TF1 = 0;
extern int TF2 = 0;
extern bool ModeHL = TRUE;
extern bool ModeOnline = TRUE;
extern bool ModeinFile = FALSE;
extern bool ModeHistory = FALSE;
extern bool alert = FALSE;
extern bool sound = FALSE;
extern bool email = FALSE;
extern bool GV = FALSE;
extern double UrovenSignal = 25.0;
double G_ibuf_132[];
double G_ibuf_136[];
double Gd_140;
double Gd_148;
double Gd_156;
int Gi_164;
int G_shift_168;
int Gi_172;
int G_shift_176;
int G_count_180;
double Gd_184;
double Gd_192;
double Gd_200;
double Gd_208;
double Gd_216;
double Gd_224;
double Gda_232[][240];
double Gda_236[][240];
double Gda_240[][240];
int G_timeframe_244;
int G_datetime_248;
int Gi_252;
bool Gi_256;
int G_file_260;
bool Gi_264;

// E37F0136AA3FFAF149B351F6A4C948E9
int init() {
   if (ModeinFile) FileDelete(Symbol() + "-SP-" + Period() + ".ini");
   if (TF2 == 0) TF2 = Period();
   HistoryBars = NormalizeDouble(HistoryBars / (TF2 / Period()), 0);
   SetIndexBuffer(0, G_ibuf_132);
   SetIndexBuffer(1, G_ibuf_136);
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);
   ArrayResize(Gda_232, HistoryBars + Len);
   ArrayResize(Gda_236, HistoryBars + Len);
   ArrayResize(Gda_240, HistoryBars + Len);
   G_timeframe_244 = Period();
   if (ModeinFile) G_file_260 = FileOpen(Symbol() + "-SP-" + Period() + ".ini", FILE_WRITE, " ");
   return (0);
}

// EA2B2676C28C0DB26D39331A336C6B92
int start() {
   int count_0;
   int Li_4;
   int Li_8;
   int Li_12;
   int str2time_16;
   int str2int_20;
   int str2int_24;
   int file_28;
   if (ModeOnline || ModeinFile) {
      if (iTime(NULL, TF2, 0) == G_datetime_248) return (0);
      G_datetime_248 = iTime(NULL, TF2, 0);
      for (Gi_164 = HistoryBars + Len; Gi_164 > 0; Gi_164--) {
         G_shift_176 = iBarShift(NULL, TF1, iTime(NULL, TF2, Gi_164));
         count_0 = 0;
         for (G_shift_168 = G_shift_176; G_shift_168 > G_shift_176 - TF2; G_shift_168--) {
            Gda_232[Gi_164][count_0] = iClose(NULL, TF1, G_shift_168);
            if (ModeHL) Gda_236[Gi_164][count_0] = iHigh(NULL, TF1, G_shift_168);
            else Gda_236[Gi_164][count_0] = MathMax(iOpen(NULL, TF1, G_shift_168), iClose(NULL, TF1, G_shift_168));
            if (ModeHL) Gda_240[Gi_164][count_0] = iLow(NULL, TF1, G_shift_168);
            else Gda_240[Gi_164][count_0] = MathMin(iOpen(NULL, TF1, G_shift_168), iClose(NULL, TF1, G_shift_168));
            count_0++;
         }
      }
      Li_4 = NormalizeDouble((Bars - IndicatorCounted()) / (TF2 / Period()), 0);
      if (ModeOnline && (!IsTesting())) Li_4 = HistoryBars;
      for (Gi_164 = Li_4; Gi_164 > 0; Gi_164--) {
         G_count_180 = 0;
         Gd_200 = 0;
         Gd_208 = 0;
         Gd_184 = 0;
         Gd_192 = 1000000;
         while (G_count_180 < Len) {
            Gi_172 = Gi_164 + G_count_180;
            Gd_216 = 0;
            Gd_224 = 0;
            for (int count_32 = 0; count_32 < TF2; count_32++) {
               if (Gda_232[Gi_172][count_32] > 0.0) Gd_140 = Gda_232[Gi_172][count_32];
               if (Gda_236[Gi_172][count_32] > 0.0) Gd_148 = Gda_236[Gi_172][count_32];
               if (Gda_240[Gi_172][count_32] > 0.0) Gd_156 = Gda_240[Gi_172][count_32];
               if (Gd_148 > Gd_184) {
                  Gd_184 = Gd_148;
                  Gd_216 += Gd_140;
               }
               if (Gd_156 < Gd_192) {
                  Gd_192 = Gd_156;
                  Gd_224 += Gd_140;
               }
            }
            if (Gd_216 > 0.0) Gd_200 += Gd_216;
            if (Gd_224 > 0.0) Gd_208 += Gd_224;
            G_count_180++;
         }
         if (Gd_200 > 0.0 && Gd_208 > 0.0) {
            if (ModeinFile && Gi_252 != Time[Gi_164]) {
               Gi_252 = Time[Gi_164];
               FileWrite(G_file_260, StringConcatenate(TimeToStr(Time[Gi_164]), ";", DoubleToStr(Gd_200 / Gd_208, 0), ";", DoubleToStr(Gd_208 / Gd_200, 0)));
            }
            Li_8 = iBarShift(NULL, 0, iTime(NULL, TF2, Gi_164));
            for (int Li_36 = Li_8; Li_36 > Li_8 - TF2 / Period(); Li_36--) {
               G_ibuf_132[Li_36] = Gd_200 / Gd_208;
               G_ibuf_136[Li_36] = Gd_208 / Gd_200;
            }
         }
      }
   }
   if (ModeHistory && (!ModeOnline) && (!ModeinFile) && Gi_256 == FALSE) {
      Gi_256 = TRUE;
      file_28 = FileOpen(Symbol() + "-SP-" + TF2 + ".ini", FILE_READ);
      while (!FileIsEnding(file_28)) {
         str2time_16 = StrToTime(FileReadString(file_28));
         str2int_20 = StrToInteger(FileReadString(file_28));
         str2int_24 = StrToInteger(FileReadString(file_28));
         Li_12 = iBarShift(NULL, 0, str2time_16, FALSE);
         for (int Li_40 = Li_12; Li_40 > Li_12 - TF2 / Period(); Li_40--) {
            G_ibuf_132[Li_40] = str2int_20;
            G_ibuf_136[Li_40] = str2int_24;
         }
      }
      FileClose(file_28);
   }
   string Ls_44 = "";
   if (sound || alert || email || GV) {
      if (G_ibuf_132[Li_36 + 1] > UrovenSignal && G_ibuf_132[Li_36 + 1] < 1000000.0) Ls_44 = Symbol() + " Signal " + WindowExpertName() + " BUY ( " + DoubleToStr(G_ibuf_132[Li_36 + 1], 1) + " )";
      if (G_ibuf_136[Li_36 + 1] > UrovenSignal && G_ibuf_136[Li_36 + 1] < 1000000.0) Ls_44 = Symbol() + " Signal " + WindowExpertName() + " SELL ( " + DoubleToStr(G_ibuf_136[Li_36 + 1], 1) + " )";
      if (GV && (!IsTesting())) GlobalVariableSet(Symbol() + WindowExpertName(), G_ibuf_132[Li_36 + 1] - (G_ibuf_136[Li_36 + 1]));
      if (Ls_44 != "" && (!IsTesting())) {
         if (sound && Gi_264 == FALSE) PlaySound("Wait.wav");
         if (alert && Gi_264 == FALSE) Alert(Ls_44);
         if (email && Gi_264 == FALSE) f0_0(Ls_44);
         Gi_264 = TRUE;
      } else Gi_264 = FALSE;
   }
   return (0);
}

// 945D754CB0DC06D04243FCBA25FC0802
void f0_0(string As_0) {
   if (IsTesting() == FALSE && IsOptimization() == FALSE && IsVisualMode() == FALSE) SendMail(WindowExpertName(), As_0);
}

// 52D46093050F38C27267BCE42543EF60
void deinit() {
   if (ModeinFile) FileClose(G_file_260);
}

Recommend