Some of these can be set in the "Tools > Options > Events tab" menu.
For the rest, you will need to add a command like:
if(about_to_hit_TP_condition) PlaySound("alert.wav");
Cheers,
Raider
Hello Raider,
Could you please let me know how is possible to add this command to my EA.I want an alert on every TP.
Sorry but no SL and TP events in the "Tools > Options > Events tab". Only TS.
What is the exact command and where should i add it please.
void SetTakeProfit()
{
int i,Type; bool selected, success;for(i=0; i<OrdersTotal(); i++)
{
selected = OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(selected && (OrderType() == OP_BUY || OrderType() == OP_SELL) && OrderTakeProfit() < 1 * MarketInfo(OrderSymbol(),MODE_POINT))
{
Type = OrderType();
success = false;
if(Type == OP_BUY) success = OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), OrderOpenPrice() + TP_Decision(OrderSymbol()) * MarketInfo(OrderSymbol(),MODE_POINT), 0, CLR_NONE);
if(Type == OP_SELL) success = OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss(), OrderOpenPrice() - TP_Decision(OrderSymbol()) * MarketInfo(OrderSymbol(),MODE_POINT), 0, CLR_NONE);if(success && Alert_On) Alert("TakeProfit for "+OrderSymbol()+" has been placed automatically.") ;
if (!success) Print("Error code = " + GetLastError());
}
}Thank you for your kindness,
Patrick.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hello everybody
how can I set MT4 to alert playing different sounds at follwing events:
a position hit SL
a position hit TP
a position is about to hit TP(as TP box turns to green color)
a position is about to hit SL(as SL box turns to red color)
one more question: how can I exit part of a trade with TP, let's say we opened a position SHORT eur/usd at 1.2950 / 2 lot and we want to exit half at 1.2900 and the rest at 1.2850. I learned how to exit part of position manualy and I want to know how to exit at desired level automaticaly.
thanks for your help
Victor1967