Issue pulling in data from other currency pairs

 
Hi everyone,

I'm trying to have my EA read in open, high, low, close information for the current daily candle from other currency pairs, but the data it shows seems to be completely wrong. 

In fact the data for the pair I am running the EA on is also incorrect if I use the currency name in the iLow statement for example iLow("GBPUSD",PERIOD_D1,0);

However it does give me the correct data if I use NULL in the iLow statement such as iLow(NULL,PERIOD_D1,0);

I'm using a Print statement to show the values in the log and it's about a 30 pip difference to what I see on the charts in my terminal. It is connected to a live demo account.

Does anyone know what the reason for this could be? Is this s broker data issue or coding issue?

Also, I've tried running the EA in strategy tester, on a terminal where I have the fxt daily history files available for all pairs. It doesn't work here either. In this case it gives the same value for open, low, high and close! a value which is not even correct for either of them! Anybody why this could be?

I'm going round in circles with it if anyone has any advice would be much appreciated!

Thanks
 
Is this MQL4 or MQL5?

It may sound strange, but try storing the symbol name in a variable first, then call the iLow with the string variable
 

 Thanks for getting back to me. 

I'm using MQL4.

 I've just tried placing in a variable and doesn't seem to work either. So now I'm using..

string GBPUSD = "GBPUSD";

iLow(GBPUSD,PERIOD_D1,0); 

This is still giving me incorrect values. However if I use iLow(NULL,PERIOD_D1,0); then I get the correct values. Really strange!.. I'm wondering if it's an issue where it's pulling the data from? any other ideas mate?

 
No probs James

One final question: Is the problem occurring when you're trading live or during backtesting?
 
This is trading live on a Roboforex demo account.
 
James Parker:
This is trading live on a Roboforex demo account.
Hmmm OK, would need to see your code to debug further mate. MT4 can be pretty temperamental when it comes to multi timeframe and multi currency EAs & indicators. You can put it up here as an attachment or if you'd prefer to protect it, feel free to PM it to me and I'll have a look. 
 
Stuart Browne:
Hmmm OK, would need to see your code to debug further mate. MT4 can be pretty temperamental when it comes to multi timeframe and multi currency EAs & indicators. You can put it up here as an attachment or if you'd prefer to protect it, feel free to PM it to me and I'll have a look. 

Ok mate I can paste some of the code in here. I was only running a simple Print statement at this stage to test a few pairs see if I can read the data in correctly.

 

string GBPUSD = "GBPUSD";

string EURUSD = "EURUSD";

string AUDUSD = "AUDUSD";

string USDJPY = "USDJPY";

   double GBPUSD_low = iLow(GBPUSD,PERIOD_D1,0);

   double EURUSD_low = iLow(EURUSD,PERIOD_D1,0);

   double AUDUSD_low = iLow(AUDUSD,PERIOD_D1,0);

   double USDJPY_low = iLow(USDJPY,PERIOD_D1,0);

         Print("GBPUSD Low = ",GBPUSD_low);

         Print("EURUSD Low = ",EURUSD_low);

         Print("AUDUSD Low = ",AUDUSD_low);

         Print("USDJPY Low = ",USDJPY_low);


It's just strange that it's giving me some data but not the same as I see on the charts. If I run the following it does give me the correct data that I see on the pair that the EA is trading.

    double GBPUSD_low = iLow(NULL,PERIOD_D1,0);

         Print("GBPUSD Low = ",GBPUSD_low); 

 

Could it be to do with it being a demo account? The symbols all have a ".m" after the names, so for example "GBPUSD.m", would that make a difference to what I need to write in the string? 

 
James Parker:

The symbols all have a ".m" after the names, so for example "GBPUSD.m", would that make a difference to what I need to write in the string? 

Bingo!
 
Stuart Browne:
Bingo!

Awesome!.. yes that seems to have worked!

Thanks for the help! 

 
James Parker:

Awesome!.. yes that seems to have worked!

Thanks for the help! 

Welcome mate
 
Still having trouble with this in the strategy tester though. Do you use tickstory data by any chance?

I'm wondering in strategy tester are you able to pull values from other currency pairs without any issues?

When I use the same code, it gives me a same value for all of the open, low, high and close on a different currency pair! Even if I run a different statement iHigh, iLow, iClose etc I get the same value. I get the correct values from the chart the EA is being tested on, but not from any others. Can't think where it's going wrong!...