Boom Limit Pro v1.0 (Non-Repaint) MetaTrader 4 Expert Advisor

The Boom Limit Pro v1.0 (Non-Repaint) is an Expert Advisor designed to analyze daily market movements based on the previous two days’ price action. It focuses on key price levels, such as highs, lows, and midpoints, to determine potential entry points for placing buy and sell stop orders. This EA is structured to provide a consistent approach to trading by following a clear set of rules derived from historical data, ensuring that it operates without repainting or recalculating signals.

#property strict

extern int    MagicNumber            = 123456;    // Magic number of the EA
extern double Lots                   = 1;         // Static lot size

datetime buyTag1 ,sellTag1, timeTag, dayTag;
double   p, lots;
double   high1, low1, open1, close1, high2, low2, open2, close2, middleY,
         sizePos, atr;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   // Set the correct value for 'p' based on the current Point size
   p = Point;
   if (Point == 0.00001) p = 0.0001;
   if (Point == 0.001)   p = 0.01;

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
{
   // Ensure there are enough bars to proceed
   if(Bars < 10) return;

   // Update daily high, low, open, and close values if a new bar is detected
   if(timeTag < Time[0])
   {
      if(dayTag != iTime(Symbol(), PERIOD_D1, 0)) deletePendings();

      // Fetch the previous day's data
      high1  = iHigh(Symbol(), PERIOD_D1, 1);
      low1   = iLow(Symbol(), PERIOD_D1, 1);
      open1  = iOpen(Symbol(), PERIOD_D1, 1);
      close1 = iClose(Symbol(), PERIOD_D1, 1);
      high2  = iHigh(Symbol(), PERIOD_D1, 2);
      low2   = iLow(Symbol(), PERIOD_D1, 2);
      open2  = iOpen(Symbol(), PERIOD_D1, 2);
      close2 = iClose(Symbol(), PERIOD_D1, 2);

      // Calculate the middle of yesterday's range, the size of the range, and the ATR
      middleY = NormalizeDouble(iHigh(Symbol(), PERIOD_D1, 1) - ((iHigh(Symbol(), PERIOD_D1, 1) - iLow(Symbol(), PERIOD_D1, 1)) * 0.5), Digits);
      sizePos = iHigh(Symbol(), PERIOD_D1, 1) - iLow(Symbol(), PERIOD_D1, 1);
      atr     = iATR(Symbol(), PERIOD_D1, 7, 1);

      // Update time tags for the current bar and day
      timeTag = Time[0];
      dayTag  = iTime(Symbol(), PERIOD_D1, 0);
   }

   // Place buy stop order if conditions are met
   if(high1 > high2 && low1 > low2 && !orderOpen(MagicNumber) && !orderClosedOnBar(MagicNumber))
   {
      if(Ask < middleY)
      {
         int ticket = OrderSend(Symbol(), OP_BUYSTOP, Lots, high1, 0, middleY, NormalizeDouble(high1 + sizePos, Digits), "2DLimits EA", MagicNumber, 0, Blue);
      }
   }

   // Place sell stop order if conditions are met
   if(high1 < high2 && low1 < low2 && !orderOpen(MagicNumber) && !orderClosedOnBar(MagicNumber))
   {
      if(Bid > middleY)
      {
         int ticket = OrderSend(Symbol(), OP_SELLSTOP, Lots, low1, 0, middleY, NormalizeDouble(low1 - sizePos, Digits), "2DLimits EA", MagicNumber, 0, Red);
      }
   }
}
//+------------------------------------------------------------------+
//| Check if an order is currently open with a given Magic Number    |
//+------------------------------------------------------------------+
bool orderOpen(int Magic)
{
   for(int i = OrdersTotal() - 1; i >= 0; i--)
   {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false) continue;
      if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
      {
         return(true);
      }
   }
   return(false);
}
//+------------------------------------------------------------------+
//| Check if an order was closed on the current bar                  |
//+------------------------------------------------------------------+
bool orderClosedOnBar(int Magic)
{
   for(int i = OrdersHistoryTotal() - 1; i >= 0; i--)
   {
      if(!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
      if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderOpenTime() >= Time[0])
      {
         return(true);
      }
   }
   return(false);
}
//+------------------------------------------------------------------+
//| Delete all pending orders for the current symbol and Magic Number|
//+------------------------------------------------------------------+
void deletePendings()
{
   for(int i = OrdersTotal() - 1; i >= 0; i--)
   {
      if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
      if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
      {
         // Delete pending orders (Buy Stop, Buy Limit, Sell Stop, Sell Limit)
         if(OrderType() == OP_BUYSTOP || OrderType() == OP_BUYLIMIT || OrderType() == OP_SELLSTOP || OrderType() == OP_SELLLIMIT)
         {
            if(OrderDelete(OrderTicket(), clrNONE)) continue;
         }
      }
   }
   return;
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
   // Cleanup code can be added here if needed
}

How the EA Works

The Two-Day Limit EA is designed to analyze the daily price action of a financial instrument, focusing on the last two trading days. It checks specific conditions related to the highs and lows of these days and uses this information to decide whether to place buy or sell stop orders.

See also  FX Grid Trading System v1.1 (Non-Repaint) MT 4 Indicator

Key Components of the EA

The EA operates by calculating several key values and checking specific conditions before placing any orders. Here’s a breakdown of the core components:

Daily Highs and Lows:
The EA tracks the highs and lows of the previous two days. These values are crucial as they form the basis for the decision-making process. The comparison between these highs and lows determines whether a trade setup is valid.

Middle of Yesterday’s Range:
The EA calculates the midpoint of the previous day’s range (the difference between the high and the low). This middle value is used as a reference point to decide whether the market is in a position to continue in a certain direction.

ATR (Average True Range):
The EA uses the Average True Range (ATR) of the previous seven days to measure market volatility. This value helps to set stop loss levels and ensures that the orders are placed within a realistic price range, considering the recent market conditions.

Trade Logic

The EA’s trade logic is straightforward but effective. It looks for specific patterns in the market’s price action, specifically when the price on day two exceeds or falls below the price on day one. Here’s how it makes trade decisions:

Buy Stop Orders

  • The EA will place a buy stop order if the following conditions are met:
    • The high of day one is higher than the high of day two.
    • The low of day one is higher than the low of day two.
    • There is no existing order open or closed on the current bar with the EA’s specific identifier (Magic Number).
    • The current price (Ask) is below the middle of yesterday’s range.
See also  Astron Prime Signal v3 (Non - Repaint) MetaTrader 5 Expert Advisor

Sell Stop Orders

  • Similarly, the EA will place a sell stop order if these conditions are met:
    • The high of day one is lower than the high of day two.
    • The low of day one is lower than the low of day two.
    • There is no existing order open or closed on the current bar with the EA’s specific identifier.
    • The current price (Bid) is above the middle of yesterday’s range.

Managing Pending Orders

One of the EA’s crucial features is its ability to manage pending orders effectively. Before placing new orders, the EA checks if there are any pending orders that meet certain conditions and removes them if necessary. This ensures that the trading environment remains clean and that only relevant orders are active.

Conclusion

The Two-Day Limit EA is a well-structured tool that leverages simple but effective trading logic based on historical price action. By focusing on the price behavior over the last two days, it aims to capitalize on potential market movements while keeping risk in check through the use of ATR and calculated levels.

Leave a Comment