Writing EA from custom indicator

 

Hello,


I wonder if someone could write an EA from this indicator that I have.. what is needed is only to open trades according to alerts, and to set inputs like take profit, stop loss, lots.. and possibly, trading times.. I guess it shouldn't be difficult even for not an expert programmer..


thank you very much



//+------------------------------------------------------------------+
//| Thumbs.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"




#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 DodgerBlue
#property indicator_color2 Fuchsia
#property indicator_color3 DodgerBlue
#property indicator_color4 Fuchsia


int gi_80 = 0;
int gi_84 = 5;
int gi_88 = 0;
extern bool UseAlert = FALSE;
extern bool Email_Alerts = TRUE;
int gi_100 = 45;
int g_period_104 = 10;
int gi_108 = 5;
int gi_112 = 18;
double gd_116 = 2.0;
int gi_unused_124 = 0;
double gd_128 = 0.02;
double gd_136 = 0.2;
double g_ibuf_144[];
double g_ibuf_148[];
double g_ibuf_152[];
double g_ibuf_156[];
int g_bars_160 = 0;

int init() {
IndicatorBuffers(4);
SetIndexStyle(0, DRAW_ARROW);
SetIndexArrow(0, SYMBOL_THUMBSUP);
SetIndexBuffer(0, g_ibuf_144);
SetIndexEmptyValue(0, 0);
SetIndexStyle(1, DRAW_ARROW);
SetIndexArrow(1, SYMBOL_THUMBSDOWN);
SetIndexBuffer(1, g_ibuf_148);
SetIndexEmptyValue(1, 0);
SetIndexBuffer(2, g_ibuf_152);
SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 2);
SetIndexEmptyValue(2, 0);
SetIndexBuffer(3, g_ibuf_156);
SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 2);
SetIndexEmptyValue(3, 0);
ObjectCreate("text_object", OBJ_LABEL, 0, 0, 0);
ObjectSet("text_object", OBJPROP_XDISTANCE, 220);
ObjectSet("text_object", OBJPROP_YDISTANCE, 0);

return (0);
}

int deinit() {
return (0);
}

int start() {
double l_isar_16;
double l_icustom_24;
double l_icustom_32;
double l_icustom_40;
double l_icustom_48;
double l_icustom_56;
double l_icustom_64;
double l_ima_72;
double l_ima_80;
double l_ima_88;




string ls_0 = "(Thumbs";
if (Bars < 100) {
ls_0 = "Bars less than 100";
IndicatorShortName(ls_0);
return (0);
}
int l_ind_counted_8 = IndicatorCounted();
int li_12 = Bars - l_ind_counted_8;
if (l_ind_counted_8 == 0) li_12 = Bars - 50;
for (int li_96 = li_12; li_96 >= 0; li_96--) {
HideTestIndicators(TRUE);
l_isar_16 = iSAR(Symbol(), 0, gd_128, gd_136, li_96);
l_icustom_24 = iCustom(NULL, 0, "RSI", gi_100, 0, li_96);
l_icustom_32 = iCustom(NULL, 0, "RSI", gi_100, 0, li_96 + 1);
l_icustom_40 = iCustom(NULL, 0, "RSI", gi_100, 0, li_96 + 2);
l_icustom_48 = iCustom(NULL, 0, "PF1", gi_108, gi_112, gd_116, 0, li_96);
l_icustom_56 = iCustom(NULL, 0, "PF1", gi_108, gi_112, gd_116, 0, li_96 + 1);
l_icustom_64 = iCustom(NULL, 0, "PF1", gi_108, gi_112, gd_116, 0, li_96 + 2);
l_ima_72 = iMA(NULL, 0, g_period_104, 0, MODE_SMA, PRICE_CLOSE, li_96);
l_ima_80 = iMA(NULL, 0, g_period_104, 0, MODE_SMA, PRICE_CLOSE, li_96 + 1);
l_ima_88 = iMA(NULL, 0, g_period_104, 0, MODE_SMA, PRICE_CLOSE, li_96 + 2);
HideTestIndicators(FALSE);
if (l_icustom_32 < l_icustom_24 || l_icustom_40 < l_icustom_32 && l_icustom_24 >= 30.0 && NormalizeDouble(l_icustom_48 - l_ima_72 - 1.0 * Point, 4) >= 0.0 && l_ima_80 >= l_icustom_56 ||
l_ima_88 >= l_icustom_64) {
if (l_ima_88 >= l_icustom_64 && g_ibuf_144[li_96 + 2] == 0.0 && Close[li_96] > l_isar_16) {
g_ibuf_144[li_96 + 1] = Low[li_96 + 1] - gi_84 * Point;
g_ibuf_152[li_96 + 1] = Close[li_96 + 1] + gi_88 * Point;
g_ibuf_152[li_96] = Close[li_96 + 1] + gi_88 * Point;
if (li_96 - 1 >= 0) g_ibuf_152[li_96 - 1] = Close[li_96 + 1] + gi_88 * Point;
if (li_96 - 2 >= 0) g_ibuf_152[li_96 - 2] = Close[li_96 + 1] + gi_88 * Point;
if (li_96 == 0 && g_bars_160 != Bars && UseAlert && Email_Alerts) {
Alert(" Long ", Symbol(), " ", Period(), " at ", Ask, " (", TimeToStr(Time[li_96]), ")");
g_bars_160 = Bars;
}
if (Email_Alerts == TRUE) SendMail("Long Alert", " Time to set EA now ON for Long Grid " + Symbol() + " " + Period() + " at " + Ask + " (" + TimeToStr(TimeCurrent()) + ")");
}
} else {
if (l_icustom_32 > l_icustom_24 || l_icustom_40 > l_icustom_32 && l_icustom_24 <= 70.0 && NormalizeDouble(l_ima_72 - 1.0 * Point - l_icustom_48, 4) >= 0.0 && l_ima_80 <= l_icustom_56 ||
l_ima_88 <= l_icustom_64) {
if (l_ima_88 <= l_icustom_64 && g_ibuf_148[li_96 + 2] == 0.0 && Close[li_96] < l_isar_16) {
g_ibuf_148[li_96 + 1] = High[li_96 + 1] + gi_84 * Point;
g_ibuf_156[li_96 + 1] = Close[li_96 + 1] - gi_88 * Point;
g_ibuf_156[li_96] = Close[li_96 + 1] - gi_88 * Point;
if (li_96 - 1 >= 0) g_ibuf_156[li_96 - 1] = Close[li_96 + 1] - gi_88 * Point;
if (li_96 - 2 >= 0) g_ibuf_156[li_96 - 2] = Close[li_96 + 1] - gi_88 * Point;
if (li_96 == 0 && g_bars_160 != Bars && UseAlert && Email_Alerts) {
Alert(" Short ", Symbol(), " ", Period(), " at ", Bid, " (", TimeToStr(Time[li_96]), ")");
g_bars_160 = Bars;
}
if (Email_Alerts == TRUE) SendMail("Short Alert", " Time to set EA now ON for Short Grid " + Symbol() + " " + Period() + " at " + Bid + " (" + TimeToStr(TimeCurrent()) + ")");
}
}
}
}
return (0);
}