← All projects

Pine Script → MT5 Smart-Money Indicator Port and EAs

A line-for-line MQL5 port of a TradingView smart-money indicator, an EA that trades its signals, and a second EA that fuses two more Pine indicators for M1–M5 scalping.

Client
TradingView indicator vendor
Year
2026
Category
Trading Systems
Stack
  • MQL5
  • MetaTrader 5
  • Pine Script

The problem

The client sold a smart-money-concepts indicator on TradingView and wanted the same product on MetaTrader 5, plus EAs that trade it. The port had to match TradingView bar for bar: same plots, same signals, same defaults.

What I built

  • Indicator port: trend line, internal and swing break of structure / change of character, order blocks, equal highs and lows, fair value gaps, multi-timeframe levels, premium/discount zones and a momentum oscillator. Every Pine input is kept with its original default.
  • Rendering map:
    • plotcandle and barcolor became one colour-candles plot
    • lines, labels and boxes became chart objects, with a 500-object FIFO per type (Pine’s limits)
    • transparency is emulated by blending colours against the chart background
    • alerts are de-duplicated per bar
  • Signal EA that reads the indicator through iCustom:
    • four entry sources (trend flip, oscillator signal, confluence, flip plus oscillator confirmation), an optional structure trend filter and closed-bar entries
    • stops in pips, ATR or at the last swing; targets in pips, ATR or R-multiple
    • five trailing modes, including trailing on the indicator’s own lines, with breakeven stacked on top
    • fixed lot or risk-percent sizing, a spread cap, time windows across midnight and max positions
  • Fusion EA: two more Pine indicators (a SuperTrend/ADX tool and a pivot-based buy/sell tool) rebuilt inside a single EA, with no indicator install. It adds four engine modes, breakeven, fixed, ATR or SuperTrend trailing, a time-based profit exit, a max-drift check before entry, and a hedging-account check.
  • Manuals in Markdown and PDF, and builds with zero compiler warnings.

Details

  • Pine semantics, reproduced:
    • each call site keeps its own var state
    • EMA and RMA seeding match Pine
    • a percentile function is rebuilt with quickselect
    • known quirks in the original are kept on purpose, so signals match
  • Live-bar repainting: the stateful structure engine snapshots its state after the last closed bar. On every tick it rolls back and replays the forming bar, which reproduces TradingView’s live behaviour.
  • iCustom limit: MT5 passes at most 64 parameters. Inputs were reordered so every setting the EA drives fits in the first 57.
  • A repainting source made tradable: the pivot-based tool repaints on TradingView, so the EA only acts on confirmed pivots. The resulting entry lag is documented for the client rather than hidden.