Skip to content
All library documents

Building a Candle-Color Indicator to Detect Inside Bars

Article MQL5 articles

Summary

This article demonstrates how to create a MetaTrader indicator that colors candles and marks inside bars. It defines an inside bar as one whose high and low remain within the preceding bar’s range, while noting that some traders use broader definitions. A central implementation lesson is that candle data buffers must be assigned in the platform’s expected order; otherwise, the indicator can alter candle shapes as well as colors. The indicator compares each bar with its predecessor and applies a distinct color when the range is contained.

The article explains why the current candle’s status can change before it closes: its high or low may still leave the prior range. Rechecking the condition lets the display remove the inside-bar marking if the setup ceases to qualify. It also discusses chart customization and restoring chart properties. This is an implementation guide for visual pattern identification, not evidence that inside-bar signals are profitable; traders may also differ on which bars qualify.

Key ideas

  • An inside bar is identified when its high and low fall within the preceding bar’s range.
  • The candle buffers must follow the platform’s required order to preserve the original candle appearance.
  • A bar can stop qualifying before it closes, so the indicator needs to reassess the condition as prices update.
  • The indicator highlights a chart formation but does not establish that trading it produces returns.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.