Retrieving calculations from multiple pairs, not based on other indicators

 

Hey guys, I've been looking at several examples of code but not quite what I've been looking for. The problem is mine is so simple and the others are so complex.

I have an indicator which runs a calculation based on current/past price and stores the final value in a buffer, which is printed as a line (i.e. RSI).

I would like my indicator to run this calculation on several currency pairs and return i.e. text listing the pairs which 1) has the greatest value, and 2) has the least value....basically ranked in order.

An alternative would be to plot the indicator lines from all the currency pairs on one screen (like an multi-line index). The timeframe is the same for all pairs.

 

I've attached my progress so far. Would appreciate any help

Files:
mix.mq4  3 kb
 
peepingtom:

I would like my indicator to run this calculation on several currency pairs and return i.e. text listing the pairs which 1) has the greatest value, and 2) has the least value....basically ranked in order.

I've attached my progress so far. Would appreciate any help 

So far you have no progress. You haven't stated what your problem is.

RTFM. To get other pair data you must use iClose, ArrayCopySeries, or ArrayCopyRates.

You could make the CI with multiple lines and multiple pairs. You could make it with one line and use an external variable to select which pair.

 

"Hey guys, I've been looking at several examples of code but not quite what I've been looking for. The problem is mine is so simple and the others are so complex.Interpretation: I cannot figure out how to achieve what I want. I described what I had so far and described what I wanted to achieve. What I attached is the amount of the indicator that I WAS able to figure out. Is that not clear enough as the 'problem'? Anyway, doesn't matter.

Okay, I was thinking iClose and Symbol() usage but ArrayCopy is new concept to me. Is there a similar indicator around here that I could use an example to work from? I am a visual learner.

Like, in the documentation it gives this example:

 double array1[][6];
  ArrayCopyRates(array1,"EURUSD", PERIOD_H1);
  Print("Current bar ",TimeToStr(array1[0][0]),"Open", array1[0][1]);

 How would I go about making it retrieve data from X number of bars ago?

Thanks

 
peepingtom:


Okay, I was thinking iClose and Symbol() usage but ArrayCopy is new concept to me. Is there a similar indicator around here that I could use an example to work from? I am a visual learner.

 How would I go about making it retrieve data from X number of bars ago?
string  PriceToStr(double p){   return( DoubleToStr(p, Digits) );              }
///////////////
#define ACR_TIME     0  // Array Copy Rates
#define ACR_OPEN     1
#define ACR_LOW      2
#define ACR_HIGH     3
#define ACR_CLOSE    4
#define ACR_VOLUME   5
    #define ACR_COUNT   6
double array1[][ACR_COUNT];
int      GetBars(){                 return( ArrayRange  (array1, 0   ) );  }
int init(){
    // https://forum.mql4.com/36470/page2 says ArrayCopyRates is a non-
    // reentrant, non-thread-safe call. Therefor you must put a mutex around
    // the call in case of multiple EAs on multiple charts. Alteratively,
    // since init() is single threaded across all charts, put all ACRs there.
    ArrayCopyRates(array1,"EURUSD", PERIOD_H1);
}
int start(){
  Print("Current bar ",TimeToStr(array1[0][0])       ,"Open",            array1[0][1]        );
  Print("6 hours ago ",TimeToStr(array1[6][ACR_TIME]),"Open", PriceToStr(array1[6][ACR_TIME])); // Self documenting

 
Ahh okay, I see. This should give me something to start from. Thanks!