{"id":3122,"date":"2026-11-22T10:00:49","date_gmt":"2026-11-22T16:00:49","guid":{"rendered":"https:\/\/patternsmart.com\/wp\/?p=3122"},"modified":"2026-11-22T16:01:41","modified_gmt":"2026-11-22T16:01:41","slug":"mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4","status":"publish","type":"post","link":"https:\/\/patternsmart.com\/wp\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\/","title":{"rendered":"MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4"},"content":{"rendered":"<div class=\"postie-post\">\n<div>\n<article style=\"max-width:1050px;margin:auto\">\n<p style=\"color:#3166d8;font-weight:bold;font-size:13px;letter-spacing:1.5px;margin:0 0 9px\">PATTERNSMART  \/  MQL4 ENGINEERING NOTE<\/p>\n<h1 style=\"font-size:37px;line-height:1.17;color:#142b46;margin:8px 0 15px\">MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4<\/h1>\n<p style=\"color:#557188;font-size:16px;margin-bottom:24px\"><strong>Difficulty: Trading Tips<\/strong> \u00a0|\u00a0 MetaTrader 4 indicator \u00a0|\u00a0 Full commented source included<\/p>\n<p style=\"margin:0 0 17px;line-height:1.75\"><strong>Why did the arrow appear and then disappear?<\/strong> On an active MT4 candle, high, low, and close can still change with every tick. A useful signal can therefore be valid for a few seconds and invalid before the candle closes. This article develops a small MQL4 audit indicator that deliberately separates an optional live preview from locked, historical signals. The objective is not to predict the next bar; it is to make the information state of each marker auditable.<\/p>\n<p style=\"margin:0 0 17px;line-height:1.75\">The practical failure often starts with a single index. In MetaTrader\u2019s series convention, <code>shift 0<\/code> represents the current, unfinished candle; <code>shift 1<\/code> represents the most recently completed candle. Mixing them can make a chart appear better in hindsight than the signal a trader actually saw in real time. Even a well-designed setup becomes difficult to validate if its alert fires on shift 0 while its historical chart is examined at shift 1.<\/p>\n<h2 style=\"color:#173553;font-size:25px;line-height:1.3;margin:34px 0 15px;border-bottom:1px solid #e4ebea;padding-bottom:9px\">A simple contract: previews may move; confirmed arrows must not<\/h2>\n<p style=\"margin:0 0 17px;line-height:1.75\">This indicator creates four visual buffers: two permanent-direction arrow buffers for completed bullish and bearish candles, plus two small-dot buffers for live previews. A preview is not a forecast, execution signal, or historical annotation. It is a diagnostic showing what the unfinished bar <em>would<\/em> satisfy if it closed now. When a new bar starts, the former bar 0 is evaluated at shift 1 using the final OHLC values, and the confirmed arrow can be retained. No algorithm is permitted to use future candles.<\/p>\n<figure style=\"margin:25px 0 29px\"><img decoding=\"async\" data-src=\"https:\/\/patternsmart.com\/wp\/wp-content\/uploads\/2026\/11\/Professional-schematic-showing-MT4-unfinished-bar-zero-new-bar-index-shift-confirmed-bar-one-and-reproducible-candle-calculations.png\" alt=\"Professional schematic showing MT4 unfinished bar zero, new-bar index shift, confirmed bar one, and reproducible candle calculations\" style=\"--smush-placeholder-width: 1440px; --smush-placeholder-aspect-ratio: 1440\/810;display:block;width:100%;max-width:1050px;height:auto;margin:auto\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\"><figcaption style=\"font-size:13px;color:#60768a;line-height:1.6;margin-top:9px;text-align:center\">Figure 1 \u2014 A live preview is mutable; a bar-1 confirmed arrow is evaluated from fixed OHLC values. Prices and times are hypothetical.<\/figcaption><\/figure>\n<h2 style=\"color:#173553;font-size:25px;line-height:1.3;margin:34px 0 15px;border-bottom:1px solid #e4ebea;padding-bottom:9px\">The filter measures shape and range, not vague \u201cstrength\u201d<\/h2>\n<p style=\"margin:0 0 17px;line-height:1.75\">A candle is considered only if it has a nonzero high\u2013low range and sufficient context. Three ratios determine whether it is unusually directional: <strong>body fraction<\/strong>, <strong>close location<\/strong>, and <strong>range expansion<\/strong> compared with the preceding ten bars. The last quantity uses strictly older candles, never the candidate bar inside its own baseline.<\/p>\n<table style=\"width:100%;border-collapse:collapse;font-size:15px;margin:16px 0 24px\">\n<tr>\n<th style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#f1f5f4;color:#173553;font-weight:700\">Measurement<\/th>\n<th style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#f1f5f4;color:#173553;font-weight:700\">Definition<\/th>\n<th style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#f1f5f4;color:#173553;font-weight:700\">Default condition<\/th>\n<\/tr>\n<tr>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">Body fraction<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">abs(C \u2212 O) \/ (H \u2212 L)<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">At least 0.65<\/td>\n<\/tr>\n<tr>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#fbfcfa\">Close location<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#fbfcfa\">(C \u2212 L) \/ (H \u2212 L)<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#fbfcfa\">Bull \u2265 0.80; bear \u2264 0.20<\/td>\n<\/tr>\n<tr>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">Range expansion<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">(H \u2212 L) \/ average of previous 10 ranges<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">At least 1.15<\/td>\n<\/tr>\n<tr>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#fbfcfa\">Direction<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#fbfcfa\">Close compared with open<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#fbfcfa\">C &gt; O bullish; C &lt; O bearish<\/td>\n<\/tr>\n<\/table>\n<h3 style=\"color:#285580;font-size:19px;line-height:1.3;margin:21px 0 10px\">Worked example: a bullish candle that qualifies<\/h3>\n<p style=\"margin:0 0 17px;line-height:1.75\">Consider a purely hypothetical candle: open 100.00, high 102.00, low 99.60, close 101.85. Its range is 2.40 and its body size is 1.85, so the body fraction is <strong>1.85 \/ 2.40 = 0.771<\/strong>. Its close is 2.25 points above the low; the close-location value is <strong>2.25 \/ 2.40 = 0.938<\/strong>. If the ten older candles had an average range of 1.80, the range-expansion ratio is <strong>2.40 \/ 1.80 = 1.333<\/strong>. The candle meets all three defaults and is bullish because 101.85 is greater than 100.00.<\/p>\n<p style=\"margin:0 0 17px;line-height:1.75\">On the active candle, those same measurements remain provisional: an additional downward tick can extend the low, change the range, reduce body fraction, and eliminate the dot. Once the bar closes, the indicator evaluates the final data on index 1. This illustrates a crucial distinction: <strong>a non-repainting confirmed signal does not imply that a preview will never flicker.<\/strong><\/p>\n<h2 style=\"color:#173553;font-size:25px;line-height:1.3;margin:34px 0 15px;border-bottom:1px solid #e4ebea;padding-bottom:9px\">Why four indicator buffers solve a chart-audit problem<\/h2>\n<table style=\"width:100%;border-collapse:collapse;font-size:15px;margin:16px 0 24px\">\n<tr>\n<th style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#f1f5f4;color:#173553;font-weight:700\">Buffer<\/th>\n<th style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#f1f5f4;color:#173553;font-weight:700\">Drawn where<\/th>\n<th style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#f1f5f4;color:#173553;font-weight:700\">Meaning<\/th>\n<\/tr>\n<tr>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">0 \u2014 BullConfirmed<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">Completed bars, shift \u2265 1<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">Green up arrow. Never assigned to bar 0.<\/td>\n<\/tr>\n<tr>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#fbfcfa\">1 \u2014 BearConfirmed<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#fbfcfa\">Completed bars, shift \u2265 1<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#fbfcfa\">Red down arrow. Never assigned to bar 0.<\/td>\n<\/tr>\n<tr>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">2 \u2014 BullPreview<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">Current bar only, shift = 0<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">Lighter dot; can appear or disappear.<\/td>\n<\/tr>\n<tr>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#fbfcfa\">3 \u2014 BearPreview<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#fbfcfa\">Current bar only, shift = 0<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#fbfcfa\">Lighter dot; can appear or disappear.<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin:0 0 17px;line-height:1.75\">The code uses MT4\u2019s <code>OnInit()<\/code> and <code>OnCalculate()<\/code> handlers. Each buffer is bound with <code>SetIndexBuffer()<\/code> and then explicitly set to series orientation with <code>ArraySetAsSeries()<\/code>; that order matters because binding may reset indexing direction. In <code>OnCalculate()<\/code>, input OHLC\/time arrays are likewise placed in series order to remove ambiguity across terminals. Historic bars are recalculated on initial load or deeper-history refresh, while ordinary ticks only update a small trailing window and the preview.<\/p>\n<p style=\"margin:0 0 17px;line-height:1.75\">The popup logic is also stateful. <code>LastClosedTime<\/code> tracks the timestamp at shift 1. The first calculation deliberately initializes that state without raising an alert for old chart history. A fresh timestamp, encountered when a new candle starts, permits at most one popup on the newly completed candle. This handles many common alert floods, although resetting the indicator or restarting the terminal also resets the in-memory state.<\/p>\n<h2 style=\"color:#173553;font-size:25px;line-height:1.3;margin:34px 0 15px;border-bottom:1px solid #e4ebea;padding-bottom:9px\">Complete MT4 MQL4 source \u2014 copy into MetaEditor<\/h2>\n<p style=\"margin:0 0 17px;line-height:1.75\">Save the following as <code>PS_ClosedBarStateAudit.mq4<\/code>. The arrow buffers and optional preview dots form one complete custom indicator; it does not place trades and does not require an EA.<\/p>\n<pre style=\"white-space:pre;font-family:Consolas,Monaco,monospace;background:#f0f4f6;padding:22px 18px;border:1px solid #dbe5e7;border-radius:12px;font-size:12.6px;line-height:1.62\"><code>\/\/+------------------------------------------------------------------+<br>\/\/| PS_ClosedBarStateAudit.mq4  -  confirmed vs live-preview candles   |<br>\/\/| Educational custom indicator for MetaTrader 4 \/ MQL4             |<br>\/\/+------------------------------------------------------------------+<br>#property strict<br>#property indicator_chart_window<br>#property indicator_buffers 4<br>#property indicator_color1 clrSeaGreen<br>#property indicator_color2 clrIndianRed<br>#property indicator_color3 clrMediumAquamarine<br>#property indicator_color4 clrLightCoral<br><br>input int    AverageRangeBars  = 10;<br>input double MinBodyFraction   = 0.65;<br>input double BullCloseLocation = 0.80;<br>input double BearCloseLocation = 0.20;<br>input double MinRangeMultiple  = 1.15;<br>input double ArrowOffsetPart   = 0.18;<br>input bool   ShowLivePreview   = true;<br>input bool   PopupOnNewBar     = false;<br><br>double BullConfirmed[];<br>double BearConfirmed[];<br>double BullPreview[];<br>double BearPreview[];<br>datetime LastClosedTime = 0;<br><br>int OnInit()<br>{<br>\u00a0\u00a0\u00a0if(AverageRangeBars &lt; 2 || MinBodyFraction &lt; 0.0 ||<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0MinBodyFraction &gt; 1.0 || BullCloseLocation &lt; 0.0 ||<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0BullCloseLocation &gt; 1.0 || BearCloseLocation &lt; 0.0 ||<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0BearCloseLocation &gt; 1.0 || MinRangeMultiple &lt;= 0.0 ||<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ArrowOffsetPart &lt; 0.0)<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return(INIT_PARAMETERS_INCORRECT);<br><br>\u00a0\u00a0\u00a0SetIndexBuffer(0, BullConfirmed);<br>\u00a0\u00a0\u00a0SetIndexBuffer(1, BearConfirmed);<br>\u00a0\u00a0\u00a0SetIndexBuffer(2, BullPreview);<br>\u00a0\u00a0\u00a0SetIndexBuffer(3, BearPreview);<br>\u00a0\u00a0\u00a0\/\/ Binding a buffer can reset its indexing direction.<br>\u00a0\u00a0\u00a0ArraySetAsSeries(BullConfirmed, true);<br>\u00a0\u00a0\u00a0ArraySetAsSeries(BearConfirmed, true);<br>\u00a0\u00a0\u00a0ArraySetAsSeries(BullPreview, true);<br>\u00a0\u00a0\u00a0ArraySetAsSeries(BearPreview, true);<br><br>\u00a0\u00a0\u00a0SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID, 2);<br>\u00a0\u00a0\u00a0SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID, 2);<br>\u00a0\u00a0\u00a0SetIndexStyle(2, DRAW_ARROW, STYLE_SOLID, 1);<br>\u00a0\u00a0\u00a0SetIndexStyle(3, DRAW_ARROW, STYLE_SOLID, 1);<br>\u00a0\u00a0\u00a0SetIndexArrow(0, 233);<br>\u00a0\u00a0\u00a0SetIndexArrow(1, 234);<br>\u00a0\u00a0\u00a0SetIndexArrow(2, 159);  \/\/ preview dot, not a confirmed arrow<br>\u00a0\u00a0\u00a0SetIndexArrow(3, 159);<br><br>\u00a0\u00a0\u00a0for(int p = 0; p &lt; 4; p++)<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0SetIndexEmptyValue(p, EMPTY_VALUE);<br>\u00a0\u00a0\u00a0SetIndexLabel(0, \"Bullish confirmed\");<br>\u00a0\u00a0\u00a0SetIndexLabel(1, \"Bearish confirmed\");<br>\u00a0\u00a0\u00a0SetIndexLabel(2, \"Bullish LIVE preview\");<br>\u00a0\u00a0\u00a0SetIndexLabel(3, \"Bearish LIVE preview\");<br>\u00a0\u00a0\u00a0IndicatorShortName(\"PS Closed-Bar State Audit (MT4)\");<br>\u00a0\u00a0\u00a0return(INIT_SUCCEEDED);<br>}<br><br>\/\/ Evaluate candle at shift using only OLDER candles (shift+1, ...).<br>int EvaluateCandle(const int shift, const int total,<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const double &amp;o[], const double &amp;h[],<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const double &amp;l[], const double &amp;c[])<br>{<br>\u00a0\u00a0\u00a0if(shift + AverageRangeBars &gt;= total)<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return 0;<br>\u00a0\u00a0\u00a0double range = h[shift] - l[shift];<br>\u00a0\u00a0\u00a0if(range &lt;= 0.0)<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return 0;<br><br>\u00a0\u00a0\u00a0double priorSum = 0.0;<br>\u00a0\u00a0\u00a0for(int k = 1; k &lt;= AverageRangeBars; k++)<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0priorSum += MathMax(0.0, h[shift+k] - l[shift+k]);<br>\u00a0\u00a0\u00a0double priorAverage = priorSum \/ AverageRangeBars;<br>\u00a0\u00a0\u00a0if(priorAverage &lt;= 0.0 || range &lt; MinRangeMultiple * priorAverage)<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return 0;<br><br>\u00a0\u00a0\u00a0double bodyRatio = MathAbs(c[shift] - o[shift]) \/ range;<br>\u00a0\u00a0\u00a0double closeLocation = (c[shift] - l[shift]) \/ range;<br>\u00a0\u00a0\u00a0if(bodyRatio &lt; MinBodyFraction)<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return 0;<br>\u00a0\u00a0\u00a0if(c[shift] &gt; o[shift] &amp;&amp; closeLocation &gt;= BullCloseLocation)<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return 1;<br>\u00a0\u00a0\u00a0if(c[shift] &lt; o[shift] &amp;&amp; closeLocation &lt;= BearCloseLocation)<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return -1;<br>\u00a0\u00a0\u00a0return 0;<br>}<br><br>int OnCalculate(const int rates_total, const int prev_calculated,<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const datetime &amp;time[], const double &amp;open[],<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const double &amp;high[], const double &amp;low[],<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const double &amp;close[], const long &amp;tick_volume[],<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0const long &amp;volume[], const int &amp;spread[])<br>{<br>\u00a0\u00a0\u00a0if(rates_total &lt;= AverageRangeBars + 2)<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return 0;<br>\u00a0\u00a0\u00a0\/\/ Make the meaning of shift 0 \/ shift 1 explicit.<br>\u00a0\u00a0\u00a0ArraySetAsSeries(time, true);<br>\u00a0\u00a0\u00a0ArraySetAsSeries(open, true);<br>\u00a0\u00a0\u00a0ArraySetAsSeries(high, true);<br>\u00a0\u00a0\u00a0ArraySetAsSeries(low, true);<br>\u00a0\u00a0\u00a0ArraySetAsSeries(close, true);<br><br>\u00a0\u00a0\u00a0if(prev_calculated == 0 || prev_calculated &gt; rates_total)<br>\u00a0\u00a0\u00a0{<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ArrayInitialize(BullConfirmed, EMPTY_VALUE);<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ArrayInitialize(BearConfirmed, EMPTY_VALUE);<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ArrayInitialize(BullPreview, EMPTY_VALUE);<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ArrayInitialize(BearPreview, EMPTY_VALUE);<br>\u00a0\u00a0\u00a0}<br><br>\u00a0\u00a0\u00a0int maxShift = rates_total - AverageRangeBars - 1;<br>\u00a0\u00a0\u00a0int recalc = (prev_calculated == 0 || prev_calculated &gt; rates_total)<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0? maxShift : MathMin(maxShift, rates_total-prev_calculated+1);<br>\u00a0\u00a0\u00a0for(int i = recalc; i &gt;= 1; i--)<br>\u00a0\u00a0\u00a0{<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0BullConfirmed[i] = EMPTY_VALUE;<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0BearConfirmed[i] = EMPTY_VALUE;<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0int direction = EvaluateCandle(i, rates_total, open, high, low, close);<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0double offset = (high[i] - low[i]) * ArrowOffsetPart;<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if(direction == 1)  BullConfirmed[i] = low[i]  - offset;<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if(direction == -1) BearConfirmed[i] = high[i] + offset;<br>\u00a0\u00a0\u00a0}<br><br>\u00a0\u00a0\u00a0\/\/ Never publish a confirmed arrow on the unfinished candle.<br>\u00a0\u00a0\u00a0BullConfirmed[0] = EMPTY_VALUE;<br>\u00a0\u00a0\u00a0BearConfirmed[0] = EMPTY_VALUE;<br>\u00a0\u00a0\u00a0BullPreview[0] = EMPTY_VALUE;<br>\u00a0\u00a0\u00a0BearPreview[0] = EMPTY_VALUE;<br>\u00a0\u00a0\u00a0if(ShowLivePreview)<br>\u00a0\u00a0\u00a0{<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0int live = EvaluateCandle(0, rates_total, open, high, low, close);<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0double liveOffset = (high[0] - low[0]) * ArrowOffsetPart;<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if(live == 1)  BullPreview[0] = low[0]  - liveOffset;<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if(live == -1) BearPreview[0] = high[0] + liveOffset;<br>\u00a0\u00a0\u00a0}<br><br>\u00a0\u00a0\u00a0\/\/ New-bar boundary: alert at most once per newly closed candle.<br>\u00a0\u00a0\u00a0\/\/ First attachment is silent; historical arrows never trigger popups.<br>\u00a0\u00a0\u00a0if(LastClosedTime == 0)<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0LastClosedTime = time[1];<br>\u00a0\u00a0\u00a0else if(time[1] != LastClosedTime)<br>\u00a0\u00a0\u00a0{<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0LastClosedTime = time[1];<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if(PopupOnNewBar &amp;&amp; BullConfirmed[1] != EMPTY_VALUE)<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Alert(Symbol(), \" MT4 bullish candle confirmed at \",<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0TimeToString(time[1], TIME_DATE|TIME_MINUTES));<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if(PopupOnNewBar &amp;&amp; BearConfirmed[1] != EMPTY_VALUE)<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Alert(Symbol(), \" MT4 bearish candle confirmed at \",<br>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0TimeToString(time[1], TIME_DATE|TIME_MINUTES));<br>\u00a0\u00a0\u00a0}<br>\u00a0\u00a0\u00a0return(rates_total);<br>}<br><\/code><\/pre>\n<h2 style=\"color:#173553;font-size:25px;line-height:1.3;margin:34px 0 15px;border-bottom:1px solid #e4ebea;padding-bottom:9px\">Installation and a reproducible acceptance test<\/h2>\n<ul style=\"padding-left:24px;line-height:1.72;margin:8px 0 20px\">\n<li style=\"margin-bottom:8px\">In MT4 select <strong>File \u2192 Open Data Folder<\/strong>, then place the file under <code>MQL4\/Indicators<\/code>. Open it with MetaEditor and compile. Refresh Navigator or restart MT4; attach <strong>PS Closed-Bar State Audit<\/strong> to a chart. Compilation and terminal-specific behavior must be checked locally.<\/li>\n<li style=\"margin-bottom:8px\">Start with <strong>AverageRangeBars=10<\/strong>, <strong>MinBodyFraction=0.65<\/strong>, <strong>BullCloseLocation=0.80<\/strong>, <strong>BearCloseLocation=0.20<\/strong>, and <strong>MinRangeMultiple=1.15<\/strong>. Leave popup alerts off during inspection.<\/li>\n<li style=\"margin-bottom:8px\">With <strong>ShowLivePreview=true<\/strong>, observe the small dots on the latest candle. Their disappearance during a live bar is expected and does not represent a confirmed-signal repaint.<\/li>\n<li style=\"margin-bottom:8px\">Wait for a bar transition. Record the preceding candle\u2019s OHLC and verify the green\/red arrow decision independently using the formula table. Check that a confirmed arrow, if present, remains attached to the closed candle.<\/li>\n<li style=\"margin-bottom:8px\">Switch <strong>ShowLivePreview=false<\/strong>. Only completed-bar arrows should remain visible. Optionally enable <strong>PopupOnNewBar<\/strong> and verify that one new-bar boundary does not generate repeated popups on every tick.<\/li>\n<\/ul>\n<h2 style=\"color:#173553;font-size:25px;line-height:1.3;margin:34px 0 15px;border-bottom:1px solid #e4ebea;padding-bottom:9px\">Sensitivity guide: what to change and what to leave alone<\/h2>\n<table style=\"width:100%;border-collapse:collapse;font-size:15px;margin:16px 0 24px\">\n<tr>\n<th style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#f1f5f4;color:#173553;font-weight:700\">Setting<\/th>\n<th style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#f1f5f4;color:#173553;font-weight:700\">Lower \/ shorter<\/th>\n<th style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#f1f5f4;color:#173553;font-weight:700\">Higher \/ longer<\/th>\n<\/tr>\n<tr>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">MinBodyFraction<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">Allows smaller real bodies; more weak candles qualify.<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">Requires a more directional candle body.<\/td>\n<\/tr>\n<tr>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#fbfcfa\">BullCloseLocation<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#fbfcfa\">Allows closes farther from the high.<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#fbfcfa\">Demands a close nearer the high.<\/td>\n<\/tr>\n<tr>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">BearCloseLocation<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">Demands a close nearer the low.<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">Allows closes farther from the low.<\/td>\n<\/tr>\n<tr>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#fbfcfa\">MinRangeMultiple<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#fbfcfa\">Allows ordinary-range candles; raises frequency.<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top;background:#fbfcfa\">Accepts only more expanded candles; fewer signals.<\/td>\n<\/tr>\n<tr>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">AverageRangeBars<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">Adapts faster to regime changes but is noisier.<\/td>\n<td style=\"1px solid #e2e9e8;padding:12px 11px;vertical-align:top\">Smoother baseline that may lag abrupt volatility changes.<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin:0 0 17px;line-height:1.75\">These are threshold trade-offs, not optimizations guaranteed to improve profitability. For example, reducing the expansion requirement from 1.15 to 1.00 means a candle with a range equal to the previous average can pass, but the code still requires both body fraction and close location to pass. Increasing the range threshold can reject the previously worked example once the requirement exceeds 1.333. The default arrow offset only affects visual placement and is not a stop-loss distance.<\/p>\n<h2 style=\"color:#173553;font-size:25px;line-height:1.3;margin:34px 0 15px;border-bottom:1px solid #e4ebea;padding-bottom:9px\">Known limitations and failure modes<\/h2>\n<ul style=\"padding-left:24px;line-height:1.72;margin:8px 0 20px\">\n<li style=\"margin-bottom:8px\">The platform calculates this indicator from broker-supplied OHLC. Different feeds, missing ticks, weekend candles, or synthetic symbols can yield different candle shapes. A directional candle is not necessarily a tradable continuation.<\/li>\n<li style=\"margin-bottom:8px\">Confirmed arrows are stable with respect to future candles <em>under unchanged historical OHLC<\/em>. If a broker revises old history, prices and historical decisions may legitimately recalculate. Avoid calling this absolute immunity to data revision.<\/li>\n<li style=\"margin-bottom:8px\">The first loaded calculation is intentionally silent; attaching the indicator halfway through a candle does not create a retroactive alert. A popup is evaluated only on the next newly detected bar boundary.<\/li>\n<li style=\"margin-bottom:8px\">Signals use completed bars, but a trading system would still face spread, execution delay, slippage, commissions, liquidity, and position-sizing decisions; none are modeled by this visual indicator.<\/li>\n<li style=\"margin-bottom:8px\">The live preview is strictly educational. Do not compare a screenshot of intrabar preview dots with an after-the-fact backtest of confirmed arrows as if they were the same event stream.<\/li>\n<\/ul>\n<h2 style=\"color:#173553;font-size:25px;line-height:1.3;margin:34px 0 15px;border-bottom:1px solid #e4ebea;padding-bottom:9px\">Validation checklist before relying on the output<\/h2>\n<ul style=\"padding-left:24px;line-height:1.72;margin:8px 0 20px\">\n<li style=\"margin-bottom:8px\">Confirm that the chart is from <strong>MetaTrader 4<\/strong> and the file is compiled as an <strong>indicator<\/strong>, not an EA or MT5 program.<\/li>\n<li style=\"margin-bottom:8px\">Inspect bar-0 behavior tick by tick; verify all confirmed buffers are empty at shift 0 and preview buffers are confined to that shift.<\/li>\n<li style=\"margin-bottom:8px\">Check the previous-ten-bar average manually for at least two signal candidates, including one disqualified by the range filter.<\/li>\n<li style=\"margin-bottom:8px\">Test both bullish and bearish examples, a zero-range candle, insufficient early history, and a history reload.<\/li>\n<li style=\"margin-bottom:8px\">Restart MT4 and confirm that no historical popup flood occurs at attachment; test exactly one alert per fresh qualifying close.<\/li>\n<li style=\"margin-bottom:8px\">Compare broker feeds and chart timeframes without interpreting different counts as evidence of profitability.<\/li>\n<\/ul>\n<p style=\"margin:0 0 17px;line-height:1.75\">If this free MT4 source helps your research but you need additional audit logging, push alerts, multi-symbol checks, or other modifications, our <a href=\"https:\/\/patternsmart.com\/wp\/services\/professional-custom-trading-software-development-services\/\">Custom Trading Software Development Services<\/a> can help you scope the adaptation.<\/p>\n<p style=\"margin:0 0 17px;line-height:1.75\"><strong>Risk note:<\/strong> This is educational diagnostic code, not an investment recommendation or a verified trading system. No return, win rate, or backtest performance is claimed. Compile, inspect, and forward-test in the target terminal before using any derivative in live trading.<\/p>\n<p style=\"border-top:1px solid #dfe8e8;padding-top:18px;margin-top:25px;color:#5b7387;font-size:14px\">\n<\/article>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>PATTERNSMART \/ MQL4 ENGINEERING NOTE MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4 Difficulty: Trading Tips \u00a0|\u00a0 MetaTrader 4 indicator \u00a0|\u00a0 Full commented source included Why did the arrow appear and then disappear? On an active MT4 candle, high, low, and close can still change with every tick. A useful signal [&hellip;]<\/p>\n","protected":false},"author":101012,"featured_media":3123,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[251,167],"tags":[548,515,561],"class_list":["post-3122","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-coding-logic","category-mt4","tag-candlestick-analysis","tag-free-mt4-indicator","tag-trading-tips"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4 - PatternSmart.com<\/title>\n<meta name=\"description\" content=\"PATTERNSMART \/ MQL4 ENGINEERING NOTE MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4 Difficulty: Trading Tips \u00a0|\u00a0\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/patternsmart.com\/wp\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4 - PatternSmart.com\" \/>\n<meta property=\"og:description\" content=\"PATTERNSMART \/ MQL4 ENGINEERING NOTE MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4 Difficulty: Trading Tips \u00a0|\u00a0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/patternsmart.com\/wp\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\/\" \/>\n<meta property=\"og:site_name\" content=\"PatternSmart.com\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/patternsmartcom\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-22T16:00:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-22T16:01:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/patternsmart.com\/wp\/wp-content\/uploads\/2026\/11\/Professional-schematic-showing-MT4-unfinished-bar-zero-new-bar-index-shift-confirmed-bar-one-and-reproducible-candle-calculations.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1440\" \/>\n\t<meta property=\"og:image:height\" content=\"810\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Pattern Smart\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@patternsmart\" \/>\n<meta name=\"twitter:site\" content=\"@patternsmart\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Pattern Smart\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\\\/\"},\"author\":{\"name\":\"Pattern Smart\",\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/#\\\/schema\\\/person\\\/eaa56431702c6932bb7d80f7de5104b6\"},\"headline\":\"MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4\",\"datePublished\":\"2026-11-22T16:00:49+00:00\",\"dateModified\":\"2026-11-22T16:01:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\\\/\"},\"wordCount\":1400,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/Professional-schematic-showing-MT4-unfinished-bar-zero-new-bar-index-shift-confirmed-bar-one-and-reproducible-candle-calculations.png\",\"keywords\":[\"candlestick analysis\",\"Free MT4 indicator\",\"Trading Tips\"],\"articleSection\":[\"Coding Logic\",\"MT4\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/patternsmart.com\\\/wp\\\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\\\/\",\"url\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\\\/\",\"name\":\"MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4 - PatternSmart.com\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/Professional-schematic-showing-MT4-unfinished-bar-zero-new-bar-index-shift-confirmed-bar-one-and-reproducible-candle-calculations.png\",\"datePublished\":\"2026-11-22T16:00:49+00:00\",\"dateModified\":\"2026-11-22T16:01:41+00:00\",\"description\":\"PATTERNSMART \\\/ MQL4 ENGINEERING NOTE MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4 Difficulty: Trading Tips \u00a0|\u00a0\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/patternsmart.com\\\/wp\\\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\\\/#primaryimage\",\"url\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/Professional-schematic-showing-MT4-unfinished-bar-zero-new-bar-index-shift-confirmed-bar-one-and-reproducible-candle-calculations.png\",\"contentUrl\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/Professional-schematic-showing-MT4-unfinished-bar-zero-new-bar-index-shift-confirmed-bar-one-and-reproducible-candle-calculations.png\",\"width\":1440,\"height\":810},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Technical analysis\",\"item\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/category\\\/technical-analysis\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/#website\",\"url\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/\",\"name\":\"PatternSmart.com\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/#organization\",\"name\":\"PatternSmart.com\",\"url\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/icon.png\",\"contentUrl\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/icon.png\",\"width\":50,\"height\":50,\"caption\":\"PatternSmart.com\"},\"image\":{\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/patternsmartcom\",\"https:\\\/\\\/x.com\\\/patternsmart\",\"https:\\\/\\\/www.youtube.com\\\/@PatternSmartcom\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/#\\\/schema\\\/person\\\/eaa56431702c6932bb7d80f7de5104b6\",\"name\":\"Pattern Smart\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/277b2a9f63046299e2c87ae6ca3e98e5edad0923ad4d1a51980f12c0f13254c0?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/277b2a9f63046299e2c87ae6ca3e98e5edad0923ad4d1a51980f12c0f13254c0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/277b2a9f63046299e2c87ae6ca3e98e5edad0923ad4d1a51980f12c0f13254c0?s=96&d=mm&r=g\",\"caption\":\"Pattern Smart\"},\"sameAs\":[\"https:\\\/\\\/PatternSmart.com\"],\"url\":\"https:\\\/\\\/patternsmart.com\\\/wp\\\/author\\\/editor\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4 - PatternSmart.com","description":"PATTERNSMART \/ MQL4 ENGINEERING NOTE MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4 Difficulty: Trading Tips \u00a0|\u00a0","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/patternsmart.com\/wp\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\/","og_locale":"en_US","og_type":"article","og_title":"MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4 - PatternSmart.com","og_description":"PATTERNSMART \/ MQL4 ENGINEERING NOTE MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4 Difficulty: Trading Tips \u00a0|\u00a0","og_url":"https:\/\/patternsmart.com\/wp\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\/","og_site_name":"PatternSmart.com","article_publisher":"https:\/\/www.facebook.com\/patternsmartcom","article_published_time":"2026-11-22T16:00:49+00:00","article_modified_time":"2026-11-22T16:01:41+00:00","og_image":[{"width":1440,"height":810,"url":"https:\/\/patternsmart.com\/wp\/wp-content\/uploads\/2026\/11\/Professional-schematic-showing-MT4-unfinished-bar-zero-new-bar-index-shift-confirmed-bar-one-and-reproducible-candle-calculations.png","type":"image\/png"}],"author":"Pattern Smart","twitter_card":"summary_large_image","twitter_creator":"@patternsmart","twitter_site":"@patternsmart","twitter_misc":{"Written by":"Pattern Smart","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/patternsmart.com\/wp\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\/#article","isPartOf":{"@id":"https:\/\/patternsmart.com\/wp\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\/"},"author":{"name":"Pattern Smart","@id":"https:\/\/patternsmart.com\/wp\/#\/schema\/person\/eaa56431702c6932bb7d80f7de5104b6"},"headline":"MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4","datePublished":"2026-11-22T16:00:49+00:00","dateModified":"2026-11-22T16:01:41+00:00","mainEntityOfPage":{"@id":"https:\/\/patternsmart.com\/wp\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\/"},"wordCount":1400,"commentCount":0,"publisher":{"@id":"https:\/\/patternsmart.com\/wp\/#organization"},"image":{"@id":"https:\/\/patternsmart.com\/wp\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\/#primaryimage"},"thumbnailUrl":"https:\/\/patternsmart.com\/wp\/wp-content\/uploads\/2026\/11\/Professional-schematic-showing-MT4-unfinished-bar-zero-new-bar-index-shift-confirmed-bar-one-and-reproducible-candle-calculations.png","keywords":["candlestick analysis","Free MT4 indicator","Trading Tips"],"articleSection":["Coding Logic","MT4"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/patternsmart.com\/wp\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/patternsmart.com\/wp\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\/","url":"https:\/\/patternsmart.com\/wp\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\/","name":"MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4 - PatternSmart.com","isPartOf":{"@id":"https:\/\/patternsmart.com\/wp\/#website"},"primaryImageOfPage":{"@id":"https:\/\/patternsmart.com\/wp\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\/#primaryimage"},"image":{"@id":"https:\/\/patternsmart.com\/wp\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\/#primaryimage"},"thumbnailUrl":"https:\/\/patternsmart.com\/wp\/wp-content\/uploads\/2026\/11\/Professional-schematic-showing-MT4-unfinished-bar-zero-new-bar-index-shift-confirmed-bar-one-and-reproducible-candle-calculations.png","datePublished":"2026-11-22T16:00:49+00:00","dateModified":"2026-11-22T16:01:41+00:00","description":"PATTERNSMART \/ MQL4 ENGINEERING NOTE MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4 Difficulty: Trading Tips \u00a0|\u00a0","breadcrumb":{"@id":"https:\/\/patternsmart.com\/wp\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/patternsmart.com\/wp\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/patternsmart.com\/wp\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\/#primaryimage","url":"https:\/\/patternsmart.com\/wp\/wp-content\/uploads\/2026\/11\/Professional-schematic-showing-MT4-unfinished-bar-zero-new-bar-index-shift-confirmed-bar-one-and-reproducible-candle-calculations.png","contentUrl":"https:\/\/patternsmart.com\/wp\/wp-content\/uploads\/2026\/11\/Professional-schematic-showing-MT4-unfinished-bar-zero-new-bar-index-shift-confirmed-bar-one-and-reproducible-candle-calculations.png","width":1440,"height":810},{"@type":"BreadcrumbList","@id":"https:\/\/patternsmart.com\/wp\/mt4-non-repainting-candle-signals-closed-bar-state-audit-and-live-preview-in-mql4\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/patternsmart.com\/wp\/"},{"@type":"ListItem","position":2,"name":"Technical analysis","item":"https:\/\/patternsmart.com\/wp\/category\/technical-analysis\/"},{"@type":"ListItem","position":3,"name":"MT4 Non-Repainting Candle Signals: Closed-Bar State Audit and Live Preview in MQL4"}]},{"@type":"WebSite","@id":"https:\/\/patternsmart.com\/wp\/#website","url":"https:\/\/patternsmart.com\/wp\/","name":"PatternSmart.com","description":"","publisher":{"@id":"https:\/\/patternsmart.com\/wp\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/patternsmart.com\/wp\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/patternsmart.com\/wp\/#organization","name":"PatternSmart.com","url":"https:\/\/patternsmart.com\/wp\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/patternsmart.com\/wp\/#\/schema\/logo\/image\/","url":"https:\/\/patternsmart.com\/wp\/wp-content\/uploads\/2026\/04\/icon.png","contentUrl":"https:\/\/patternsmart.com\/wp\/wp-content\/uploads\/2026\/04\/icon.png","width":50,"height":50,"caption":"PatternSmart.com"},"image":{"@id":"https:\/\/patternsmart.com\/wp\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/patternsmartcom","https:\/\/x.com\/patternsmart","https:\/\/www.youtube.com\/@PatternSmartcom"]},{"@type":"Person","@id":"https:\/\/patternsmart.com\/wp\/#\/schema\/person\/eaa56431702c6932bb7d80f7de5104b6","name":"Pattern Smart","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/277b2a9f63046299e2c87ae6ca3e98e5edad0923ad4d1a51980f12c0f13254c0?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/277b2a9f63046299e2c87ae6ca3e98e5edad0923ad4d1a51980f12c0f13254c0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/277b2a9f63046299e2c87ae6ca3e98e5edad0923ad4d1a51980f12c0f13254c0?s=96&d=mm&r=g","caption":"Pattern Smart"},"sameAs":["https:\/\/PatternSmart.com"],"url":"https:\/\/patternsmart.com\/wp\/author\/editor\/"}]}},"_links":{"self":[{"href":"https:\/\/patternsmart.com\/wp\/wp-json\/wp\/v2\/posts\/3122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/patternsmart.com\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/patternsmart.com\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/patternsmart.com\/wp\/wp-json\/wp\/v2\/users\/101012"}],"replies":[{"embeddable":true,"href":"https:\/\/patternsmart.com\/wp\/wp-json\/wp\/v2\/comments?post=3122"}],"version-history":[{"count":0,"href":"https:\/\/patternsmart.com\/wp\/wp-json\/wp\/v2\/posts\/3122\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/patternsmart.com\/wp\/wp-json\/wp\/v2\/media\/3123"}],"wp:attachment":[{"href":"https:\/\/patternsmart.com\/wp\/wp-json\/wp\/v2\/media?parent=3122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/patternsmart.com\/wp\/wp-json\/wp\/v2\/categories?post=3122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/patternsmart.com\/wp\/wp-json\/wp\/v2\/tags?post=3122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}