HELP WANTED: Alert functionality not working as expected

 

Hi,

I'm trying add an alert functionality to the attached indicator, please see below for what I have so far:

I'm expecting to have one alert when it crosses   (and the candle is closed)above the 26.5 level.

I'm expecting to have another alert when it crosses (and the candle is closed) below the 27.0 level.

Sadly, I'm getting alerts almost every millisecond.  

Is there anyone out there who may be able to help?

Files:
 
Please edit your post and

use the code button (Alt+S) when pasting code, do not post an image.

I know that it is not obvious, but topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I will move your topic to the MQL4 and Metatrader 4 section.

 
TheBrinded: I'm expecting to have one alert when it crosses  
input int    TriggerCandle    = 1;
⋮
if (((TriggerCandle > 0) && (Time[0] > LastAlertTime))…
{

Really? I expect continuous alerts, one per candle.

Reason: