Alert sent only when signal is confirmed

To add comments, please log in or register
bobby
129
bobby  

Hello,

I have a problem with my alerts that are sent when there is a signal, but the bar where is the signal is not yet finished during the sending. I would like that the signal be sent only after that the barne closed where the signal is made. Otherwise, the signal can disappear and reappear several times on the same bar, thus there is several alerts for a same signal.

Here is the code :

if (Alerts == true)

{

UpArrow = EMPTY_VALUE; DnArrow = EMPTY_VALUE;

if ((DIR == 1) && (DIR == -1)) UpArrow = Sum - (Ask - Bid);

if ((DIR == -1) && (DIR == 1)) DnArrow = Sum + (Ask - Bid);

}

if (Alerts == true)

{

string AlertTXT;

if (UpArrow[0+p]!=EMPTY_VALUE && TurnedUp==false)

{

AlertTXT=" BUY: "+Symbol()+" - "+Period()+" at "+ DoubleToStr(Close[0],Digits)+ " - "+ TimeToStr(CurTime(),TIME_SECONDS);

Alert(AlertTXT); if (EmailON) SendMail(AlertTXT,AlertTXT);

if (SignalPrice == true)

{

ObjectCreate("BUY SIGNAL: " + DoubleToStr(Time[0],0),OBJ_ARROW,0,Time[0],Close[0]);

ObjectSet("BUY SIGNAL: " + DoubleToStr(Time[0],0),OBJPROP_ARROWCODE,5);

ObjectSet("BUY SIGNAL: " + DoubleToStr(Time[0],0),OBJPROP_COLOR,SignalPriceBUY);

}

TurnedDn = false; TurnedUp = true;

}

if (DnArrow[0+p]!=EMPTY_VALUE && TurnedDn==false)

{

AlertTXT=" SELL: "+Symbol()+" - "+Period()+" at "+ DoubleToStr(Close[0],Digits)+ " - "+ TimeToStr(CurTime(),TIME_SECONDS);

Alert(AlertTXT); if (EmailON) SendMail(AlertTXT,AlertTXT);

if (SignalPrice == true)

{

ObjectCreate("SELL SIGNAL: " + DoubleToStr(Time[0],0),OBJ_ARROW,0,Time[0],Close[0]);

ObjectSet("SELL SIGNAL: " + DoubleToStr(Time[0],0),OBJPROP_ARROWCODE,5);

ObjectSet("SELL SIGNAL: " + DoubleToStr(Time[0],0),OBJPROP_COLOR,SignalPriceSELL);

}

TurnedUp = false; TurnedDn = true;

}

}

What have I to do ?

Files:
alert.gif 5 kb
To add comments, please log in or register