Coding help - page 326

 

Alert on changing direction

Hello,

In an EA that buy, for example if MA10>MA20 (and sell opposite), how can I write an alert if Buy and MA10<MA20 ( and opposite) ?

Thanks.

Jo

 
Jovager:
Hello,

In an EA that buy, for example if MA10>MA20 (and sell opposite), how can I write an alert if Buy and MA10<MA20 ( and opposite) ?

Thanks.

Jo

Try like this :

if (MA10previousMA20) for the first condition

if (MA10previous>MA20previous && MA10<MA20) for the second condition

 
mladen:
Are you trying alerts in a back test? If yes, then that is the cause : alerts do not work in back test

Thanks. They used to, as in Build 509.

 
Big Be:
Thanks. They used to, as in Build 509.

:):)

A lot of things used to work which now does not work in this "new metatrader" any more. Try out multi time frame in visual back test and you will have an "amusement" for the weekend

 
mladen:
Looks familiar Will check if it exists already

Any luck on this Mr Mladen ...

Were you able to find it .??

Thanks

 
mladen:
:):):) A lot of things used to work which now does not work in this "new metatrader" any more. Try out multi time frame in visual back test and you will have an "amusement" for the weekend

Hi Mladen

I see that you are one of those helpful programmers so I might ask if you could possibly make an EA out of the added indicator. This one is not repainting and delivers astounding good signals!

Files:
 

Hello Guys, pls help to look at this code, what can be done to make it alert and show arrows on current candle.

Thanks in advance

// B83A886A5C437CCD9AC15473FD6F1788

void f0_2(string As_0) {

if (IsTesting() == FALSE && IsOptimization() == FALSE && IsVisualMode() == FALSE) SendMail(WindowExpertName(), As_0);

}

// A8CFDE6331BD59EB2AC96F8911C4B666

void f0_1(string A_name_0, string A_text_8, string A_fontname_16, int A_fontsize_24, color A_color_28, int A_y_32, int A_x_36, int A_corner_40, int A_bool_44) {

ObjectCreate(A_name_0, OBJ_LABEL, 0, 0, 0);

ObjectSetText(A_name_0, A_text_8, A_fontsize_24, A_fontname_16, A_color_28);

ObjectSet(A_name_0, OBJPROP_CORNER, A_corner_40);

ObjectSet(A_name_0, OBJPROP_XDISTANCE, A_x_36);

ObjectSet(A_name_0, OBJPROP_YDISTANCE, A_y_32);

ObjectSet(A_name_0, OBJPROP_BACK, A_bool_44);

}

// 085FEA7ABDC5D904FE69A3081EFD7398

void f0_0(string As_0, int GetBar) {

if (IsTesting() == FALSE && IsOptimization() == FALSE && IsVisualMode() == FALSE) {

if (sound) PlaySound("News.wav");

if (alert) Alert("New signal " + As_0+ " @ Symbol: "+Symbol()+" & Period: M"+Period()+" & Time: "+TimeToString(GetBar,TIME_MINUTES|TIME_SECONDS));

if (email) f0_2("New signal " + As_0+ " @ Symbol: "+Symbol()+" & Period: M"+Period()+" & Time: "+TimeToString(GetBar,TIME_MINUTES|TIME_SECONDS));

}

}

// BE8F80182E0C983916DA7338C2C1C040

int f0_3(string A_name_0, string A_name_8) {

if (ObjectFind(A_name_0) == -1) return (0);

if (ObjectFind(A_name_8) == -1) return (0);

if (ObjectGet(A_name_0, OBJPROP_XDISTANCE) > ObjectGet(A_name_8, OBJPROP_XDISTANCE) - 10.0 && ObjectGet(A_name_0, OBJPROP_XDISTANCE) < ObjectGet(A_name_8, OBJPROP_XDISTANCE) +

10.0) {

if (ObjectGet(A_name_0, OBJPROP_YDISTANCE) > ObjectGet(A_name_8, OBJPROP_YDISTANCE) - 10.0 && ObjectGet(A_name_0, OBJPROP_YDISTANCE) < ObjectGet(A_name_8, OBJPROP_YDISTANCE) +

10.0) return (1);

}

return (0);

}

// E4DB2306E8CC4DEB5830201DE61935CA

double f0_4() {

double Ld_ret_0 = 0;

for (int pos_8 = 0; pos_8 < OrdersTotal(); pos_8++) {

if (OrderSelect(pos_8, SELECT_BY_POS, MODE_TRADES) == TRUE)

if (OrderSymbol() == Symbol()) Ld_ret_0 += OrderProfit();

}

return (Ld_ret_0);

}

// EA2B2676C28C0DB26D39331A336C6B92

int start() {

string Ls_0;

double iatr_20;

double Ld_28;

double Ld_36;

int TimeBar=0;

if (f0_3("x", "r4") == 1) {

alert = FALSE;

ObjectDelete("r2");

f0_1("x", "G", "Wingdings", 25, Pink, 160, 55, 1, FALSE);

PlaySound("Tick.wav");

G_time_192 = 0;

RefreshRates();

}

if (f0_3("x", "t4") == 1) {

sound = FALSE;

ObjectDelete("t2");

f0_1("x", "G", "Wingdings", 25, Pink, 160, 55, 1, FALSE);

PlaySound("Tick.wav");

G_time_192 = 0;

RefreshRates();

}

if (f0_3("x", "u4") == 1) {

email = FALSE;

ObjectDelete("u2");

f0_1("x", "G", "Wingdings", 25, Pink, 160, 55, 1, FALSE);

PlaySound("Tick.wav");

G_time_192 = 0;

RefreshRates();

}

if (f0_3("x", "r3") == 1) {

alert = TRUE;

f0_1("r2", "þ", "Wingdings", 14, Red, 55, 65, 1, FALSE);

f0_1("x", "G", "Wingdings", 25, Pink, 160, 55, 1, FALSE);

PlaySound("Tick.wav");

G_time_192 = 0;

RefreshRates();

}

if (f0_3("x", "t3") == 1) {

sound = TRUE;

f0_1("t2", "þ", "Wingdings", 14, Red, 80, 65, 1, FALSE);

f0_1("x", "G", "Wingdings", 25, Pink, 160, 55, 1, FALSE);

PlaySound("Tick.wav");

G_time_192 = 0;

RefreshRates();

}

if (f0_3("x", "u3") == 1) {

email = TRUE;

f0_1("u2", "þ", "Wingdings", 14, Red, 105, 65, 1, FALSE);

f0_1("x", "G", "Wingdings", 25, Pink, 160, 55, 1, FALSE);

PlaySound("Tick.wav");

G_time_192 = 0;

RefreshRates();

}

for (int index_8 = 0; index_8 < 100; index_8++) {

if (G_ibuf_108 < 1000.0) {

TimeBar=Time;

Ls_0 = "BUY";

break;

}

if (G_ibuf_112 < 1000.0) {

TimeBar=Time;

Ls_0 = "SELL";

break;

}

}

if (Ls_0 == "BUY" && ObjectDescription("Signal1") != "BUY") {

f0_0("BUY",TimeBar);

f0_1("Signal1", "BUY", "Wingdings 3", 30, White, 80, 32, 1, FALSE);

}

if (Ls_0 == "SELL" && ObjectDescription("Signal1") != "SELL") {

f0_0("SELL",TimeBar);

f0_1("Signal1", "SELL", "Wingdings 3", 30, White, 80, 25, 1, FALSE);

}

f0_1("r1", "Profit", "Arial", 10, Lime, 50, 80, 1, FALSE);

f0_1("Pr", DoubleToStr(f0_4(), 0), "Arial", 13, Yellow, 50, 35, 1, FALSE);

if (Time[0] == G_time_192) return (0);

G_time_192 = Time[0];

int Li_12 = Bars - IndicatorCounted();

if (IndicatorCounted() > 0) Li_12++;

for (int bars_16 = Bars; bars_16 > 0; bars_16--) {

if (bars_16 <= HistoriBar) {

iatr_20 = iATR(NULL, 0, 100, 0);

Ld_28 = Close - iATR(NULL, 0, PeriodIndikator, bars_16) * Factor;

Ld_36 = Close + iATR(NULL, 0, PeriodIndikator, bars_16) * Factor;

if (Ld_28 > Gd_156 && Gi_180 == 1) Gd_156 = Ld_28;

if (Ld_36 < Gd_148 && Gi_180 == 2) Gd_148 = Ld_36;

if (Gd_156 != 0.0 && Gi_180 == 1) Gd_unused_124 = Gd_156;

if (Gd_148 != 1000.0 && Gi_180 == 2) Gd_unused_132 = Gd_148;

if (Close < Gd_156 && Gi_180 == 1) {

Gi_180 = 2;

if (bars_16 < HistoriBar / 2.0) G_ibuf_112 = High + iatr_20;

Gd_156 = 0;

}

if (Close > Gd_148 && Gi_180 == 2) {

Gi_180 = 1;

if (bars_16 < HistoriBar / 2.0) G_ibuf_108 = Low - iatr_20;

Gd_148 = 1000;

}

}

}

return (0);

}

// 52D46093050F38C27267BCE42543EF60

int deinit() {

 
wolfsch:
Hi Mladen I see that you are one of those helpful programmers so I might ask if you could possibly make an EA out of the added indicator. This one is not repainting and delivers astounding good signals!

wolfsch

I must disappoint you but that indicator is using T3 clean and snake indicator. Now, T3 does not repaint. But "snake" is centered tma and it recalculates which makes that indicator a recalculating (repainting) kind

PS: that is actually a renamed "T3 TMA combination" indicator which was then renamed to "uni cross" indicator. More information about it you can find here : https://www.mql5.com/en/forum/general

 
emmany4:
Hello Guys, pls help to look at this code, what can be done to make it alert and show arrows on current candle.

Thanks in advance

// B83A886A5C437CCD9AC15473FD6F1788

void f0_2(string As_0) {

if (IsTesting() == FALSE && IsOptimization() == FALSE && IsVisualMode() == FALSE) SendMail(WindowExpertName(), As_0);

}

// A8CFDE6331BD59EB2AC96F8911C4B666

void f0_1(string A_name_0, string A_text_8, string A_fontname_16, int A_fontsize_24, color A_color_28, int A_y_32, int A_x_36, int A_corner_40, int A_bool_44) {

ObjectCreate(A_name_0, OBJ_LABEL, 0, 0, 0);

ObjectSetText(A_name_0, A_text_8, A_fontsize_24, A_fontname_16, A_color_28);

ObjectSet(A_name_0, OBJPROP_CORNER, A_corner_40);

ObjectSet(A_name_0, OBJPROP_XDISTANCE, A_x_36);

ObjectSet(A_name_0, OBJPROP_YDISTANCE, A_y_32);

ObjectSet(A_name_0, OBJPROP_BACK, A_bool_44);

}

// 085FEA7ABDC5D904FE69A3081EFD7398

void f0_0(string As_0, int GetBar) {

if (IsTesting() == FALSE && IsOptimization() == FALSE && IsVisualMode() == FALSE) {

if (sound) PlaySound("News.wav");

if (alert) Alert("New signal " + As_0+ " @ Symbol: "+Symbol()+" & Period: M"+Period()+" & Time: "+TimeToString(GetBar,TIME_MINUTES|TIME_SECONDS));

if (email) f0_2("New signal " + As_0+ " @ Symbol: "+Symbol()+" & Period: M"+Period()+" & Time: "+TimeToString(GetBar,TIME_MINUTES|TIME_SECONDS));

}

}

// BE8F80182E0C983916DA7338C2C1C040

int f0_3(string A_name_0, string A_name_8) {

if (ObjectFind(A_name_0) == -1) return (0);

if (ObjectFind(A_name_8) == -1) return (0);

if (ObjectGet(A_name_0, OBJPROP_XDISTANCE) > ObjectGet(A_name_8, OBJPROP_XDISTANCE) - 10.0 && ObjectGet(A_name_0, OBJPROP_XDISTANCE) < ObjectGet(A_name_8, OBJPROP_XDISTANCE) +

10.0) {

if (ObjectGet(A_name_0, OBJPROP_YDISTANCE) > ObjectGet(A_name_8, OBJPROP_YDISTANCE) - 10.0 && ObjectGet(A_name_0, OBJPROP_YDISTANCE) < ObjectGet(A_name_8, OBJPROP_YDISTANCE) +

10.0) return (1);

}

return (0);

}

// E4DB2306E8CC4DEB5830201DE61935CA

double f0_4() {

double Ld_ret_0 = 0;

for (int pos_8 = 0; pos_8 < OrdersTotal(); pos_8++) {

if (OrderSelect(pos_8, SELECT_BY_POS, MODE_TRADES) == TRUE)

if (OrderSymbol() == Symbol()) Ld_ret_0 += OrderProfit();

}

return (Ld_ret_0);

}

// EA2B2676C28C0DB26D39331A336C6B92

int start() {

string Ls_0;

double iatr_20;

double Ld_28;

double Ld_36;

int TimeBar=0;

if (f0_3("x", "r4") == 1) {

alert = FALSE;

ObjectDelete("r2");

f0_1("x", "G", "Wingdings", 25, Pink, 160, 55, 1, FALSE);

PlaySound("Tick.wav");

G_time_192 = 0;

RefreshRates();

}

if (f0_3("x", "t4") == 1) {

sound = FALSE;

ObjectDelete("t2");

f0_1("x", "G", "Wingdings", 25, Pink, 160, 55, 1, FALSE);

PlaySound("Tick.wav");

G_time_192 = 0;

RefreshRates();

}

if (f0_3("x", "u4") == 1) {

email = FALSE;

ObjectDelete("u2");

f0_1("x", "G", "Wingdings", 25, Pink, 160, 55, 1, FALSE);

PlaySound("Tick.wav");

G_time_192 = 0;

RefreshRates();

}

if (f0_3("x", "r3") == 1) {

alert = TRUE;

f0_1("r2", "þ", "Wingdings", 14, Red, 55, 65, 1, FALSE);

f0_1("x", "G", "Wingdings", 25, Pink, 160, 55, 1, FALSE);

PlaySound("Tick.wav");

G_time_192 = 0;

RefreshRates();

}

if (f0_3("x", "t3") == 1) {

sound = TRUE;

f0_1("t2", "þ", "Wingdings", 14, Red, 80, 65, 1, FALSE);

f0_1("x", "G", "Wingdings", 25, Pink, 160, 55, 1, FALSE);

PlaySound("Tick.wav");

G_time_192 = 0;

RefreshRates();

}

if (f0_3("x", "u3") == 1) {

email = TRUE;

f0_1("u2", "þ", "Wingdings", 14, Red, 105, 65, 1, FALSE);

f0_1("x", "G", "Wingdings", 25, Pink, 160, 55, 1, FALSE);

PlaySound("Tick.wav");

G_time_192 = 0;

RefreshRates();

}

for (int index_8 = 0; index_8 < 100; index_8++) {

if (G_ibuf_108 < 1000.0) {

TimeBar=Time;

Ls_0 = "BUY";

break;

}

if (G_ibuf_112 < 1000.0) {

TimeBar=Time;

Ls_0 = "SELL";

break;

}

}

if (Ls_0 == "BUY" && ObjectDescription("Signal1") != "BUY") {

f0_0("BUY",TimeBar);

f0_1("Signal1", "BUY", "Wingdings 3", 30, White, 80, 32, 1, FALSE);

}

if (Ls_0 == "SELL" && ObjectDescription("Signal1") != "SELL") {

f0_0("SELL",TimeBar);

f0_1("Signal1", "SELL", "Wingdings 3", 30, White, 80, 25, 1, FALSE);

}

f0_1("r1", "Profit", "Arial", 10, Lime, 50, 80, 1, FALSE);

f0_1("Pr", DoubleToStr(f0_4(), 0), "Arial", 13, Yellow, 50, 35, 1, FALSE);

if (Time[0] == G_time_192) return (0);

G_time_192 = Time[0];

int Li_12 = Bars - IndicatorCounted();

if (IndicatorCounted() > 0) Li_12++;

for (int bars_16 = Bars; bars_16 > 0; bars_16--) {

if (bars_16 <= HistoriBar) {

iatr_20 = iATR(NULL, 0, 100, 0);

Ld_28 = Close - iATR(NULL, 0, PeriodIndikator, bars_16) * Factor;

Ld_36 = Close + iATR(NULL, 0, PeriodIndikator, bars_16) * Factor;

if (Ld_28 > Gd_156 && Gi_180 == 1) Gd_156 = Ld_28;

if (Ld_36 < Gd_148 && Gi_180 == 2) Gd_148 = Ld_36;

if (Gd_156 != 0.0 && Gi_180 == 1) Gd_unused_124 = Gd_156;

if (Gd_148 != 1000.0 && Gi_180 == 2) Gd_unused_132 = Gd_148;

if (Close < Gd_156 && Gi_180 == 1) {

Gi_180 = 2;

if (bars_16 < HistoriBar / 2.0) G_ibuf_112 = High + iatr_20;

Gd_156 = 0;

}

if (Close > Gd_148 && Gi_180 == 2) {

Gi_180 = 1;

if (bars_16 < HistoriBar / 2.0) G_ibuf_108 = Low - iatr_20;

Gd_148 = 1000;

}

}

}

return (0);

}

// 52D46093050F38C27267BCE42543EF60

int deinit() {

Hello Emmany4, if you find the original code for that EA would probably be able to add or fix the arrows and alerts for buy and sell, but that version is decompiled.

 
mrtools:
Hello Emmany4, if you find the original code for that EA would probably be able to add or fix the arrows and alerts for buy and sell, but that version is decompiled.

As far as I see that is an incomplete decompiled code of some super trend variation (the one using atr, not the cci version). Nothing else. Anyway, that code as is, can not work (large parts of it are missing)

Reason: