Navigation:Home > Content >

smSuper_TRIX_v1.mq4

Time: 2016-08-10 | Download file:smSuper_TRIX_v1.mq4

/*
   Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
   Website: http://purebeam.biz
   E-mail : [email protected]
*/
#property copyright "© 2009.07.12, SwingMan"
#property link      ""

#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Gray
#property indicator_color2 SeaGreen
#property indicator_color3 Maroon
#property indicator_color4 DeepSkyBlue
#property indicator_color5 Red
#property indicator_width1 1

extern int TRIX_Period = 6;
extern string _____Averages_____ = "0=SMA, 1=EMA, 2=SMMA, 3=LWMA";
extern int Mode_Average_1 = 2;
extern int Mode_Average_2 = 2;
extern int Mode_Average_3 = 1;
extern string _____Input_Price_____ = "0=C,4=Median,5=Typical,6=Weighted";
extern int Input_Price = 0;
extern string p2 = "_____Signals_____";
extern bool Draw_Signals = TRUE;
extern bool Alert_Signals = FALSE;
extern bool EMail_Signals = FALSE;
extern int CountBars = 500;
int g_period_136 = 0;
double gd_140 = 1000.0;
double gda_148[];
double gda_152[];
double g_ibuf_156[];
double g_ibuf_160[];
double g_ibuf_164[];
double g_ibuf_168[];
double g_ibuf_172[];
double gda_176[];
double g_ibuf_180[];
double g_ibuf_184[];
bool gi_188 = FALSE;
bool gi_192 = FALSE;
int g_ma_method_196;
int g_ma_method_200;
int g_ma_method_204;
int g_applied_price_208;

int init() {
   string ls_0;
   string ls_8;
   string ls_16;
   string ls_24;
   ArraySetAsSeries(gda_148, TRUE);
   ArraySetAsSeries(gda_152, TRUE);
   ArraySetAsSeries(gda_176, TRUE);
   IndicatorDigits(Digits);
   IndicatorBuffers(7);
   SetIndexBuffer(0, g_ibuf_164);
   SetIndexStyle(0, DRAW_LINE);
   SetIndexLabel(0, NULL);
   SetIndexBuffer(1, g_ibuf_168);
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexBuffer(2, g_ibuf_172);
   SetIndexStyle(2, DRAW_HISTOGRAM);
   SetIndexBuffer(3, g_ibuf_180);
   SetIndexStyle(3, DRAW_ARROW);
   SetIndexArrow(3, 233);
   SetIndexLabel(3, NULL);
   SetIndexBuffer(4, g_ibuf_184);
   SetIndexStyle(4, DRAW_ARROW);
   SetIndexArrow(4, 234);
   SetIndexLabel(4, NULL);
   SetIndexBuffer(5, g_ibuf_156);
   SetIndexBuffer(6, g_ibuf_160);
   g_ma_method_196 = 2;
   g_ma_method_200 = 2;
   g_ma_method_204 = 1;
   g_applied_price_208 = 0;
   switch (Mode_Average_1) {
   case 0:
      g_ma_method_196 = 0;
      ls_8 = "S";
      break;
   case 1:
      g_ma_method_196 = 1;
      ls_8 = "E";
      break;
   case 2:
      g_ma_method_196 = 2;
      ls_8 = "M";
      break;
   case 3:
      g_ma_method_196 = 3;
      ls_8 = "W";
   }
   switch (Mode_Average_2) {
   case 0:
      g_ma_method_200 = 0;
      ls_16 = "S";
      break;
   case 1:
      g_ma_method_200 = 1;
      ls_16 = "E";
      break;
   case 2:
      g_ma_method_200 = 2;
      ls_16 = "M";
      break;
   case 3:
      g_ma_method_200 = 3;
      ls_16 = "W";
   }
   switch (Mode_Average_3) {
   case 0:
      g_ma_method_204 = 0;
      ls_24 = "S";
      break;
   case 1:
      g_ma_method_204 = 1;
      ls_24 = "E";
      break;
   case 2:
      g_ma_method_204 = 2;
      ls_24 = "M";
      break;
   case 3:
      g_ma_method_204 = 3;
      ls_24 = "W";
   }
   switch (Input_Price) {
   case 0:
      g_applied_price_208 = 0;
      ls_0 = "C";
      break;
   case 4:
      g_applied_price_208 = 4;
      ls_0 = "M";
      break;
   case 5:
      g_applied_price_208 = 5;
      ls_0 = "T";
      break;
   case 6:
      g_applied_price_208 = 6;
      ls_0 = "W";
   }
   string ls_48 = ", " + ls_8 + "," + ls_16 + "," + ls_24 + ", " + ls_0;
   IndicatorShortName("SwingMan UltraSuperTRIX_v1 (" + TRIX_Period + ls_48 + ")");
   SetIndexLabel(1, "TRIX up");
   SetIndexLabel(2, "TRIX dn");
   return (0);
}

int start() {
   double ld_8;
   int li_16;
   int li_20;
   int li_24;
   string ls_28;
   string ls_36;
   if (TRIX_Period == g_period_136) return (0);
   ArrayResize(gda_148, Bars);
   ArrayResize(gda_152, Bars);
   ArrayResize(gda_176, Bars);
   int li_4 = CountBars;
   if (li_4 > Bars) li_4 = Bars - 1;
   for (int li_0 = 0; li_0 < li_4; li_0++) gda_148[li_0] = iMA(Symbol(), Period(), TRIX_Period, 0, g_ma_method_196, g_applied_price_208, li_0);
   for (li_0 = 0; li_0 < li_4; li_0++) gda_152[li_0] = iMAOnArray(gda_148, 0, TRIX_Period, 0, g_ma_method_200, li_0);
   for (li_0 = 0; li_0 < li_4; li_0++) gda_176[li_0] = iMAOnArray(gda_152, 0, TRIX_Period, 0, g_ma_method_204, li_0);
   for (li_0 = 0; li_0 < li_4 - 1; li_0++)
      if (gda_176[li_0 + 1] != 0.0) gda_148[li_0] = gd_140 * (gda_176[li_0] - (gda_176[li_0 + 1])) / (gda_176[li_0 + 1]);
   for (li_0 = 0; li_0 < li_4 - 1; li_0++) gda_152[li_0] = iMAOnArray(gda_148, 0, g_period_136, 0, MODE_EMA, li_0);
   for (li_0 = 0; li_0 < li_4 - 1; li_0++) {
      ld_8 = gda_148[li_0] - gda_152[li_0];
      g_ibuf_164[li_0] = ld_8;
      if (ld_8 >= 0.0) {
         g_ibuf_168[li_0] = ld_8;
         g_ibuf_172[li_0] = EMPTY_VALUE;
      } else {
         g_ibuf_168[li_0] = EMPTY_VALUE;
         g_ibuf_172[li_0] = ld_8;
      }
   }
   for (li_0 = li_4 - 1; li_0 >= 0; li_0--) {
      if (Draw_Signals == TRUE) {
         li_16 = 0;
         g_ibuf_180[li_0 + li_16] = EMPTY_VALUE;
         g_ibuf_184[li_0 + li_16] = EMPTY_VALUE;
         li_20 = g_ibuf_168[li_0 + li_16] > 0.0 && g_ibuf_168[li_0 + li_16] != EMPTY_VALUE && g_ibuf_172[li_0 + 1 + li_16] < 0.0;
         li_24 = g_ibuf_172[li_0 + li_16] < 0.0 && g_ibuf_168[li_0 + 1 + li_16] != EMPTY_VALUE && g_ibuf_168[li_0 + 1 + li_16] > 0.0;
         if (li_20 == 1) {
            g_ibuf_180[li_0 + li_16] = 0;
            g_ibuf_184[li_0 + li_16] = EMPTY_VALUE;
         }
         if (li_24 == 1) {
            g_ibuf_180[li_0 + li_16] = EMPTY_VALUE;
            g_ibuf_184[li_0 + li_16] = 0;
         }
         li_16 = 1;
         g_ibuf_180[li_0 + li_16] = EMPTY_VALUE;
         g_ibuf_184[li_0 + li_16] = EMPTY_VALUE;
         li_20 = g_ibuf_168[li_0 + li_16] > 0.0 && g_ibuf_168[li_0 + li_16] != EMPTY_VALUE && g_ibuf_172[li_0 + 1 + li_16] < 0.0;
         li_24 = g_ibuf_172[li_0 + li_16] < 0.0 && g_ibuf_168[li_0 + 1 + li_16] != EMPTY_VALUE && g_ibuf_168[li_0 + 1 + li_16] > 0.0;
         if (li_20 == 1) {
            g_ibuf_180[li_0 + li_16] = 0;
            g_ibuf_184[li_0 + li_16] = EMPTY_VALUE;
         }
         if (li_24 == 1) {
            g_ibuf_180[li_0 + li_16] = EMPTY_VALUE;
            g_ibuf_184[li_0 + li_16] = 0;
         }
      }
      ls_36 = Get_sPeriod(Period());
      if (Alert_Signals == TRUE || EMail_Signals == TRUE) {
         if (gda_152[li_0] < gda_148[li_0] && gda_152[li_0 + 1] >= gda_148[li_0 + 1]) g_ibuf_156[li_0] = gda_152[li_0] - 0.0001;
         if (gda_152[li_0] > gda_148[li_0] && gda_152[li_0 + 1] <= gda_148[li_0 + 1]) g_ibuf_160[li_0] = gda_152[li_0] + 0.0001;
         if (g_ibuf_156[0] == gda_152[0] - 0.0001 && gi_188 == FALSE) {
            ls_28 = "Trix BUY:  " + Symbol() + "-" + ls_36 + "  at  " + Close[0] + "  " + TimeToStr(TimeCurrent(), TIME_MINUTES|TIME_SECONDS);
            if (Alert_Signals == TRUE) Alert(ls_28);
            if (EMail_Signals == TRUE) SendMail("TRIX alert", ls_28);
            gi_192 = FALSE;
            gi_188 = TRUE;
         }
         if (g_ibuf_160[0] == gda_152[0] + 0.0001 && gi_192 == FALSE) {
            ls_28 = "Trix SELL:  " + Symbol() + "-" + ls_36 + "  at  " + Close[0] + "  " + TimeToStr(TimeCurrent(), TIME_MINUTES|TIME_SECONDS);
            if (Alert_Signals == TRUE) Alert(ls_28);
            if (EMail_Signals == TRUE) SendMail("TRIX alert", ls_28);
            gi_192 = TRUE;
            gi_188 = FALSE;
         }
      }
   }
   return (0);
}

string Get_sPeriod(int ai_0) {
   if (ai_0 == 1) return ("M1");
   if (ai_0 == 5) return ("M5");
   if (ai_0 == 15) return ("M15");
   if (ai_0 == 30) return ("M30");
   if (ai_0 == 60) return ("H1");
   if (ai_0 == 240) return ("H4");
   if (ai_0 == 1440) return ("D1");
   if (ai_0 == 10080) return ("W1");
   if (ai_0 == 43200) return ("MN1");
   return ("");
}

Recommend