MQL4 Learning - page 61

 

help with sound alert

I could use some help with my nested if statement below - the Alertmsg & the email triggers are happening properly, but the sound files are not playing appropriately - they are playing but not the right sound with the event.

any help would be appreciated:

Dave

*******************

{

ind_buffer3 = EMPTY_VALUE; ind_buffer4 = EMPTY_VALUE;

if (ind_buffer1 > ind_buffer2 && ind_buffer1 < ind_buffer2)

{ ind_buffer3 = Low - 1 * Point;

AlertMsg = "BUY Signal";

TradeType = 1 ;

PlaySound("airforce.wav");}

if (ind_buffer1 ind_buffer2)

{ ind_buffer4 = High + 1 * Point;

AlertMsg = "SELL Signal";

TradeType = -1;

PlaySound("tires.wav");}

if (eMailAlerts_On && LastTradeType != TradeType && LastTradeTime != Time[0])

{LastTradeType = TradeType;

LastTradeTime = Time[0];

SendMail("EA Alert: Mac-Daddy Lunge// ",Symbol()+" - "+AlertMsg);}

}

//---- done

return(0);

}

 

Try this:

{

ind_buffer3 = EMPTY_VALUE; ind_buffer4 = EMPTY_VALUE;

if (ind_buffer1 > ind_buffer2 && ind_buffer1 < ind_buffer2&&TradeType != 1)

{ ind_buffer3 = Low - 1 * Point;

AlertMsg = "BUY Signal";

TradeType = 1 ;

PlaySound("airforce.wav");}

if (ind_buffer1 ind_buffer2&&TradeType !=-1)

{ ind_buffer4 = High + 1 * Point;

AlertMsg = "SELL Signal";

TradeType = -1;

PlaySound("tires.wav");}

if (eMailAlerts_On && LastTradeType != TradeType && LastTradeTime != Time[0])

{LastTradeType = TradeType;

LastTradeTime = Time[0];

SendMail("EA Alert: Mac-Daddy Lunge// ",Symbol()+" - "+AlertMsg);}

}

//---- done

return(0);

}
 

Roger - thanks.

That didn't fix it, but it's helped. I'm using this code with an EA that points MACD dots & I need to figure out how to have it only play the sound when a new dot is painted, after the EA is run (not for all the history dots that get loaded).

 

Try

if(i == 0)AlertMsg = "BUY Signal";

Lux

 

Tuen Code Around

Hi

I test an EA that works pretty well if you turn buy to sell and

sell to buy. I do it manually but would like to know what lines

of coded needed to be changed so it works as orginal but do

the opposite orders.

What lines do I look for?

Daniel

 

Request for Help

Hi,

Can somebody explain to me what the following block of MQL4 code means and what it does in an expert?

datetime timeprev=0;

//---------------------

if(timeprev==Time[0])

return(0);

timeprev=Time[0];

Thanks.

 

It means you can use your code only once for one bar, usually first tick. Any other tick code doesn't work. Sometimes it is very usefully.

 
Roger09:
It means you can use your code only once for one bar, usually first tick. Any other tick code doesn't work. Sometimes it is very usefully.

Thanks Roger09 for your answer.

Does this code block reduce the quality of EA test results in MetaTrader strategy tester? I noticed that when I test without this code the test takes longer and the profit is much lower.

And in live trading (if I am using H4 time frame and basing my strategy signals on closed candles (bar 1 & 2) ) will it effect the results?

 
Drake:
Hi guys,

at first sorry for my bad english,

so I'm buildind an EA, but I've got a problem.....

I need to know the value of the max and min of a certain candle ( for example the candle from 8,00 to 9,00 ( gmt + 1 )).

Can you help me please ?

Thanks a lot.

Hi friends,

don't leave me alone.

Help me please.

 
unaizams:
Thanks Roger09 for your answer.

Does this code block reduce the quality of EA test results in MetaTrader strategy tester? I noticed that when I test without this code the test takes longer and the profit is much lower.

And in live trading (if I am using H4 time frame and basing my strategy signals on closed candles (bar 1 & 2) ) will it effect the results?

I don't know your logic, so I can't answer your question. Sometimes it's better, sometimes not.

Reason: