Loading…

Inside Bar Chain Outcome Study

A single inside bar and a multi-bar inside bar chain are often traded as if they mean the same thing - a coiled market waiting to break - without checking whether a longer chain actually produces a bigger or more directional move. This script measures it directly: it walks the loaded history chaining consecutive inside bars (each one contained within the bar immediately before it), then measures the breakout that follows each chain, separately for chains of exactly one inside bar and chains of two or more. Because each inside bar in an unbroken chain is contained by its immediate predecessor, and that predecessor is in turn contained by its own predecessor back to the start of the chain, every bar in the chain is transitively inside the original mother bar too - so the mother bar's own high and low already bound the whole chain. The breakout is measured against that mother range directly rather than re-derived from the last (redundant) inside bar, which keeps a two-bar and a five-bar chain scored on the same footing. Follow-through is measured as the furthest the market pushed beyond the broken edge over a fixed window starting at the breakout confirmation bar, which is the plainest way to compare "how far did it actually go" between the two chain-length buckets. Notes and limitations - This is a descriptive study, not a trading signal. A direction or follow-through difference between the single and multi buckets on a small sample is not evidence of an edge; check the reach (sample count) for each bucket before drawing conclusions. - A chain with no qualifying breakout close within InpBreakoutSearchBars is counted as "unresolved" and excluded from the direction and follow-through averages rather than forced into a guess. - "Inside bar" here is defined strictly against the immediately preceding bar's high and low, with no tolerance for an equal high or low counting either way - a bar that exactly matches its predecessor's high or low is inside by this definition. - Chain length has no upper cap in this study; a very long chain is still counted once in the 2-plus bucket alongside a simple two-bar chain, so the multi bucket can mix genuinely different chain lengths together. Check the raw CSV if the chain-length breakdown itself matters for the analysis being done.

Script · MT5 · v1.0 · Free

About Inside Bar Chain Outcome Study

Inside Bar Chain Outcome Study is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 8 settings, such as Symbol, Timeframe and Max bars. MQL source code included.

Files in the download: InsideBarChainStudy.ex5, InsideBarChainStudy.mq5, InsideBarChainStudy.txt.

Settings

SettingDefaultWhat it does
SymbolSymbol to study, blank = this chart's symbol
TimeframePERIOD_H1Timeframe to study
Max bars5000Most recent bars to include
Breakout buffer pips2.0Close must clear the mother bar's edge by this many pips
Breakout search bars10Bars after the chain checked for the breakout close
Measure bars10Bars after breakout confirmation used to measure follow-through
Save csvtrueWrite every chain event to a CSV file
DelimiterDelimiterCommaCSV column separator

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Breakout · Candlestick Patterns · Alerts · MT5 Script · MQL5 Source Code

MQL4 & MQL5 scripts · PolyMaria