How the iCustom Function Retrieves Values From External MT4 Indicators

An Expert Advisor can display a custom indicator’s signals without knowing how the indicator calculates them. The connection is a function call that requests a particular output buffer at a particular bar. If the wrong buffer or bar is selected, the automated strategy may act on a perfectly valid number that means something entirely different from what its developer intended.

In metatrader 4, iCustom() retrieves values from a compiled custom indicator. Its apparent simplicity hides five details that determine whether an Expert Advisor interprets those values correctly.

The Indicator Name Must Resolve to the Intended File

The function loads an indicator identified by its name relative to the platform’s MQL4/Indicators directory. An indicator in a subfolder requires the corresponding path, with backslashes escaped in an MQL4 string. A misspelled filename, missing compiled indicator or wrong subfolder prevents the intended calculation from being accessed.

The name also matters when similarly named versions coexist. An EA may keep calling an older compiled build even after the developer edits a different source file. Confirm the exact file being loaded and check terminal logs for loading errors before diagnosing the trading rule itself.

Input Parameters Must Match the Indicator’s Declared Order

After the symbol, timeframe and indicator name, iCustom() accepts optional arguments corresponding to the indicator’s external inputs, followed by the buffer index and bar shift. Supplied inputs must match the declared order and types. Omitted inputs use their compiled defaults.

A channel indicator might accept a lookback length, deviation multiplier and alert switch. Passing the multiplier where the lookback belongs changes the calculation, potentially without an obvious visual warning. An EA that expects a 20-bar channel may instead receive values based on an unintended configuration. Compare the call against the indicator’s actual input or extern declarations, not a screenshot of its settings.

Buffer Indices Identify Data Series, Not Chart Colors

The mode argument selects an indicator line buffer indexed from zero, within the supported range of zero through seven. Buffer zero is not inherently the main signal, and a buffer used for drawing arrows may contain an empty-value marker on most bars. Its meaning comes from the indicator’s SetIndexBuffer() assignments and output design.

For example, a custom trend indicator might expose its upper boundary in buffer zero, lower boundary in buffer one and buy arrows in buffer two. Reading buffer zero as a buy signal would treat ordinary price levels as instructions. Inspect the source or reliable buffer documentation, and explicitly test for EMPTY_VALUE where appropriate.

Bar Shift Can Turn an Unfinished Signal Into an Entry

The final argument, shift, identifies the bar: zero for the current, still-forming candle and one for the most recently completed candle. An indicator may change its current-bar output each time a new price arrives, even when its completed-bar values remain stable.

Imagine a hypothetical sugar-share CFD strategy that buys 400 CFDs when a custom breakout indicator emits a value above 52. At 10:12, the current-bar buffer briefly reads 53, triggering a purchase at $26.40. By the candle close, the buffer falls to 49 and the share price slips to $25.90. Closing there creates a $200 loss before costs. A completed-bar rule would not have entered on that temporary reading. The difference is signal timing, not an incorrect calculation.

Returned Numbers Still Need Validation Before Orders

An indicator can load successfully yet return a value unsuitable for trading: an empty marker, an uninitialized observation or a number calculated with insufficient history. A nonzero result is not proof that the intended signal is ready. Developers should check available bars, compare selected buffer values with the indicator on the same symbol and timeframe, and inspect errors when calls fail.

In metatrader 4 automation, repeating iCustom() calls also requires attention to consistent inputs and manageable processing overhead. Before opening a CFD position, run the EA on a demo chart, log the indicator name, parameters, buffer and shift alongside each proposed order, and confirm that the recorded signal matches the completed chart evidence.