Help with the below please

 

Hi,

Could anyone help me with the below indicator,

It creates an alert only once and I need it to keep repeating the alert (when it rings once and I'm moving about my house I miss the alert, if it could ring like 20 times or in any other way possible?).

After the alert I usually either immediately re-enter or wait a certain period of time before re-entering.

So I guess ideally If I could set the number of times it alerts to an X amount (eg: 20 times, or more)?

//+------------------------------------------------------------------+
//|                                              AlertCloseOrder.mq4 |
//|                               Copyright © 2010, Vladimir Hlystov |
//|                                         http://cmillion.narod.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Vladimir Hlystov"
#property link      "http://cmillion.narod.ru"
#property indicator_chart_window
int Orders;
//+------------------------------------------------------------------+
int start()
  {
   if (Orders>OrdersTotal()) AlertOrder();
   Orders=OrdersTotal();
   return(0);
  }
//+------------------------------------------------------------------+
void AlertOrder()
{
   string txt;
   double OCP;
   int i=OrdersHistoryTotal()-1;
   if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true)
   {                                     
      OCP=OrderClosePrice();
      if (OCP==OrderStopLoss()  ) txt="SL";
      if (OCP==OrderTakeProfit()) txt="TP";
      Alert("Ордер N ",OrderTicket()," закрыт по ",txt," ",
      DoubleToStr(OCP,Digits)," прибыль ",DoubleToStr(OrderProfit(),2));
}  }
//+------------------------------------------------------------------+
 

The program runs once and only once every time a tick is received. So 2 ways you could do it are:

1. use PlaySound, and use a sound affect that last a long time.

2. use a while loop to keep sending alerts.

The problem with a loop is you need user input to cancel it. Maybe you can use a MessageBox to do this...? I've never tried but should work.

Alternatively, use a for loop to send something like 50 Alerts (with a Sleep between each), and hope that will be enough.

 
alladir:

The program runs once and only once every time a tick is received. So 2 ways you could do it are:

1. use PlaySound, and use a sound affect that last a long time.

2. use a while loop to keep sending alerts.

The problem with a loop is you need user input to cancel it. Maybe you can use a MessageBox to do this...? I've never tried but should work.

Alternatively, use a for loop to send something like 50 Alerts (with a Sleep between each), and hope that will be enough.


If you used a MessageBox to cancel, I think that the message box would appear and the program will stop and wait for a response, so no more alerts while it is waiting.

Possibly the easiest way would be for the code to place a label on the chart at the same time as it sends the first alert. Follow that with a loop that checks that the label exists before sending another alert. Clicking on the label and deleting it would then stop the alert repeating.

 

Thank you guys!

GumRai this seems to be appropriate: "place a label on the chart at the same time as it sends the first alert. Follow that with a loop that checks that the label exists before sending another alert. Clicking on the label and deleting it would then stop the alert repeating."

But I can't code unfortunately (believe me I've tried learning), anyone willing to code that into the above code for me please?

Nick

Reason: