Pairs Trading

 

I would like to know you if there's a way to get on the same chart a ratio between the pairs ( for example eurusd / gbpusd ) ?


Thanks

 
See the MarketInfo instruction to get information from another pair : https://docs.mql4.com/common/MarketInfo
 
Jacques366:

thanks but my question was about how to make a chart with a ratio between two pairs and not to get the last or bid...

 

Use this:

https://docs.mql4.com/series


You'll need to choose do you want Open or Close value.


double iOpen( string symbol, int timeframe, int shift)


so,


string ratio = iOpen("EURUSD","M1",1)/iOpen("GBPUSD","M1",1);

//1 i "shift value", you need to use FOR statement to take all historical data...


I think that should do it...

Reason: