Adding alerts, error with repeats grrr

 

I would be very grateful if someone could point out where i'm going wrong

with my adding alert attempt.  It works, but i'm getting repeating alerts 

for the same action, i just want the one alert. grrrr 

thank you kate


{{

string Text;

// Up Arrow Alert

if ((chL_BuferUp[TriggerCandle] > 0) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != 1))))

{

Text = AlertText + " @ lows  :  " + Symbol() + " - " + EnumToString((ENUM_TIMEFRAMES)Period()) + " - LONG";

if (EnableNativeAlerts) Alert(Text);

if (EnableSoundAlerts) PlaySound(SoundFileName);

LastAlertDirection = 1;

}

// Down Arrow Alert

if ((chH_BuferDn[TriggerCandle] < 0) && ((TriggerCandle < 0) || ((TriggerCandle == 0) && (LastAlertDirection != 1))))

{

Text = AlertText + " @ highs :  " + Symbol() + " - " + EnumToString((ENUM_TIMEFRAMES)Period()) + " - SHORT";

if (EnableNativeAlerts) Alert(Text);

if (EnableSoundAlerts) PlaySound(SoundFileName);

   LastAlertDirection = -1;

}

}

Files:
 
kate682:

I would be very grateful if someone could point out where i'm going wrong

with my adding alert attempt.  It works, but i'm getting repeating alerts 

for the same action, i just want the one alert. grrrr 

thank you kate

No one can help you because no one sees your entire code. But I guess your conditions are met repeatedly within a candle. Focus on these two lines.

if ((chL_BuferUp[TriggerCandle] > 0) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != 1))))
if ((chH_BuferDn[TriggerCandle] < 0) && ((TriggerCandle < 0) || ((TriggerCandle == 0) && (LastAlertDirection != 1))))
 
datetime TimeOfLastAlert, TimeOfNewAlert;
if(TimeOfNewAlert!=TimeOfLastAlert)
  {
   Alert();
   TimeOfLastAlert=TimeOfNewAlert;
  }

Give these things some values.

Time of candle open or close it should be.