有代码,求高人写个自动交易EA

 

/*
Generated by EX4-TO-MQ4 decompiler V4.0.224.1 []
Website: http://purebeam.biz/
E-mail : purebeam@gmail.com
*/
#property link "http://www.xpworx.com/"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Yellow
#property indicator_color2 FireBrick
#property indicator_color3 Green
#property indicator_color4 Black

extern bool Alert_On = FALSE;
extern bool Arrows_On = FALSE;
extern bool Email_Alert = FALSE;
int gi_88 = 159;
int gi_92 = 159;
int g_color_96 = Lime;
int g_color_100 = Red;
int gi_unused_104 = 1;
int g_width_108 = 1;
string gs_112 = "";
string gs_120 = "";
double g_ibuf_128[];
double g_ibuf_132[];
double g_ibuf_136[];
double g_ibuf_140[];
double g_ibuf_144[];
double g_ibuf_148[];
double g_ibuf_152[];
int gi_156;
int g_bars_160 = 0;
int g_bars_164 = 0;
int g_bars_168 = 0;
int g_bars_172 = 0;
int gi_176 = 0;
int g_bars_180 = 0;
int g_bars_184 = 0;
int g_bars_188 = 0;
int g_bars_192 = 0;
int g_bars_196 = 0;
int g_bars_200 = 0;
int g_bars_204 = 0;
int g_bars_208 = 0;

int init() {
DeleteStamp();
gs_120 = GenVer();
DeleteAllObjects();
IndicatorBuffers(7);
SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 1);
SetIndexBuffer(2, g_ibuf_128);
SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 1);
SetIndexBuffer(1, g_ibuf_132);
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1);
SetIndexBuffer(0, g_ibuf_136);
SetIndexBuffer(3, g_ibuf_152);
SetIndexBuffer(4, g_ibuf_140);
SetIndexBuffer(5, g_ibuf_144);
SetIndexBuffer(6, g_ibuf_148);
SetIndexLabel(0, "XP Moving Average");
SetIndexLabel(1, "DownBuffer");
SetIndexLabel(2, "UpBuffer");
SetIndexLabel(3, "Signal");
switch (Period()) {
case PERIOD_M1:
gi_156 = 5;
break;
case PERIOD_M5:
gi_156 = 7;
break;
case PERIOD_M15:
gi_156 = 10;
break;
case PERIOD_M30:
gi_156 = 15;
break;
case PERIOD_H1:
gi_156 = 20;
break;
case PERIOD_H4:
gi_156 = 30;
break;
case PERIOD_D1:
gi_156 = 80;
break;
case PERIOD_W1:
gi_156 = 150;
break;
case PERIOD_MN1:
gi_156 = 250;
}
return (0);
}

int deinit() {
DeleteStamp();
DeleteAllObjects();
return (0);
}

void start() {
int li_0;
double ld_20;
StampVersion(gs_112, gs_120, 5, 20);
int li_4 = 0;
int li_8 = IndicatorCounted();
if (li_8 >= 0) {
if (li_8 > 0) li_8--;
li_0 = Bars - li_8;
switch (6) {
case 0:
case 1:
case 2:
case 3:
for (li_4 = 0; li_4 < li_0; li_4++) g_ibuf_140[li_4] = iMA(NULL, 0, 55, 0, 6, PRICE_CLOSE, li_4);
break;
case 4:
for (li_4 = 0; li_4 < li_0; li_4++) g_ibuf_144[li_4] = iMA(NULL, 0, 55, 0, MODE_EMA, PRICE_CLOSE, li_4);
for (li_4 = 0; li_4 < li_0; li_4++) g_ibuf_148[li_4] = iMAOnArray(g_ibuf_144, 0, 55, 0, MODE_EMA, li_4);
for (li_4 = 0; li_4 < li_0; li_4++) g_ibuf_140[li_4] = iMAOnArray(g_ibuf_148, 0, 55, 0, MODE_EMA, li_4);
break;
case 5:
for (li_4 = 0; li_4 < li_0; li_4++) g_ibuf_144[li_4] = iMA(NULL, 0, 55, 0, MODE_EMA, PRICE_CLOSE, li_4);
for (li_4 = 0; li_4 < li_0; li_4++) g_ibuf_140[li_4] = iMAOnArray(g_ibuf_144, 0, 55, 0, MODE_EMA, li_4);
break;
case 6:
for (li_4 = 0; li_4 < li_0; li_4++) g_ibuf_140[li_4] = iCustom(NULL, 0, "THV3 T3", 55, 0.3, 0, li_4);
break;
case 7:
for (li_4 = 0; li_4 < li_0; li_4++) g_ibuf_140[li_4] = iCustom(NULL, 0, "JMA", 55, 0, 0, li_4);
break;
case 8:
for (li_4 = 0; li_4 < li_0; li_4++) g_ibuf_140[li_4] = iCustom(NULL, 0, "HMA", 55, 0, li_4);
break;
case 9:
for (li_4 = 0; li_4 < li_0; li_4++) g_ibuf_140[li_4] = iCustom(NULL, 0, "DECEMA_v1", 55, 0, 0, li_4);
break;
case 10:
for (li_4 = 0; li_4 < li_0; li_4++) g_ibuf_140[li_4] = iCustom(NULL, 0, "SATL", 0, li_4);
}
for (int l_index_16 = 0; l_index_16 < li_0; l_index_16++) {
g_ibuf_128[l_index_16] = g_ibuf_140[l_index_16];
g_ibuf_132[l_index_16] = g_ibuf_140[l_index_16];
g_ibuf_136[l_index_16] = g_ibuf_140[l_index_16];
}
for (l_index_16 = 0; l_index_16 < li_0; l_index_16++) {
ld_20 = 0;
for (int li_28 = l_index_16 + 1; li_28 <= l_index_16 + 4; li_28++) ld_20 += g_ibuf_140[li_28];
ld_20 /= 4.0;
if (g_ibuf_140[l_index_16] < ld_20) g_ibuf_128[l_index_16] = EMPTY_VALUE;
else {
if (g_ibuf_140[l_index_16] > ld_20) g_ibuf_132[l_index_16] = EMPTY_VALUE;
else {
g_ibuf_128[l_index_16] = EMPTY_VALUE;
g_ibuf_132[l_index_16] = EMPTY_VALUE;
}
}
}
for (l_index_16 = 0; l_index_16 < li_0; l_index_16++) {
g_ibuf_152[l_index_16] = 0;
if (g_ibuf_128[l_index_16 + 1] == EMPTY_VALUE && g_ibuf_128[l_index_16] != EMPTY_VALUE && g_ibuf_136[l_index_16 + 1] != g_ibuf_128[l_index_16]) {
if (Arrows_On && l_index_16 != 0) DrawObject(1, l_index_16, g_ibuf_140[l_index_16] - gi_156 * Point);
if (Arrows_On && l_index_16 == 0) DrawOnce(1, l_index_16, g_ibuf_140[l_index_16] - gi_156 * Point, 1);
g_ibuf_152[l_index_16] = 1;
}
if (g_ibuf_132[l_index_16 + 1] == EMPTY_VALUE && g_ibuf_132[l_index_16] != EMPTY_VALUE && g_ibuf_136[l_index_16 + 1] != g_ibuf_132[l_index_16]) {
if (Arrows_On && l_index_16 != 0) DrawObject(2, l_index_16, g_ibuf_140[l_index_16] + gi_156 * Point);
if (Arrows_On && l_index_16 == 0) DrawOnce(2, l_index_16, g_ibuf_140[l_index_16] + gi_156 * Point, 2);
g_ibuf_152[l_index_16] = -1;
}
}
if (Alert_On) {
if (g_ibuf_128[1] == EMPTY_VALUE && g_ibuf_128[0] != EMPTY_VALUE && g_ibuf_136[1] != g_ibuf_128[0]) AlertOnce(Symbol() + ":" + PeriodToText() + "Coral Signal Buy", 1);
if (g_ibuf_132[1] == EMPTY_VALUE && g_ibuf_132[0] != EMPTY_VALUE && g_ibuf_136[1] != g_ibuf_132[0]) AlertOnce(Symbol() + ":" + PeriodToText() + "Coral Signal Sell", 2);
}
if (Email_Alert) {
if (g_ibuf_128[1] == EMPTY_VALUE && g_ibuf_128[0] != EMPTY_VALUE && g_ibuf_136[1] != g_ibuf_128[0]) SendMailOnce("Coral Signal", Symbol() + ":" + PeriodToText() + "Coral Signal Buy", 1);
if (g_ibuf_132[1] == EMPTY_VALUE && g_ibuf_132[0] != EMPTY_VALUE && g_ibuf_136[1] != g_ibuf_132[0]) SendMailOnce("Coral Signal", Symbol() + ":" + PeriodToText() + " Coral Signal Sell", 2);
}
}
}

int DrawOnce(int ai_0, int ai_4, double ad_8, int ai_16) {
switch (ai_16) {
case 1:
if (g_bars_160 == 0 || g_bars_160 < Bars) {
DrawObject(ai_0, ai_4, ad_8);
g_bars_160 = Bars;
return (1);
}
case 2:
if (g_bars_164 == 0 || g_bars_164 < Bars) {
DrawObject(ai_0, ai_4, ad_8);
g_bars_164 = Bars;
return (1);
}
case 3:
if (g_bars_168 == 0 || g_bars_168 < Bars) {
DrawObject(ai_0, ai_4, ad_8);
g_bars_168 = Bars;
return (1);
}
case 4:
if (g_bars_172 == 0 || g_bars_172 < Bars) {
DrawObject(ai_0, ai_4, ad_8);
g_bars_172 = Bars;
return (1);
}
}
return (0);
}

void DrawObject(int ai_0, int ai_4, double a_price_8) {
gi_176++;
string l_name_16 = "";
if (ai_0 == 1) {
l_name_16 = "Buy Option" + DoubleToStr(gi_176, 0);
ObjectCreate(l_name_16, OBJ_ARROW, 0, Time[ai_4], a_price_8);
ObjectSet(l_name_16, OBJPROP_COLOR, g_color_96);
ObjectSet(l_name_16, OBJPROP_ARROWCODE, gi_88);
ObjectSet(l_name_16, OBJPROP_WIDTH, g_width_108);
}
if (ai_0 == 2) {
l_name_16 = "Sell Option" + DoubleToStr(gi_176, 0);
ObjectCreate(l_name_16, OBJ_ARROW, 0, Time[ai_4], a_price_8);
ObjectSet(l_name_16, OBJPROP_COLOR, g_color_100);
ObjectSet(l_name_16, OBJPROP_ARROWCODE, gi_92);
ObjectSet(l_name_16, OBJPROP_WIDTH, g_width_108);
}
ObjectsRedraw();
}

void DeleteAllObjects() {
string l_name_4;
int l_objs_total_0 = ObjectsTotal();
for (int li_12 = ObjectsTotal() - 1; li_12 >= 0; li_12--) {
l_name_4 = ObjectName(li_12);
if (StringFind(l_name_4, "Option", 0) > -1) ObjectDelete(l_name_4);
ObjectsRedraw();
}
}

int AlertOnce(string as_0, int ai_8) {
switch (ai_8) {
case 1:
if (g_bars_180 == 0 || g_bars_180 < Bars) {
Alert(as_0);
g_bars_180 = Bars;
return (1);
}
break;
case 2:
if (g_bars_184 == 0 || g_bars_184 < Bars) {
Alert(as_0);
g_bars_184 = Bars;
return (1);
}
break;
case 3:
if (g_bars_188 == 0 || g_bars_188 < Bars) {
Alert(as_0);
g_bars_188 = Bars;
return (1);
}
break;
case 4:
if (g_bars_192 == 0 || g_bars_192 < Bars) {
Alert(as_0);
g_bars_192 = Bars;
return (1);
}
break;
}
return (0);
}

int SendMailOnce(string as_0, string as_8, int ai_16) {
switch (ai_16) {
case 1:
if (g_bars_196 == 0 || g_bars_196 < Bars) {
SendMail(as_0, as_8);
g_bars_196 = Bars;
return (1);
}
break;
case 2:
if (g_bars_200 == 0 || g_bars_200 < Bars) {
SendMail(as_0, as_8);
g_bars_200 = Bars;
return (1);
}
break;
case 3:
if (g_bars_204 == 0 || g_bars_204 < Bars) {
SendMail(as_0, as_8);
g_bars_204 = Bars;
return (1);
}
break;
case 4:
if (g_bars_208 == 0 || g_bars_208 < Bars) {
SendMail(as_0, as_8);
g_bars_208 = Bars;
return (1);
}
break;
}
return (0);
}

void TakeScreenShot(int ai_0 = -1) {
int li_4 = 1;
if (!GlobalVariableCheck("ssc")) {
GlobalVariableSet("ssc", 1);
li_4 = 1;
} else {
li_4 = GlobalVariableGet("ssc") + 1.0;
GlobalVariableSet("ssc", li_4);
}
if (ai_0 > 0 && li_4 > ai_0) return;
string ls_8 = "xpMA\\" + "xpMA_" + Symbol() + "_" + DoubleToStr(li_4, 0) + ".jpg";
WindowScreenShot(ls_8, 320, 480);
}

string PeriodToText() {
switch (Period()) {
case PERIOD_M1:
return ("M1");
case PERIOD_M5:
return ("M5");
case PERIOD_M15:
return ("M15");
case PERIOD_M30:
return ("M30");
case PERIOD_H1:
return ("H1");
case PERIOD_H4:
return ("H4");
case PERIOD_D1:
return ("D1");
case PERIOD_W1:
return ("W1");
case PERIOD_MN1:
return ("MN1");
}
return ("");
}

void StampVersion(string as_0, string as_8, int a_x_16, int a_y_20) {
string l_name_36;
string ls_24 = "Stamp_" + as_0;
int l_objs_total_32 = ObjectsTotal();
for (int li_44 = 0; li_44 < ObjectsTotal(); li_44++) {
l_name_36 = ObjectName(li_44);
if (StringFind(l_name_36, ls_24, 0) > -1) {
ObjectSet(ls_24, OBJPROP_XDISTANCE, a_x_16);
ObjectSet(ls_24, OBJPROP_YDISTANCE, a_y_20);
ObjectsRedraw();
} else {
ObjectCreate(ls_24, OBJ_LABEL, 0, 0, 0);
ObjectSetText(ls_24, as_0 + " " + as_8, 6, "arial", DarkGreen);
ObjectSet(ls_24, OBJPROP_XDISTANCE, a_x_16);
ObjectSet(ls_24, OBJPROP_YDISTANCE, a_y_20);
ObjectsRedraw();
}
}
if (ObjectsTotal() == 0) {
ObjectCreate(ls_24, OBJ_LABEL, 0, 0, 0);
ObjectSetText(ls_24, as_0 + " " + as_8, 6, "arial", DarkGreen);
ObjectSet(ls_24, OBJPROP_XDISTANCE, a_x_16);
ObjectSet(ls_24, OBJPROP_YDISTANCE, a_y_20);
ObjectsRedraw();
}
}

void DeleteStamp() {
string l_name_4;
int l_objs_total_0 = ObjectsTotal();
for (int li_12 = ObjectsTotal() - 1; li_12 >= 0; li_12--) {
l_name_4 = ObjectName(li_12);
if (StringFind(l_name_4, "Stamp", 0) > -1) ObjectDelete(l_name_4);
ObjectsRedraw();
}
}

string GenVer() {
string ls_0 = "BS";
return (ls_0 + "(" + 10 + ")");

谢谢了,写好后联系:QQ:353572353
}

原因: