Compare the same trading job
This is a documentation-based comparison of MetaTrader 5, not MT4. The reference task is a long-only breakout on ordinary 15-minute EURUSD candles. It needs a chart, completed-bar calculations, a fixed exposure, and an exit rule. Extra features matter only if they change that task.
| Requirement | MetaTrader 5 | TradingView |
|---|
| Chart and input data | Record the broker server, symbol specification, history, and bar timestamps. | Record the provider-qualified symbol, session, timeframe, and chart type. |
| Custom calculations | MQL5 uses explicit scalar types, arrays, structures, and indicator handles. | Pine uses typed values with qualifiers such as simple and series; historical values belong to its bar execution model. |
| Historical testing | Run an EA in Strategy Tester; select the tick mode, dates, inputs, and trading conditions. | Run a Pine strategy against chart data using the broker emulator and declared strategy properties. |
| Parameter research | The tester supports parameter optimization and a separate forward period within historical data. | Use strategy inputs and reports to inspect the selected configuration; preserve a separate holdout interval for evaluation. |
| Account execution | An EA submits trade requests to the account environment and must handle the returned results. | Pine simulation is separate from broker execution. Automated alert routing needs another integration. |
Freeze the rule before translating it
For this hypothetical fixture, enter long only while flat and without a pending entry when the completed candle closes strictly above the highest high of the preceding three candles. Exclude the signal candle from that three-bar window. Exit the whole position when a later completed close is strictly below the lowest low of its preceding three candles. Make one decision per completed candle and execute at the next available price. There are no intrabar stops, short entries, or added positions.
- Wait for three prior completed candles. Missing observations or unfinished indicator data must not be silently replaced with zero.
- In an MT5 EA that detects the first tick of a new bar, the signal candle is shift 1 and its three predecessors are shifts 2 through 4. In a Pine strategy evaluated at the signal bar close, the signal candle is current and its predecessors are one through three bars back.
- A different feed can have a prior high above 1.1012 and legitimately produce no entry. Compare raw bars before editing either implementation.
| Fixture | Calculation | Expected decision |
|---|
| Three prior highs: 1.1000, 1.1010, 1.1005 | Breakout threshold = max(1.1000, 1.1010, 1.1005) = 1.1010. | A completed close of 1.1012 produces one entry decision while flat. |
| Signal candle high: 1.1015 | Including this high would move the threshold to 1.1015. | That is a different rule and would suppress this entry. |
| Boundary close: 1.1010 | The close equals the prior threshold. | No entry: the rule requires strictly greater, not greater than or equal. |
| Later prior lows: 1.1013, 1.1011, 1.1014 | Exit threshold = 1.1011; completed close = 1.1010. | Exit the existing long at the next available price. |
Pine and MQL5 types do not map one for one
MQL5 distinguishes integer handles and tickets from floating-point prices, datetime values, and enumerations. Pine also has a type system, but its qualifiers describe how values vary during execution. A Pine series is not an ordinary MQL5 array, and an MQL5 handle is not the indicator value it identifies.
- For an added moving-average filter, MQL5 iMA returns an integer handle. Read its buffer with CopyBuffer, check the returned count, and handle INVALID_HANDLE or unavailable data. Treating the handle as a price can compile yet produce incorrect decisions.
- CopyBuffer position 0 means the current bar. Specify both the requested shifts and destination-array order before comparing a pair of values; do not assume array element 0 is always the latest completed sample.
- Pine evaluates historical series as the script runs through bars. Preserve the distinction between a completed-bar decision and an intrabar update when translating to an event handler.
- For this breakout fixture, avoid unnecessary indicators: compare the same high and low windows directly, then verify boolean decisions before adding filters.
Tick mode and data provenance change the experiment
MT5 can test with broker-supplied real ticks or generated ticks. In real-tick mode, missing tick data for an available minute bar can be generated, so inspect coverage and the tester journal. Generated Every tick, 1 Minute OHLC, and Open prices only are different models. TradingView normally derives historical fills from chart data; Bar Magnifier uses lower-timeframe data where available. These settings cannot establish identical price paths by themselves.
- For the completed-bar fixture, compare the input candles and decision times first. After adding intrabar exits, rerun with a model that can represent them; Open prices only is not a substitute for checking intrabar behavior.
- MT5 real ticks can contain changing spreads within a minute; generated ticks use the corresponding minute-bar spread. Record the price side used for the signal and the Bid/Ask prices used for trades.
- TradingView forex providers can differ: ICE combines contributors, while other feeds can represent individual brokers. Matching the text EURUSD does not match the source, session, or volume series.
- MT5 forward optimization reserves a later part of the historical interval. It is a holdout test, not evidence of live execution. Keep the interval and selection procedure fixed before evaluating results.
Orders, deals, and positions require separate checks
In MT5, an order is an instruction, a deal is an execution, and a position is the resulting exposure. Account settings determine netting or hedging behavior. With netting, deals in one symbol update a common position; hedging accounts can hold separate positions, including opposite directions. Pine models strategy entries and exits within its simulated position, so ticket-by-ticket hedging logic needs an explicit redesign.
- For the reference rule, assert one owned long and no pending entry before opening. Decide how manual trades or another EA on the same symbol affect that assertion.
- MQL5 OrderSend returning true does not prove a fill. Inspect the result code and subsequent trade events, including rejection or partial execution.
- Pine strategies normally calculate at close and market orders normally fill on the next available tick, historically the next bar open. Record any settings that change this timing instead of assigning the signal close as the fill.
| Hypothetical operation | MT5 netting account | MT5 hedging account |
|---|
| Two filled buys of 0.10 lot each | One aggregate long position of 0.20 lot. | Two separate long positions of 0.10 lot each. |
| Then a new sell of 0.10 lot, without selecting a position to close | The common long exposure reduces to 0.10 lot. | A new short position can coexist with both longs. A net exposure calculation hides the separate tickets. |
Convert exposure before comparing profit
Assume a USD account and a EURUSD contract of 100,000 EUR per lot. A 0.10-lot position represents 10,000 EUR. If the assumed buy fills at Ask 1.1014 and the later sell fills at Bid 1.1024, gross P/L is 10,000 × (1.1024 − 1.1014) = $10. With a hypothetical $1 commission on each order, net P/L is $8. This isolated fill example is separate from the signal fixture above; it is not a platform backtest.
- The given fills already use Ask for the buy and Bid for the sell. Subtracting the same spread again would double-count that cost.
- Do not type 0.10 into both platforms and assume equal exposure. Verify the MT5 contract size and volume step, and the TradingView symbol quantity and point value.
- The example excludes swap, currency conversion, slippage beyond the assumed fills, and partial execution. Add each applicable cost with its actual units before comparing reports.
Migration acceptance checklist
Save a small audit table for the same timestamps on both platforms. Stop at the first mismatch and resolve it before comparing aggregate performance. A successful compiler check is only one acceptance condition.
| Gate | Evidence to save | Pass condition |
|---|
| Inputs | Provider, server, symbol, session, timezone, OHLC, and history start. | Both runs use the agreed data or every known difference is documented. |
| Signals | Signal timestamp, three prior highs/lows, close, flat state, and pending-entry state. | The breakout, equality, insufficient-history, and duplicate-entry cases match the written rule. |
| Order behavior | Request, acceptance, fill, and position-change timestamps; result codes and tickets. | Each expected entry and exit has the intended exposure, including rejected and partially filled requests. |
| Costs | Lot-to-unit mapping, price side, fees, spread treatment, and financing assumptions. | The $10 gross / $8 net fixture reproduces under its stated assumptions without charging spread twice. |
| Testing | Tick mode, Pine calculation/fill properties, date range, inputs, and holdout period. | Any divergent trade is explained; a matching final return alone is not accepted. |
Use Pineify for the chosen Pine implementation
Give the Pine Script AI Coding Agent your own rule specification, the breakout fixture, and the expected decisions. It can create or revise an editable Pine artifact; request a syntax check, then inspect the behavior in TradingView. The supported handoff here is explicit trading logic. It does not recover protected source, migrate an MT5 account, or execute trades.