WRB Hidden Gap

Jajaofopobo

Trader
Sep 6, 2021
70
7
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
19,270
1,515
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
70
7
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
70
7
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
70
7
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
70
7
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

Jajaofopobo

Trader
Sep 6, 2021
70
7
24
For the upcoming update, it would be appreciated if the gap breach criteria could be adjusted to require a certain percentage of the gap to be filled before considering it breached.

Thanks
 

Karl2007

Trader
Oct 17, 2023
3
0
7
44
Hi, I am trading with suply/demand zones, liquidity and imbalances.
This indicator helps to identify quickly imbalances but there are many of them not detected and not marked , I attach and example in M1. I have included in orange colour the missing ones (there is a bunch).
As I consider that the indicator is quite useful, I would like to ask creator to take a look and correct it to identify all imbalances.
Thanks in advance.

example.jpg
 

Karl2007

Trader
Oct 17, 2023
3
0
7
44
Understood, thanks.
In any case, could it be added an option to detect all of them and not only WRB? I think that it is interesting to know how many of them are created to consider if price will come to mitigate them in the future.
 

1xICT

Newbie
Nov 18, 2023
3
0
1
29
Thank you very much for your sharing. I want to see the boxes on the chart when I go above the timeframe I selected from the inputs, but it gives an error in mt5 (it works in mt4). How can I fix this? ( error alert: the timeframe input parameter should be higher or equal the current timeframe)
 

Enivid

Administrator
Staff member
Nov 30, 2008
19,270
1,515
144
Odesa
www.earnforex.com
Thank you very much for your sharing. I want to see the boxes on the chart when I go above the timeframe I selected from the inputs, but it gives an error in mt5 (it works in mt4). How can I fix this? ( error alert: the timeframe input parameter should be higher or equal the current timeframe)
You can just comment out or remove these lines in MetaEditor:
MQL5:
       Alert("The Timeframe input parameter should be higher or equal to the current timeframe.");
        return INIT_FAILED;
And the re-compile the code.
 

1xICT

Newbie
Nov 18, 2023
3
0
1
29
You can just comment out or remove these lines in MetaEditor:
MQL5:
       Alert("The Timeframe input parameter should be higher or equal to the current timeframe.");
        return INIT_FAILED;
And the re-compile the code.
thank you I did it.I have one more request: the shadows of the boxes are entering the candles in MT5, how can I fix this? (MT4 does not have this problem)
 

Attachments

  • mt5.jpg
    mt5.jpg
    25.6 KB · Views: 4
  • mt4.jpg
    mt4.jpg
    13.8 KB · Views: 4