please anybody kind me for Converting MT Indicator to AFL

#1
#property indicator_separate_window
#property indicator_minimum -100.0
#property indicator_maximum 100.0
#property indicator_levelcolor SlateGray
#property indicator_levelstyle 1
#property indicator_buffers 8
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 Black
#property indicator_color4 Black
#property indicator_color5 Black
#property indicator_color6 Black
#property indicator_color7 Black
#property indicator_color8 Black
#property indicator_width1 1
#property indicator_level1 60.0
#property indicator_width2 1
#property indicator_level2 53.0
#property indicator_level3 -50.0
#property indicator_level4 -60.0

extern int WavePeriod = 10;
extern int AvgPeriod = 21;
extern bool SoundAlert = FALSE;
extern bool EmailAlert = FALSE;
double g_ibuf_92[];
double g_ibuf_96[];
double g_ibuf_100[];
double g_ibuf_104[];
double g_ibuf_108[];
double g_ibuf_112[];
double g_ibuf_116[];
double g_ibuf_120[];
int gi_124 = -50;
int gi_128 = 53;
int gi_132;

int init() {
Comment("");
IndicatorShortName("TrendWave");
SetIndexBuffer(0, g_ibuf_100);
SetIndexLabel(0, "ESA");
SetIndexStyle(0, DRAW_NONE);
SetIndexDrawBegin(0, 0);
SetIndexBuffer(1, g_ibuf_112);
SetIndexLabel(1, "DD Values");
SetIndexStyle(1, DRAW_NONE);
SetIndexDrawBegin(1, 0);
SetIndexBuffer(2, g_ibuf_104);
SetIndexLabel(2, "DD");
SetIndexStyle(2, DRAW_NONE);
SetIndexDrawBegin(2, 0);
SetIndexBuffer(3, g_ibuf_108);
SetIndexLabel(3, "CI");
SetIndexStyle(3, DRAW_NONE);
SetIndexDrawBegin(3, 0);
SetIndexBuffer(4, g_ibuf_92);
SetIndexLabel(4, "Bull");
SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, 1, Lime);
SetIndexDrawBegin(4, 0);
SetIndexBuffer(5, g_ibuf_96);
SetIndexLabel(5, "Bear");
SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, 1, Red);
SetIndexDrawBegin(5, 0);
SetIndexBuffer(6, g_ibuf_116);
SetIndexLabel(6, "Buy Dot");
SetIndexStyle(6, DRAW_ARROW, STYLE_SOLID, 2, Aqua);
SetIndexArrow(6, 108);
SetIndexDrawBegin(6, 0);
SetIndexBuffer(7, g_ibuf_120);
SetIndexLabel(7, "Sell Dot");
SetIndexStyle(7, DRAW_ARROW, STYLE_SOLID, 2, Yellow);
SetIndexArrow(7, 108);
SetIndexDrawBegin(7, 0);
ArrayResize(g_ibuf_100, Bars);
ArrayResize(g_ibuf_112, Bars);
ArrayResize(g_ibuf_104, Bars);
ArrayResize(g_ibuf_108, Bars);
ArrayResize(g_ibuf_92, Bars);
ArrayResize(g_ibuf_96, Bars);
ArrayResize(g_ibuf_116, Bars);
ArrayResize(g_ibuf_120, Bars);
return (0);
}

int start() {
double l_ima_on_arr_0;
Comment("");
int li_8 = IndicatorCounted();
if (li_8 < 0) return (-1);
if (li_8 > 0) li_8--;
int li_12 = Bars - li_8;
for (int li_16 = li_12; li_16 > 0; li_16--) {
g_ibuf_100[li_16] = iMA(NULL, 0, WavePeriod, 0, MODE_EMA, PRICE_TYPICAL, li_16);
ArraySetAsSeries(g_ibuf_100, TRUE);
}
for (li_16 = li_12; li_16 > 0; li_16--) {
g_ibuf_112[li_16] = MathAbs((iHigh(NULL, 0, li_16) + iClose(NULL, 0, li_16) + iLow(NULL, 0, li_16)) / 3.0 - g_ibuf_100[li_16]);
ArraySetAsSeries(g_ibuf_112, TRUE);
}
for (li_16 = li_12; li_16 > 0; li_16--) {
l_ima_on_arr_0 = iMAOnArray(g_ibuf_112, 0, WavePeriod, 0, MODE_EMA, li_16);
g_ibuf_104[li_16] = l_ima_on_arr_0;
ArraySetAsSeries(g_ibuf_104, TRUE);
}

for (li_16 = li_12; li_16 > 0; li_16--) {
l_ima_on_arr_0 = iMAOnArray(g_ibuf_108, 0, AvgPeriod, 0, MODE_EMA, li_16);
g_ibuf_92[li_16] = l_ima_on_arr_0;
ArraySetAsSeries(g_ibuf_92, TRUE);
}

for (li_16 = li_12; li_16 > 0; li_16--) {
if (g_ibuf_92[li_16] >= g_ibuf_96[li_16] && g_ibuf_92[li_16 + 1] <= g_ibuf_96[li_16 + 1] && g_ibuf_92[li_16] < gi_124) {
g_ibuf_116[li_16] = g_ibuf_92[li_16];
SendAlert("buy");
} else g_ibuf_116[li_16] = -1000;
if (g_ibuf_92[li_16] <= g_ibuf_96[li_16] && g_ibuf_92[li_16 + 1] >= g_ibuf_96[li_16 + 1] && g_ibuf_92[li_16] > gi_128) {
g_ibuf_120[li_16] = g_ibuf_96[li_16];
SendAlert("sell");
} else g_ibuf_120[li_16] = -1000;
}
return (0);
}

void SendAlert(string as_0) {
if (Time[0] != gi_132) {
if (SoundAlert) {
if (as_0 == "buy") Alert(Symbol() + " => " + TimeToStr(TimeCurrent()) + " buy");
if (as_0 == "sell") Alert(Symbol() + " => " + TimeToStr(TimeCurrent()) + " sell");
}
if (EmailAlert) {
if (as_0 == "buy") SendMail("TrendWave Alert", Symbol() + " => " + TimeToStr(TimeCurrent()) + " buy");
if (as_0 == "sell") SendMail("TrendWave Alert", Symbol() + " => " + TimeToStr(TimeCurrent()) + " sell");
}
gi_132 = Time[0];
}
}


#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Yellow
#property indicator_color2 Fuchsia
#property indicator_color3 Red
#property indicator_color4 White
#property indicator_color5 DarkViolet

/*#import "MT4.SuperADX_Indicator.dll"
bool Activate(int a0, int a1, string a2);
string GetLastErrorDescription();
#import*/

//extern string License = "Enter License key here";
extern int WhiteBarTrigger = 35;
extern int RedBarTrigger = 10;
extern int WavePeriod = 10;
extern int AvgPeriod = 21;
extern bool SoundAlert = FALSE;
extern bool EmailAlert = FALSE;
extern int NumberOfBarsToUse = 500;
double g_ibuf_112[];
double g_ibuf_116[];
double g_ibuf_120[];
double g_ibuf_124[];
double g_ibuf_128[];
double gda_132[];
double gda_136[];
double gda_140[];
double gda_144[];
double gda_148[];
double gda_152[];
double gda_156[];
double gda_160[];
int gi_164 = -50;
int gi_168 = 53;
int gi_172;
bool gi_176 = FALSE;
bool gi_180 = FALSE;
string gs_184;

int init() {
int li_8;
string ls_0 = "!SuperADX";
IndicatorShortName(ls_0);
ArrayResize(gda_140, Bars);
ArrayResize(gda_152, Bars);
ArrayResize(gda_144, Bars);
ArrayResize(gda_148, Bars);
ArrayResize(gda_132, Bars);
ArrayResize(gda_136, Bars);
ArrayResize(gda_156, Bars);
ArrayResize(gda_160, Bars);
SetIndexBuffer(0, g_ibuf_124);
SetIndexBuffer(1, g_ibuf_120);
SetIndexBuffer(2, g_ibuf_116);
SetIndexBuffer(3, g_ibuf_112);
SetIndexBuffer(4, g_ibuf_128);
SetIndexLabel(0, "Yellow Bar 53");
SetIndexLabel(1, "Magenta Bar 53");
SetIndexLabel(2, "Red Bar 53");
SetIndexLabel(3, "White Bar 53");
SetIndexLabel(4, "DarkViolet Bar 53");
SetIndexEmptyValue(0, 0);
SetIndexEmptyValue(0, 1);
SetIndexEmptyValue(0, 2);
SetIndexEmptyValue(0, 3);
SetIndexEmptyValue(0, 4);
SetIndexDrawBegin(0, 1);
SetIndexDrawBegin(1, 1);
SetIndexDrawBegin(2, 1);
SetIndexDrawBegin(3, 1);
SetIndexDrawBegin(4, 1);
SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 4, Yellow);
SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 4, Fuchsia);
SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID, 4, Red);
SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_SOLID, 4, White);
SetIndexStyle(4, DRAW_HISTOGRAM, STYLE_SOLID, 4, DarkViolet);
/*if (IsDemo()) li_8 = 1;
else li_8 = 2;
if (AccountNumber() == 0) gi_176 = TRUE;
gi_180 = Activate(AccountNumber(), li_8, License);
gs_184 = GetLastErrorDescription();*/
return (0);
}

int deinit() {
return (0);
}

int start() {
int li_unused_0;
int li_4;
double l_ima_on_arr_8;
int li_16;
bool li_48;
bool l_bool_52;
bool l_bool_56;
/*if (gi_176) {
if (AccountNumber() == 0) {
Comment("Connecting to server...");
return (0);
}
gi_176 = FALSE;
if (IsDemo()) li_unused_0 = 1;
else li_unused_0 = 2;
gi_180 = TRUE;
gs_184 = GetLastErrorDescription();
li_4 = 0;
} else li_4 = IndicatorCounted();
if (gi_180 == FALSE) {
Comment(gs_184);
return (0);
}
Comment("License Activated");*/
double l_icustom_20 = 0;
double l_icustom_28 = 0;
double l_icustom_36 = 0;
if (li_4 < 0) return (-1);
if (li_4 > 0) li_4--;
if (NumberOfBarsToUse == 0) li_16 = Bars - 1;
else li_16 = NumberOfBarsToUse;
for (int li_44 = li_16; li_44 > 0; li_44--) {
gda_140[li_44] = iMA(NULL, 0, WavePeriod, 0, MODE_EMA, PRICE_TYPICAL, li_44);
ArraySetAsSeries(gda_140, TRUE);
}
for (li_44 = li_16; li_44 > 0; li_44--) {
gda_152[li_44] = MathAbs((iHigh(NULL, 0, li_44) + iClose(NULL, 0, li_44) + iLow(NULL, 0, li_44)) / 3.0 - gda_140[li_44]);
ArraySetAsSeries(gda_152, TRUE);
}
for (li_44 = li_16; li_44 > 0; li_44--) {
l_ima_on_arr_8 = iMAOnArray(gda_152, 0, WavePeriod, 0, MODE_EMA, li_44);
gda_144[li_44] = l_ima_on_arr_8;
ArraySetAsSeries(gda_144, TRUE);
}
for (li_44 = li_16; li_44 > 0; li_44--) {
if (gda_144[li_44] > 0.0) gda_148[li_44] = ((iHigh(NULL, 0, li_44) + iClose(NULL, 0, li_44) + iLow(NULL, 0, li_44)) / 3.0 - gda_140[li_44]) / (0.015 * gda_144[li_44]);
else gda_148[li_44] = 0;
ArraySetAsSeries(gda_148, TRUE);
}
for (li_44 = li_16; li_44 > 0; li_44--) {
l_ima_on_arr_8 = iMAOnArray(gda_148, 0, AvgPeriod, 0, MODE_EMA, li_44);
gda_132[li_44] = l_ima_on_arr_8;
ArraySetAsSeries(gda_132, TRUE);
}
for (li_44 = li_16; li_44 > 0; li_44--) {
l_ima_on_arr_8 = iMAOnArray(gda_132, 0, 4, 0, MODE_SMA, li_44);
gda_136[li_44] = l_ima_on_arr_8;
ArraySetAsSeries(gda_136, TRUE);
}
for (li_44 = li_16 - 1; li_44 > 0; li_44--) {
if (gda_132[li_44] >= gda_136[li_44] && gda_132[li_44 + 1] <= gda_136[li_44 + 1] && gda_132[li_44] <= gi_164) gda_156[li_44] = 1;
else gda_156[li_44] = 0;
if (gda_132[li_44] <= gda_136[li_44] && gda_132[li_44 + 1] >= gda_136[li_44 + 1] && gda_132[li_44] >= gi_168) gda_160[li_44] = 1;
else gda_160[li_44] = 0;
}
for (li_44 = li_16 - 2; li_44 > 0; li_44--) {
l_icustom_20 = iCustom(NULL, 0, "SupportingADX", 14, NumberOfBarsToUse, 0, li_44);
l_icustom_28 = iCustom(NULL, 0, "SupportingADX", 14, NumberOfBarsToUse, 0, li_44 + 1);
l_icustom_36 = iCustom(NULL, 0, "SupportingADX", 14, NumberOfBarsToUse, 0, li_44 + 2);
li_48 = MACDSignal(li_44);
l_bool_52 = l_icustom_28 > WhiteBarTrigger && l_icustom_20 < l_icustom_28 && l_icustom_28 > l_icustom_36;
l_bool_56 = l_icustom_20 < RedBarTrigger && l_icustom_20 > l_icustom_28 && l_icustom_28 < l_icustom_36;
g_ibuf_112[li_44] = 0;
g_ibuf_120[li_44] = 0;
g_ibuf_128[li_44] = 0;
g_ibuf_124[li_44] = 0;
if (l_bool_52 && gda_156[li_44] != 0.0 || gda_160[li_44] != 0.0) {
g_ibuf_124[li_44] = 2.5 * l_icustom_20;
if (li_44 == 1) SendAlert("yb");
}
if (l_bool_52) {
if (li_48) {
g_ibuf_128[li_44] = 1.5 * l_icustom_20;
if (li_44 == 1) SendAlert("wbmacd");
} else {
g_ibuf_112[li_44] = 1.5 * l_icustom_20;
if (li_44 == 1) SendAlert("wb");
}
}
if (ThreeBars(li_44) && l_bool_52) {
g_ibuf_120[li_44] = 2.0 * l_icustom_20;
if (li_44 == 1) SendAlert("tb");
}
if (l_bool_56) {
g_ibuf_116[li_44] = 2.0 * l_icustom_20;
if (li_44 == 1) SendAlert("rb");
} else g_ibuf_116[li_44] = 0;
}
return (0);
}

int MACDSignal(int ai_0) {
double l_icustom_4 = iCustom(Symbol(), 0, "SupportingMACD", 12, 26, 9, 0, ai_0);
double l_icustom_12 = iCustom(Symbol(), 0, "SupportingMACD", 12, 26, 9, 0, ai_0 + 1);
double l_icustom_20 = iCustom(Symbol(), 0, "SupportingMACD", 12, 26, 9, 1, ai_0);
double l_icustom_28 = iCustom(Symbol(), 0, "SupportingMACD", 12, 26, 9, 1, ai_0 + 1);
if (l_icustom_4 > l_icustom_20 && l_icustom_12 <= l_icustom_28) return (1);
if (l_icustom_4 < l_icustom_20 && l_icustom_12 >= l_icustom_28) return (1);
return (0);
}

int ThreeBars(int ai_0) {
int l_count_4 = 0;
for (int l_count_8 = 0; l_count_8 < 16; l_count_8++)
if (g_ibuf_112[ai_0 + l_count_8] != 0.0 || g_ibuf_128[ai_0 + l_count_8] != 0.0) l_count_4++;
if (l_count_4 > 2) return (1);
return (0);
}

void SendAlert(string as_0) {
if (Time[1] != gi_172) {
if (SoundAlert) {
if (as_0 == "wb") Alert(Symbol() + " => TF: " + Period() + "M => " + TimeToStr(TimeCurrent()) + " white bar");
if (as_0 == "wbmacd") Alert(Symbol() + " => TF: " + Period() + "M => " + TimeToStr(TimeCurrent()) + " white bar + macd");
if (as_0 == "rb") Alert(Symbol() + " => TF: " + Period() + "M => " + TimeToStr(TimeCurrent()) + " red bar");
if (as_0 == "tb") Alert(Symbol() + " => TF: " + Period() + "M => " + TimeToStr(TimeCurrent()) + " three bars");
if (as_0 == "yb") Alert(Symbol() + " => TF: " + Period() + "M => " + TimeToStr(TimeCurrent()) + " whitebar + trendwave");
}
if (EmailAlert) {
if (as_0 == "wb") SendMail("!SuperADX Alert", Symbol() + " => TF: " + Period() + "M => " + TimeToStr(TimeCurrent()) + " white bar");
if (as_0 == "wbmacd") SendMail("!SuperADX Alert", Symbol() + " => TF: " + Period() + "M => " + TimeToStr(TimeCurrent()) + " white bar + macd");
if (as_0 == "rb") SendMail("!SuperADX Alert", Symbol() + " => TF: " + Period() + "M => " + TimeToStr(TimeCurrent()) + " red bar");
if (as_0 == "tb") SendMail("!SuperADX Alert", Symbol() + " => TF: " + Period() + "M => " + TimeToStr(TimeCurrent()) + " three bars");
if (as_0 == "yb") SendMail("!SuperADX Alert", Symbol() + " => TF: " + Period() + "M => " + TimeToStr(TimeCurrent()) + " whitebar + trendwave");
}
gi_172 = Time[1];
}
}
 

Attachments

Last edited: