Adding alerts, error with repeats grrr

To add comments, please log in or register
Gemma kate
244
Gemma kate  

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;

}

}

Petr Nosek
2847
Petr Nosek  
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))))
kypa
1081
kypa  
datetime TimeOfLastAlert, TimeOfNewAlert;
if(TimeOfNewAlert!=TimeOfLastAlert)
  {
   Alert();
   TimeOfLastAlert=TimeOfNewAlert;
  }

Give these things some values.

Time of candle open or close it should be.

To add comments, please log in or register