Navigation:Home > Content >

ITM_X-Gen_SYNT~.mq4

Time: 2010-04-04 | Download file:ITM_X-Gen_SYNT~.mq4

#property copyright "ITM Financial, 2012"
#property link      "support@forexsocialsignals.com"

#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Gold
#property indicator_style1 1
#property indicator_color2 Magenta
#property indicator_style2 2
#property indicator_color3 DodgerBlue
#property indicator_style3 2
#property indicator_color4 Aqua
#property indicator_width4 3
#property indicator_color5 Magenta
#property indicator_width5 3

extern string TimeFrame = "Do Not Change Anything";
extern bool AlertOnTradeSignal = TRUE;
extern  bool Alert_1=true; // алерты о стрелке на первом баре
extern  bool Alert_0=true; // алерты о стрелке на нулевом баре
int gi_88 = 56;
int g_applied_price_92 = PRICE_CLOSE;
double gd_96 = 2.5;
bool gi_104 = TRUE;
bool gi_108 = FALSE;
bool gi_112 = FALSE;
bool g_bool_116 = FALSE;
bool gi_120 = FALSE;
bool gi_124 = FALSE;
bool gi_128 = FALSE;
double Buf0[];
double gda_unused_136[];
double Buf1[];
double Buf2[];
double Buf5[];
double Buf6[];
double Buf4[];
double Buf3[];
string gs_164;
string gs_172;
string gs_dummy_180;
bool gi_188 = FALSE;
bool gi_192 = FALSE;
int g_timeframe_196;
extern int BrokerDigits = 5;
string gs_204 = "";
datetime g_time_212;

int init() {
   g_bool_116 = AlertOnTradeSignal;
   g_timeframe_196 = f0_1(TimeFrame);
   gi_88 = MathMax(gi_88, 1);
   IndicatorBuffers(7);
   SetIndexBuffer(0, Buf0);
   SetIndexDrawBegin(0, gi_88);
   SetIndexBuffer(1, Buf1);
   SetIndexDrawBegin(1, gi_88);
   SetIndexBuffer(2, Buf2);
   SetIndexDrawBegin(2, gi_88);
   SetIndexBuffer(3, Buf3);
   SetIndexStyle(3, DRAW_ARROW);
   SetIndexArrow(4, SYMBOL_ARROWDOWN);
   SetIndexBuffer(4, Buf4);
   SetIndexStyle(4, DRAW_ARROW);
   SetIndexArrow(3, SYMBOL_ARROWUP);
   SetIndexBuffer(5, Buf5);
   SetIndexBuffer(6, Buf6);
   if (TimeFrame == "calculateTma") {
      gi_188 = TRUE;
      return (0);
   }
   if (TimeFrame == "returnBars") {
      gi_192 = TRUE;
      return (0);
   }
   gs_164 = WindowExpertName();
   return (0);
}


int deinit() {
   return (0);
}

int start() {
   string ls_0;
   int li_8;
   int li_16;
   int shift_20;
   int datetime_24;
   double ld_32;
   int e;
   if (Period() > PERIOD_M1) {
      if (Buf0[1] < Buf0[2]) gs_172 = "SHORT\n\n-------------------------------------------\n** IMPORTANT ADVICE **\n-------------------------------------------\n1) DO NOT Enter LONG Trades.\n2) ENTER Trade AFTER DOWN (BLUE) Arrows on the previous few bars, AND if the Chart Market Direction is SHORT";
      else {
         if (Buf0[1] > Buf0[2]) gs_172 = "LONG\n\n-------------------------------------------\n** IMPORTANT ADVICE **\n-------------------------------------------\n1) DO NOT Enter SHORT Trades.\n2) ENTER Trade AFTER UP (RED) Arrows on the previous few bars, AND if the Chart Market Direction is LONG!";
         else gs_172 = "Unknown / Possibly in Whipsaw Mode";
      }
 
      li_8 = IndicatorCounted();
      if (li_8 < 0) return (-1);
      if (li_8 > 0) li_8--;
      li_16 = MathMin(Bars - 1, Bars - li_8 + gi_88);
      if (gi_192) {
         Buf0[0] = li_16;
         return (0);
      }
      if (gi_188) {
         f0_3(li_16);
         return (0);
      }
      if (g_timeframe_196 == Period()) li_16 = MathMax(li_16, MathMin(Bars - 1, iCustom(NULL, g_timeframe_196, gs_164, "returnBars", 0, 0) * g_timeframe_196 / Period()));
      for (int i = li_16; i >= 0; i--) {
         shift_20 = iBarShift(NULL, g_timeframe_196, Time[i]);
         datetime_24 = iTime(NULL, g_timeframe_196, shift_20);
         Buf0[i] = iCustom(NULL, g_timeframe_196, gs_164, "calculateTma", 0, shift_20);
         Buf1[i] = iCustom(NULL, g_timeframe_196, gs_164, "calculateTma", 1, shift_20);
         Buf2[i] = iCustom(NULL, g_timeframe_196, gs_164, "calculateTma", 2, shift_20);
         Buf4[i] = EMPTY_VALUE;
         Buf3[i] = EMPTY_VALUE;
         if (High[i + 1] > Buf1[i + 1] && Close[i + 1] > Open[i + 1] && Close[i] < Open[i]) Buf4[i] = High[i] + iATR(NULL, 0, 20, i);
         if (Low[i + 1] < Buf2[i + 1] && Close[i + 1] < Open[i + 1] && Close[i] > Open[i]) Buf3[i] = Low[i] - iATR(NULL, 0, 20, i);
         if (g_timeframe_196 <= Period() || shift_20 == iBarShift(NULL, g_timeframe_196, Time[i - 1])) continue;
         if (gi_104) {
            for (int li_28 = 1; i + li_28 < Bars && Time[i + li_28] >= datetime_24; li_28++) {
            }
            ld_32 = 1.0 / li_28;
            for (int a = 1; a < li_28; a++) {
               Buf0[i + a] = a * ld_32 * (Buf0[i + li_28]) + (1.0 - a * ld_32) * Buf0[i];
               Buf1[i + a] = a * ld_32 * (Buf1[i + li_28]) + (1.0 - a * ld_32) * Buf1[i];
               Buf2[i + a] = a * ld_32 * (Buf2[i + li_28]) + (1.0 - a * ld_32) * Buf2[i];
            }
         }
      }
      
       if (Alert_1) e = 1;
       if (Alert_0) e = 0;
      if (g_bool_116) {
         if (High[e] > Buf1[e] && High[e + 1] < Buf1[e + 1]) f0_2("ALERT: Upper Sentiment Band Broken by CURRENT HIGH!");
         if (Low[e] < Buf2[e] && Low[e + 1] > Buf2[e + 1]) f0_2("ALERT: Lower Sentiment Band Broken by CURRENT LOW!");
      } else {
         if (Close[e] > Buf1[e] && Close[e + 1] < Buf1[e + 1]) f0_2("ALERT: Upper Sentiment Band Broken by CURRENT CLOSE!");
         if (Close[e] < Buf2[e] && Close[e + 1] > Buf2[e + 1]) f0_2("ALERT: Lower Sentiment Band Broken by CURRENT CLOSE!");
      }
            	   if(Alert_1){
      if(Close[e + 1] > Buf1[e + 1] && Close[e + 2] < Buf1[e + 2]){
         static int lt1=0;
            if(lt1!=Time[0]){
               lt1=Time[0];
               Alert("ITM ("+Symbol()+","+fTimeFrameName(Period())+"): SELL (Bar 1), Bid="+DS(Bid));
            }
      }
      if(Close[e + 1] < Buf2[e + 1] && Close[e + 2] > Buf2[e + 2]){
         static int lt2=0;
            if(lt2!=Time[0]){
               lt2=Time[0];
               Alert("ITM ("+Symbol()+","+fTimeFrameName(Period())+"): BUY (Bar 1), Bid="+DS(Bid));
            }         
      }      
   }
   if(Alert_0){
      if(Close[e] > Buf1[e] && Close[e + 1] < Buf1[e + 1]){
         static int lt3=0;
            if(lt3!=Time[0]){
               lt3=Time[0];
               Alert("ITM ("+Symbol()+","+fTimeFrameName(Period())+"): SELL (Bar 0), Bid="+DS(Bid));
            }            
      }
      if(Close[e] < Buf2[e] && Close[e + 1] > Buf2[e + 1]){
         static int lt4=0;
            if(lt4!=Time[0]){
               lt4=Time[0];
               Alert("ITM ("+Symbol()+","+fTimeFrameName(Period())+"): BUY (Bar 0), Bid="+DS(Bid));
            }          
      }     
   }      
      return (0);
   }

   return (0);
}

void f0_3(int ai_0) {
   int li_8;
   double ld_24;
   double ld_32;
   double ld_40;
   double ld_16 = 2.0 * gi_88 + 1.0;
   for (int li_4 = ai_0; li_4 >= 0; li_4--) {
      ld_24 = (gi_88 + 1) * iMA(NULL, 0, 1, 0, MODE_SMA, g_applied_price_92, li_4);
      ld_32 = gi_88 + 1;
      li_8 = 1;
      for (int i = gi_88; li_8 <= gi_88; i--) {
         ld_24 += i * iMA(NULL, 0, 1, 0, MODE_SMA, g_applied_price_92, li_4 + li_8);
         ld_32 += i;
         if (li_8 <= li_4) {
            ld_24 += i * iMA(NULL, 0, 1, 0, MODE_SMA, g_applied_price_92, li_4 - li_8);
            ld_32 += i;
         }
         li_8++;
      }
      Buf0[li_4] = ld_24 / ld_32;
      ld_40 = iMA(NULL, 0, 1, 0, MODE_SMA, g_applied_price_92, li_4) - Buf0[li_4];
      if (li_4 <= Bars - gi_88 - 1) {
         if (li_4 == Bars - gi_88 - 1) {
            Buf1[li_4] = Buf0[li_4];
            Buf2[li_4] = Buf0[li_4];
            if (ld_40 >= 0.0) {
               Buf5[li_4] = MathPow(ld_40, 2);
               Buf6[li_4] = 0;
               continue;
            }
            Buf6[li_4] = MathPow(ld_40, 2);
            Buf5[li_4] = 0;
            continue;
         }
         if (ld_40 >= 0.0) {
            Buf5[li_4] = ((Buf5[li_4 + 1]) * (ld_16 - 1.0) + MathPow(ld_40, 2)) / ld_16;
            Buf6[li_4] = (Buf6[li_4 + 1]) * (ld_16 - 1.0) / ld_16;
         } else {
            Buf6[li_4] = ((Buf6[li_4 + 1]) * (ld_16 - 1.0) + MathPow(ld_40, 2)) / ld_16;
            Buf5[li_4] = (Buf5[li_4 + 1]) * (ld_16 - 1.0) / ld_16;
         }
         Buf1[li_4] = Buf0[li_4] + gd_96 * MathSqrt(Buf5[li_4]);
         Buf2[li_4] = Buf0[li_4] - gd_96 * MathSqrt(Buf6[li_4]);
      }
   }
}

void f0_2(string as_0) {
   string str_concat_8;
   if (gs_204 != as_0 || g_time_212 != Time[0]) {
      gs_204 = as_0;
      g_time_212 = Time[0];
      str_concat_8 = StringConcatenate(Symbol(), " at ", TimeToStr(TimeLocal(), TIME_SECONDS), " ITM : ", as_0);
      if (gi_120) Alert(str_concat_8);
      if (gi_128) SendMail(StringConcatenate(Symbol(), "ITM "), str_concat_8);
      if (gi_124) PlaySound("alert2.wav");
   }
}

int f0_1(string as_0) {
   int i;
   for (int li_8 = StringLen(as_0) - 1; li_8 >= 0; li_8--) {
      i = StringGetChar(as_0, li_8);
      if ((i > '`' && i < '{') || (i > 'Я' && i < 256)) as_0 = StringSetChar(as_0, 1, i - 32);
      else
         if (i > -33 && i < 0) as_0 = StringSetChar(as_0, 1, i + 224);
   }
   int timeframe_16 = 0;
   if (as_0 == "M1" || as_0 == "1") timeframe_16 = 1;
   if (as_0 == "M2" || as_0 == "2") timeframe_16 = 2;
   if (as_0 == "M3" || as_0 == "3") timeframe_16 = 3;
   if (as_0 == "M4" || as_0 == "4") timeframe_16 = 4;
   if (as_0 == "M5" || as_0 == "5") timeframe_16 = 5;
   if (as_0 == "M15" || as_0 == "15") timeframe_16 = 15;
   if (as_0 == "M30" || as_0 == "30") timeframe_16 = 30;
   if (as_0 == "H1" || as_0 == "60") timeframe_16 = 60;
   if (as_0 == "H4" || as_0 == "240") timeframe_16 = 240;
   if (as_0 == "D1" || as_0 == "1440") timeframe_16 = 1440;
   if (as_0 == "W1" || as_0 == "10080") timeframe_16 = 10080;
   if (as_0 == "MN" || as_0 == "43200") timeframe_16 = 43200;
   if (timeframe_16 == 0 || timeframe_16 < Period()) timeframe_16 = Period();
   return (timeframe_16);
}
string DS(double v){return(DoubleToStr(v, Digits));}

string fTimeFrameName(int arg){

   // fTimeFrameName();

   int v;
      if(arg==0){
         v=Period();
      }
      else{
         v=arg;
      }
      switch(v){
         case 0:
            return("0");
         case 1:
            return("M1");
         case 2:
            return("M2");
         case 3:
            return("M3");
         case 4:
            return("M4");
         case 5:
            return("M5");                  
         case 15:
            return("M15");
         case 30:
            return("M30");             
         case 60:
            return("H1");
         case 240:
            return("H4");                  
         case 1440:
            return("D1");
         case 10080:
            return("W1");          
         case 43200:
            return("MN1");
         default:
            return("Wrong TimeFrame");          
      }
}

Recommend