void CheckAlert()
{
    int Length = StringLen(UnfilledPrefix);
    int total = ObjectsTotal(ChartID(), 0, OBJ_RECTANGLE);
 
    // Loop over all unfilled boxes.
    for (int j = 0; j < total; j++)
    {
 
 
        string ObjectText = ObjectName(0, j, 0, OBJ_RECTANGLE);
 
        if (StringSubstr(ObjectText, 0, Length) != UnfilledPrefix) continue;
 
        // Object marked as alerted.
        if (StringSubstr(ObjectText, StringLen(ObjectText) - 1, 1) == "A")
        {
            // Try to find a dupe object (could be the result of a bug) and delete it.
            string ObjectNameWithoutA = StringSubstr(ObjectText, 0, StringLen(ObjectText) - 1);
            if (ObjectFind(0, ObjectNameWithoutA) >= 0) ObjectDelete(0, ObjectNameWithoutA);
            continue;
        }
 
        double Price1 = ObjectGetDouble(0, ObjectText, OBJPROP_PRICE1);
        double Price2 = ObjectGetDouble(0, ObjectText, OBJPROP_PRICE2);
        double bHigh = MathMax(Price1, Price2);
        double bLow = MathMin(Price1, Price2);
 
 
 
        color ObjectColor = ObjectGetInteger(0, ObjectText, OBJPROP_COLOR);
 
        // Current price above lower border for buy alert.
        if ((Ask > bLow) && (Bid < bHigh) && (ObjectColor == HGcolorIntersectionBullishUnbreached || ObjectColor == HGcolorNormalBullishBreached) )
        {
            string Text = "Buy Alert: " + Symbol() + " - " + StringSubstr(EnumToString((ENUM_TIMEFRAMES)Period()), 7) + " - WRB rectangle breached (Buy).";
            if (EnableNativeAlerts   ) Alert(Text);
            if (EnableEmailAlerts) SendMail("Buy Alert", Text);
            if (EnablePushAlerts) SendNotification(Text);
            ObjectSetString(0, ObjectText, OBJPROP_NAME, ObjectText + "A");
            return;
        }
 
        // Current price below upper border for sell alert.
        if ((Ask < bHigh) && (Bid > bLow) && (ObjectColor == HGcolorIntersectionBearishUnbreached || ObjectColor == HGcolorNormalBearishBreached))
        {
            string Text = "Sell Alert: " + Symbol() + " - " + StringSubstr(EnumToString((ENUM_TIMEFRAMES)Period()), 7) + " - WRB rectangle breached (Sell).";
            if (EnableNativeAlerts ) Alert(Text);
            if (EnableEmailAlerts) SendMail("Sell Alert", Text);
            if (EnablePushAlerts ) SendNotification(Text);
            ObjectSetString(0, ObjectText, OBJPROP_NAME, ObjectText + "A");
            return;
        }
    }
}