How to code if I want to Indicator or EA to get price info from another currency pair?

 

Hi guys,

I would like to know what code to use if I am attaching an indicator/EA to currency XXXXXX and would like the indicator to fetch the High/Low of nth candle of YYYYYY of the same time frame?

In simpler word for example I attach the indicator to an EURUSD chart 15min, and under certain condition, if criteria are met, it would fetch the High/Low of the 6th candle of USDJPY 15min?

Rgds,

 
iHigh and iLow
 
  1. Perhaps you should read the manual. Timeseries and Indicators Access - MQL4 Reference

  2. On MT4: Unless the current chart is that specific pair/TF referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4

    The function linked to, opens a hidden chart for the symbol/TF in question (if not already open,) thus updating history, and temporarily placing the symbol on Market Watch (if not already there,) so SymbolInfoDouble(symbol, SYMBOL_BID) or MarketInfo(symbol, MODE_BID) don't also return zero on the first call.

 

Hi Keith,


Thanks for the reply. I get the iHigh and iLow standard function of mql4. What I am asking is specifically how do you put it in code (as in into function code) such that when the mql4 program reach the function, it could get the iHigh/iLow that is of a another different currency pair. ie indicator or EA is on EURUSD chart, but the code is written such it can look up for the iLow/iHigh of all other currency specified pairs except EURUSD.


Thanks again for offering help.


Rgds,

Luxy 

Keith Watford:
iHigh and iLow
 
William Roeder:
  1. Perhaps you should read the manual. Timeseries and Indicators Access - MQL4 Reference

  2. On MT4: Unless the current chart is that specific pair/TF referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4

    The function linked to, opens a hidden chart for the symbol/TF in question (if not already open,) thus updating history, and temporarily placing the symbol on Market Watch (if not already there,) so SymbolInfoDouble(symbol, SYMBOL_BID) or MarketInfo(symbol, MODE_BID) don't also return zero on the first call.

Hi William,


Thanks for the tip. I will look into them and post up my problems as I am foreseeing quite a numbers of them along the way to code my own program. :) Have a nice day to you!


Rgds,

Luxy

 

You specify the symbol in the call so if you want to access other (then chart) symbol data just change the symbolname in the call.

It's actually the first parameter that you have to specify.

double  iHigh(
   const string        symbol,          // Symbol
   ENUM_TIMEFRAMES     timeframe,       // Period
   int                 shift            // Shift
   );
double high_audcad = iHigh("AUDCAD",PERIOD_D1,0);

Hardcoding symbolnames can produce problems between brokers if they use post or prefixes;

So you can also use:

SymbolName(position,1)

You can see this in action if you run this:

//+------------------------------------------------------------------+
//| loop through all symbols                                         |
//+------------------------------------------------------------------+
for(int i=0;i<SymbolsTotal(1);i++)
  {
   double high = iHigh(SymbolName(i,1),PERIOD_D1,0);

   Print("SYMBOL: ",SymbolName(i,1)," Found At: ",i);
   Print("High: "+(string)high);
   // Do Something...
  }
//+------------------------------------------------------------------+
 
Marco vd Heijden:

You specify the symbol in the call so if you want to access other (then chart) symbol data just change the symbolname in the call.

It's actually the first parameter that you have to specify.

Hardcoding symbolnames can produce problems between brokers if they use post or prefixes;

So you can also use:

You can see this in action if you run this:

Hi Marco,


This is exactly what I am searching for! You are God sent~~~!!! Thank you very much~!!! Hope you have a nice day too~!!! Thank you again for your help!


Rgds,

Luxy

Reason: