Map the execution model first
Pine evaluates a script across dataset bars and re-executes the realtime bar as updates arrive. MQL4 dispatches terminal events to an EA, custom indicator, or script. The conversion must state when each signal becomes final and which event owns it.
A Pine indicator usually maps to an MQL4 custom indicator with buffers and OnCalculate. A Pine strategy usually maps to an Expert Advisor, but TradingView simulated orders do not map one-to-one to broker OrderSend, OrderModify, and OrderClose calls.
| Pine concept | MQL4 target | Conversion question |
|---|---|---|
| indicator() and plot() | Custom indicator and buffers | Which values and styles are drawn? |
| strategy.entry / exit | EA trade state machine | How are fills, stops, and ownership modeled? |
| Series history operator | Timeseries shift | Is current or closed bar intended? |
| request.security | Cross-symbol/timeframe functions | How are gaps and alignment handled? |
