Migrating from PineScript to MQL5

 

Hello everyone,

I am attempting to transform a strategy on PineScript to an EA on MQL5. I have been facing difficulties mainly related to how candles are modelled between the two: open, high, low, and close prices in the candles of Tradingview do not match those of MT5, even though data from the same broker is used in both.

From what I found, the differences may be due to the following reasons:

1) Tradingview models candles as averages between bid and ask, whereas MT5 models the bid price only

2) For some brokers, Tradingview assumes that the opening of a candle is EXACTLY the same as the close of the previous day, ensuring continuity and smoothness from candle to candle with no gaps

I have attempted to "transform" Tradingview candles to MQL5 by taking into consideration the above two points. Yet, I am still not able to exactly match the open, high, low, and close prices in both.  

Has anyone else been struggling with this same issue? What other causes (other than the above 2) might be behind this discrepancy?

Thank you,

Karim 

Reason: