!smSuper TRIX_PV_4col.mq4

!smSuper TRIX_PV_4col.mq4
!smSuper TRIX_PV_4col.mq4 Programming source code

#property indicator_separate_window
#property indicator_buffers 7
#property indicator_color1 Gray
#property indicator_color2 Green
#property indicator_color3 YellowGreen
#property indicator_color4 Maroon
#property indicator_color5 Tomato
#property indicator_color6 DeepSkyBlue
#property indicator_color7 Red
#property indicator_width1 1

extern int TRIX_Period = 3;
extern string _____Averages_____ = “0=SMA, 1=EMA, 2=SMMA, 3=LWMA”;
extern int Mode_Average_1 = 1;
extern int Mode_Average_2 = 1;
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 Gda_156[];
double Gda_160[];
double G_ibuf_164[];
double G_ibuf_168[];
double G_ibuf_172[];
double Gda_176[];
double G_ibuf_180[];
double G_ibuf_184[];
double Gda_188[];
double Gda_192[];
double G_ibuf_196[];
double G_ibuf_200[];
bool Gi_204 = FALSE;
bool Gi_208 = FALSE;
int G_ma_method_212;
int G_ma_method_216;
int G_ma_method_220;
int G_applied_price_224;

int init() {
string Ls_0;
string Ls_8;
string Ls_16;
string Ls_24;
ArraySetAsSeries(Gda_148, TRUE);
ArraySetAsSeries(Gda_152, TRUE);
ArraySetAsSeries(Gda_156, TRUE);
ArraySetAsSeries(Gda_160, TRUE);
ArraySetAsSeries(Gda_192, TRUE);
ArraySetAsSeries(Gda_176, TRUE);
ArraySetAsSeries(Gda_188, TRUE);
IndicatorDigits(4);
SetIndexBuffer(0, G_ibuf_164);
SetIndexStyle(0, DRAW_LINE);
SetIndexLabel(0, “TRIX”);
SetIndexBuffer(1, G_ibuf_168);
SetIndexStyle(1, DRAW_HISTOGRAM);
SetIndexLabel(1, NULL);
SetIndexBuffer(2, G_ibuf_172);
SetIndexStyle(2, DRAW_HISTOGRAM);
SetIndexLabel(2, NULL);
SetIndexBuffer(3, G_ibuf_180);
SetIndexStyle(3, DRAW_HISTOGRAM);
SetIndexLabel(3, NULL);
SetIndexBuffer(4, G_ibuf_184);
SetIndexStyle(4, DRAW_HISTOGRAM);
SetIndexLabel(4, NULL);
SetIndexBuffer(5, G_ibuf_196);
SetIndexStyle(5, DRAW_ARROW);
SetIndexArrow(5, 233);
SetIndexLabel(5, NULL);
SetIndexBuffer(6, G_ibuf_200);
SetIndexStyle(6, DRAW_ARROW);
SetIndexArrow(6, 234);
SetIndexLabel(6, NULL);
G_ma_method_212 = 2;
G_ma_method_216 = 2;
G_ma_method_220 = 1;
G_applied_price_224 = 0;
switch (Mode_Average_1) {
case 0:
G_ma_method_212 = 0;
Ls_8 = “S”;
break;
case 1:
G_ma_method_212 = 1;
Ls_8 = “E”;
break;
case 2:
G_ma_method_212 = 2;
Ls_8 = “M”;
break;
case 3:
G_ma_method_212 = 3;
Ls_8 = “W”;
}
switch (Mode_Average_2) {
case 0:
G_ma_method_216 = 0;
Ls_16 = “S”;
break;
case 1:
G_ma_method_216 = 1;
Ls_16 = “E”;
break;
case 2:
G_ma_method_216 = 2;
Ls_16 = “M”;
break;
case 3:
G_ma_method_216 = 3;
Ls_16 = “W”;
}
switch (Mode_Average_3) {
case 0:
G_ma_method_220 = 0;
Ls_24 = “S”;
break;
case 1:
G_ma_method_220 = 1;
Ls_24 = “E”;
break;
case 2:
G_ma_method_220 = 2;
Ls_24 = “M”;
break;
case 3:
G_ma_method_220 = 3;
Ls_24 = “W”;
}
switch (Input_Price) {
case 0:
G_applied_price_224 = 0;
Ls_0 = “C”;
break;
case 4:
G_applied_price_224 = 4;
Ls_0 = “M”;
break;
case 5:
G_applied_price_224 = 5;
Ls_0 = “T”;
break;
case 6:
G_applied_price_224 = 6;
Ls_0 = “W”;
}
string Ls_48 = “, ” + Ls_8 + “,” + Ls_16 + “,” + Ls_24 + “, ” + Ls_0;
IndicatorShortName(“SwingMan UltraSuperTRIX_PV_4col (” + TRIX_Period + Ls_48 + “)”);
return (0);
}

int start() {
double Ld_8;
double Ld_16;
int Li_24;
int Li_28;
int Li_32;
string Ls_36;
string Ls_44;
if (TRIX_Period == G_period_136) return (0);
ArrayResize(Gda_148, Bars);
ArrayResize(Gda_152, Bars);
ArrayResize(Gda_156, Bars);
ArrayResize(Gda_160, Bars);
ArrayResize(Gda_192, Bars);
ArrayResize(Gda_176, Bars);
ArrayResize(Gda_188, 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_212, G_applied_price_224, 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_216, Li_0); for (Li_0 = 0; Li_0 < Li_4; Li_0++) Gda_192[Li_0] = iMAOnArray(Gda_152, 0, TRIX_Period, 0, G_ma_method_220, Li_0); for (Li_0 = 0; Li_0 < Li_4 - 1; Li_0++) if (Gda_192[Li_0 + 1] != 0.0) Gda_148[Li_0] = Gd_140 * (Gda_192[Li_0] - (Gda_192[Li_0 + 1])) / (Gda_192[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 = Li_4 - 1; Li_0 >= 0; Li_0–) {
Ld_8 = Gda_148[Li_0] – Gda_152[Li_0];
G_ibuf_164[Li_0] = Ld_8;
Ld_16 = G_ibuf_164[Li_0] – (G_ibuf_164[Li_0 + 1]);
if (Ld_8 >= 0.0) {
if (Ld_16 >= 0.0) {
G_ibuf_168[Li_0] = Ld_8;
G_ibuf_180[Li_0] = EMPTY_VALUE;
G_ibuf_172[Li_0] = EMPTY_VALUE;
G_ibuf_184[Li_0] = EMPTY_VALUE;
} else {
G_ibuf_168[Li_0] = EMPTY_VALUE;
G_ibuf_180[Li_0] = EMPTY_VALUE;
G_ibuf_172[Li_0] = Ld_8;
G_ibuf_184[Li_0] = EMPTY_VALUE;
}
} else {
if (Ld_8 < 0.0) { if (Ld_16 >= 0.0) {
G_ibuf_168[Li_0] = EMPTY_VALUE;
G_ibuf_180[Li_0] = EMPTY_VALUE;
G_ibuf_172[Li_0] = EMPTY_VALUE;
G_ibuf_184[Li_0] = Ld_8;
} else {
G_ibuf_168[Li_0] = EMPTY_VALUE;
G_ibuf_180[Li_0] = Ld_8;
G_ibuf_172[Li_0] = EMPTY_VALUE;
G_ibuf_184[Li_0] = EMPTY_VALUE;
}
}
}
if (Ld_8 >= 0.0) {
Gda_176[Li_0] = Ld_8;
Gda_188[Li_0] = EMPTY_VALUE;
} else {
Gda_176[Li_0] = EMPTY_VALUE;
Gda_188[Li_0] = Ld_8;
}
}
for (Li_0 = Li_4 – 1; Li_0 >= 0; Li_0–) {
if (Draw_Signals == TRUE) {
Li_24 = 0;
G_ibuf_196[Li_0 + Li_24] = EMPTY_VALUE;
G_ibuf_200[Li_0 + Li_24] = EMPTY_VALUE;
Li_28 = Gda_176[Li_0 + Li_24] > 0.0 && Gda_176[Li_0 + Li_24] != EMPTY_VALUE && Gda_188[Li_0 + 1 + Li_24] < 0.0; Li_32 = Gda_188[Li_0 + Li_24] < 0.0 && Gda_176[Li_0 + 1 + Li_24] != EMPTY_VALUE && Gda_176[Li_0 + 1 + Li_24] > 0.0;
if (Li_28 == 1) {
G_ibuf_196[Li_0 + Li_24] = 0;
G_ibuf_200[Li_0 + Li_24] = EMPTY_VALUE;
}
if (Li_32 == 1) {
G_ibuf_196[Li_0 + Li_24] = EMPTY_VALUE;
G_ibuf_200[Li_0 + Li_24] = 0;
}
Li_24 = 1;
G_ibuf_196[Li_0 + Li_24] = EMPTY_VALUE;
G_ibuf_200[Li_0 + Li_24] = EMPTY_VALUE;
Li_28 = Gda_176[Li_0 + Li_24] > 0.0 && Gda_176[Li_0 + Li_24] != EMPTY_VALUE && Gda_188[Li_0 + 1 + Li_24] < 0.0; Li_32 = Gda_188[Li_0 + Li_24] < 0.0 && Gda_176[Li_0 + 1 + Li_24] != EMPTY_VALUE && Gda_176[Li_0 + 1 + Li_24] > 0.0;
if (Li_28 == 1) {
G_ibuf_196[Li_0 + Li_24] = 0;
G_ibuf_200[Li_0 + Li_24] = EMPTY_VALUE;
}
if (Li_32 == 1) {
G_ibuf_196[Li_0 + Li_24] = EMPTY_VALUE;
G_ibuf_200[Li_0 + Li_24] = 0;
}
}
Ls_44 = 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]) Gda_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]) Gda_160[Li_0] = Gda_152[Li_0] + 0.0001; if (Gda_156[0] == Gda_152[0] - 0.0001 && Gi_204 == FALSE) { Ls_36 = "Trix BUY: " + Symbol() + "-" + Ls_44 + " at " + DoubleToStr(Close[0], Digits) + " " + TimeToStr(TimeCurrent(), TIME_MINUTES|TIME_SECONDS); if (Alert_Signals == TRUE) Alert(Ls_36); if (EMail_Signals == TRUE) SendMail("TRIX alert", Ls_36); Gi_208 = FALSE; Gi_204 = TRUE; } if (Gda_160[0] == Gda_152[0] + 0.0001 && Gi_208 == FALSE) { Ls_36 = "Trix SELL: " + Symbol() + "-" + Ls_44 + " at " + DoubleToStr(Close[0], Digits) + " " + TimeToStr(TimeCurrent(), TIME_MINUTES|TIME_SECONDS); if (Alert_Signals == TRUE) Alert(Ls_36); if (EMail_Signals == TRUE) SendMail("TRIX alert", Ls_36); Gi_208 = TRUE; Gi_204 = 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 (""); }

DOWNLOAD

Leave a Reply

Your email address will not be published.