MT4 Inside Bar Breakout Indicator: Confirmed-Candle Arrows with a Tick-Volume Quality Filter

Beginner Trading Tutorial · MQL4 custom indicator · Price action and participation

An inside bar is a pause: a candle whose entire high-to-low range fits inside the range of the preceding candle. It does not predict the next direction. The practical question is whether a later completed candle actually breaks the original range, and whether activity is unusually high when it does.

This tutorial builds a complete MetaTrader 4 indicator that places a green or red arrow only after a three-candle sequence has completed. The setup consists of a mother bar, a smaller inside bar, and a breakout bar. An optional relative tick-volume gate helps distinguish quiet pokes through a boundary from moves accompanied by greater-than-usual quote activity.

Read the pattern, not just the shape

The mother bar supplies two fixed reference prices: its high and low. The inside bar must have a strictly lower high and a strictly higher low. The breakout bar must then close above the mother high for a bullish arrow, or below the mother low for a bearish arrow. We also require the bullish candle to close above its open, or the bearish candle below its open. This extra candle-direction rule avoids a visually confusing signal on a bar with a counter-direction body.

MT4 Inside Bar Breakout Indicator: Confirmed-Candle Arrows with a Tick-Volume Quality Filter
Figure 1. Schematic three-bar sequence. Mother high 1.1050 and low 1.1000 are fixed before the breakout; the example close of 1.1059 is above the mother high. Prices are hypothetical, not historical observations.

A repeatable, numerical test

Suppose an illustrative EUR/USD mother candle spans 1.1000–1.1050. The next candle has high 1.1040 and low 1.1010, so both extremes remain inside. A third candle opens at 1.1033 and closes at 1.1059. Because the close is above 1.1050 and above its own open, the price conditions pass.

Now add tick volume. If the breakout candle records 1,180 ticks and the average across the preceding 20 candles is 1,000 ticks, relative tick volume is 1,180 ÷ 1,000 = 1.18. The default 1.15 threshold passes. Change the breakout candle to 980 ticks and the ratio becomes 0.98; with the volume filter enabled, no arrow is printed even though the price pattern remains intact.

In spot forex, MT4 usually provides tick volume—a measure of the number of quote updates—not centralized exchange-traded contract volume. Interpret the ratio as relative activity on your broker's feed, not universal market buy pressure.

Three-stage inside-bar breakout decision logic and illustrative 1180 versus 1000 tick-volume comparison
Figure 2. Independent checks: a valid inside bar, completed close beyond the mother range, and relative tick volume at or above 1.15. All must pass when the filter is enabled.

The design choices that make the signal reproducible

Setting Default Meaning
VolumeLookback 20 Average tick volume of the 20 bars preceding the breakout, excluding the breakout itself.
MinRelativeTickVolume 1.15 Require signal-bar activity at least 15% above the lookback average.
MinMotherRangePoints 100 Ignore tiny mother-bar ranges; MT4 points depend on symbol quotation precision.
UseVolumeFilter true Set false to study price-pattern signals without the volume gate.

On a typical five-digit EUR/USD quote, 100 points represent approximately 10 pips; do not assume that translation holds for every symbol. The mother-bar filter uses price points, not ATR. The volume denominator deliberately includes the inside and mother bars when they fall within the preceding 20 candles; it excludes the breakout candle, preventing self-inflation of its comparison.

Complete ready-to-copy MQL4 indicator

Create PS_InsideBarBreakout.mq4 and paste the entire listing. The code uses the MT4 OnCalculate() event, two drawing buffers, and the documented DRAW_ARROW style. Price arrays are explicitly set to timeseries indexing to make the shift logic unambiguous.

// MT4 Inside Bar Breakout + relative tick volume
// Save as PS_InsideBarBreakout.mq4 in MQL4/Indicators
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 LimeGreen
#property indicator_color2 Tomato
#property indicator_width1 2
#property indicator_width2 2

input int VolumeLookback = 20;
input double MinRelativeTickVolume = 1.15;
input int MinMotherRangePoints = 100;
input bool UseVolumeFilter = true;

double BullArrow[];
double BearArrow[];

int OnInit()
{
   if(VolumeLookback < 3 || MinRelativeTickVolume <= 0.0
      || MinMotherRangePoints < 0)
      return(INIT_PARAMETERS_INCORRECT);

   if(!SetIndexBuffer(0, BullArrow) ||
      !SetIndexBuffer(1, BearArrow))
      return(INIT_FAILED);

   ArraySetAsSeries(BullArrow, true);
   ArraySetAsSeries(BearArrow, true);
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(0, 233);
   SetIndexArrow(1, 234);
   SetIndexEmptyValue(0, EMPTY_VALUE);
   SetIndexEmptyValue(1, EMPTY_VALUE);
   SetIndexLabel(0, "Bullish inside-bar breakout");
   SetIndexLabel(1, "Bearish inside-bar breakout");
   IndicatorShortName("PS Inside Bar Breakout (confirmed)");
   return(INIT_SUCCEEDED);
}

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   if(rates_total < VolumeLookback + 4)
      return(0);

   ArraySetAsSeries(open, true);
   ArraySetAsSeries(high, true);
   ArraySetAsSeries(low, true);
   ArraySetAsSeries(close, true);
   ArraySetAsSeries(tick_volume, true);

   if(prev_calculated == 0)
   {
      ArrayInitialize(BullArrow, EMPTY_VALUE);
      ArrayInitialize(BearArrow, EMPTY_VALUE);
   }

   // Shift 0 is still forming. Never draw on it.
   BullArrow[0] = EMPTY_VALUE;
   BearArrow[0] = EMPTY_VALUE;

   int oldest = rates_total - 1 - MathMax(VolumeLookback, 2);
   int start = (prev_calculated == 0)
               ? oldest
               : MathMin(oldest, rates_total - prev_calculated + 2);

   for(int i = start; i >= 1; i--)
   {
      BullArrow[i] = EMPTY_VALUE;
      BearArrow[i] = EMPTY_VALUE;

      // Three completed bars: mother i+2, inside i+1, breakout i.
      bool inside = high[i+1] < high[i+2] &&
                    low[i+1] > low[i+2];
      if(!inside)
         continue;

      double motherPoints = (high[i+2] - low[i+2]) / _Point;
      if(motherPoints < MinMotherRangePoints)
         continue;

      double avgTick = 0.0;
      for(int j = 1; j <= VolumeLookback; j++)
         avgTick += (double)tick_volume[i+j];
      avgTick /= VolumeLookback;

      if(UseVolumeFilter)
      {
         if(avgTick <= 0.0)
            continue;
         if((double)tick_volume[i] / avgTick <
            MinRelativeTickVolume)
            continue;
      }

      bool bullish = close[i] > high[i+2] &&
                     close[i] > open[i];
      bool bearish = close[i] < low[i+2] &&
                     close[i] < open[i];
      double offset = MathMax(5.0 * _Point,
                              0.20 * (high[i] - low[i]));
      if(bullish)
         BullArrow[i] = low[i] - offset;
      else if(bearish)
         BearArrow[i] = high[i] + offset;
   }
   return(rates_total);
}

What the code is doing

Shifts [1], [2], and [3]. A live chart’s shift 0 candle is incomplete. For the latest signal, shift 1 is the just-completed breakout bar; shift 2 is the inside bar and shift 3 is the mother bar. The loop begins at shift 1, never at 0. This avoids provisional intrabar arrows, although corrected broker history can still change earlier calculations.

Buffers versus orders. BullArrow[] and BearArrow[] hold plotted arrow prices, not trade orders. EMPTY_VALUE clears disqualified bars, while the offset moves arrows away from candle extremes. The indicator does not manage entries, stop-losses, position sizing, or exits.

Historical versus incremental calculation. On first load, the indicator evaluates historical bars with enough older volume data. On subsequent ticks, it recalculates only the newest relevant closed bars plus a short overlap. If deeper history arrives and the platform resets prev_calculated, the indicator can rebuild its buffers.

Install and validate in MT4

  1. Open MT4 → File → Open Data Folder → MQL4 → Indicators.
  2. Save the supplied code as PS_InsideBarBreakout.mq4, open it in MetaEditor, and compile. Confirm the broker/build-specific result yourself; no external compile run is claimed here.
  3. Refresh Navigator, attach the indicator to a chart, and start with the default parameters on a liquid currency pair and H1 timeframe.
  4. Locate a complete mother/inside/breakout sequence; read its exact OHLC prices from the Data Window and recalculate the tick-volume ratio.
  5. Compare UseVolumeFilter=true against false; record how many signals vanish and why. Then observe the current forming bar to verify that no shift-0 arrow is drawn.

When it is useful—and when it misleads

Inside-bar breakouts can serve as a structured chart-review aid around consolidation, intraday ranges, or planned watchlists. They are less convincing when the mother range was caused by an exceptional news spike, when spreads widen at rollover, or when illiquid trading hours distort tick counts. More filters can reduce noise but also miss genuine breakouts, and a single threshold can behave very differently across symbols and timeframes.

The opposite extreme matters too: a close just one point beyond a boundary satisfies the strict rule but may have little economic meaning after spread and execution costs. This introductory implementation intentionally does not enforce a minimum breakout distance, higher-timeframe trend, or a retest requirement. Those are sensible extensions to research individually rather than silently bundling them into an opaque signal.

For a practical validation exercise, collect at least 30 historical qualifying setups across several market regimes. Note the mother range, close distance beyond the boundary, relative tick volume, the following bars' maximum favorable/adverse excursion, spread, and event-news context. Do not present a few selected screenshots as proof of profitability. Even confirmed arrows can precede fast reversals.

Interested in adapting this free indicator—for example, adding alerts, breakout-distance limits, or broker-specific filters? You can explore Custom Trading Software Development Services to discuss a tailored modification.

Educational software example only, not a guarantee of results or personalized investment advice. Test compile compatibility and data quality in your own MT4 terminal; evaluate transaction costs and risk before live trading.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.