WRB Hidden Gap

Jajaofopobo

Trader
Sep 6, 2021
53
4
24
Thanks @Enivid. Can you help splitting the alerts into buy and sell based on Price breaching it from above or below. Tried splitting it but it is repeating alerts instead of just once
 

Enivid

Administrator
Staff member
Nov 30, 2008
17,846
1,224
144
Odesa
www.earnforex.com
Thanks @Enivid. Can you help splitting the alerts into buy and sell based on Price breaching it from above or below. Tried splitting it but it is repeating alerts instead of just once
Not sure what you mean. Do you want it to filter alerts, so that you don't receive, let's say, long alerts?
 

Jajaofopobo

Trader
Sep 6, 2021
53
4
24
Not sure what you mean. Do you want it to filter alerts, so that you don't receive, let's say, long alerts?
Yes, If price breaches the rectangle from below, it should alert a sell alert and if price breaches it from above, it should be a buy alert message. Unlike the alert that signals "WRB rectangle breached" for both below and above breaches.

might be interested in only longs on a chart.
 

Jajaofopobo

Trader
Sep 6, 2021
53
4
24
MQL4:
 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 result of a bug) and delete it.
               string ObjectNameWithoutA = StringSubstr(ObjectText, 0, StringLen(ObjectText) - 1);
               if (ObjectFind(ObjectNameWithoutA) >= 0) ObjectDelete(ObjectNameWithoutA);
               continue;
           }
 
           double Price1 = ObjectGet(ObjectText, OBJPROP_PRICE1);
           double Price2 = ObjectGet(ObjectText, OBJPROP_PRICE2);
           double bHigh = MathMax(Price1, Price2);
           double bLow = MathMin(Price1, Price2);
           string Ma1 = Bid > maValue;
           string Ma2 = Bid < maValue;
 
           // Current price above lower border.
                       if (Bid < bHigh && Ask > bLow)
            {
                // Calculate the mid-price of the Hidden Gap object
                double midPrice = (bHigh + bLow) / 2.0;
 
                if (Bid > midPrice)
                {
                    // Buy Alert condition
                    string Text = "Buy Alert Hidden Gap breached for " + Symbol();
                    if (EnableNativeAlerts) Alert(Text);
                    if (EnableEmailAlerts) SendMail("Buy Alert", Text);
                    if (EnablePushAlerts) SendNotification(Text);
                    ObjectSetString(0, ObjectText, OBJPROP_NAME, ObjectText + "A");
                }
                else
                {
                    // Sell Alert condition
 
                    string Text = "Sell Alert : Hidden Gap breached for " + Symbol();
                    if (EnableNativeAlerts) Alert(Text);
                    if (EnableEmailAlerts) SendMail("Sell Alert", Text);
                    if (EnablePushAlerts) SendNotification(Text);
                    ObjectSetString(0, ObjectText, OBJPROP_NAME, ObjectText + "A");
                }
            }
        }
    }
Functions properly but becomes unresponsive at times with recurring alerts.
 

Jajaofopobo

Trader
Sep 6, 2021
53
4
24
MQL4:
 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 result of a bug) and delete it.
               string ObjectNameWithoutA = StringSubstr(ObjectText, 0, StringLen(ObjectText) - 1);
               if (ObjectFind(ObjectNameWithoutA) >= 0) ObjectDelete(ObjectNameWithoutA);
               continue;
           }
 
           double Price1 = ObjectGet(ObjectText, OBJPROP_PRICE1);
           double Price2 = ObjectGet(ObjectText, OBJPROP_PRICE2);
           double bHigh = MathMax(Price1, Price2);
           double bLow = MathMin(Price1, Price2);
           string Ma1 = Bid > maValue;
           string Ma2 = Bid < maValue;
 
           // Current price above lower border.
                       if (Bid < bHigh && Ask > bLow)
            {
                // Calculate the mid-price of the Hidden Gap object
                double midPrice = (bHigh + bLow) / 2.0;
 
                if (Bid > midPrice)
                {
                    // Buy Alert condition
                    string Text = "Buy Alert Hidden Gap breached for " + Symbol();
                    if (EnableNativeAlerts) Alert(Text);
                    if (EnableEmailAlerts) SendMail("Buy Alert", Text);
                    if (EnablePushAlerts) SendNotification(Text);
                    ObjectSetString(0, ObjectText, OBJPROP_NAME, ObjectText + "A");
                }
                else
                {
                    // Sell Alert condition
 
                    string Text = "Sell Alert : Hidden Gap breached for " + Symbol();
                    if (EnableNativeAlerts) Alert(Text);
                    if (EnableEmailAlerts) SendMail("Sell Alert", Text);
                    if (EnablePushAlerts) SendNotification(Text);
                    ObjectSetString(0, ObjectText, OBJPROP_NAME, ObjectText + "A");
                }
            }
        }
    }
Functions properly but becomes unresponsive at times with recurring alerts.
@Enivid, i tried splitting the alert couldn't get it to work well. also tried using P1 and P2 to differentiate the bullish gaps from the bearish gaps, had like the same issue of recurring alert. Kindly help consider splitting the alert in the next update. Thanks
 

Jajaofopobo

Trader
Sep 6, 2021
53
4
24
MQL4:
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;
        }
    }
}
I used the colour to split the alert and it works well. Thanks for the indie. It has helped me alot
 
  • 👍
Reactions: Enivid