highest and lowest

 
double uhigh=High[Highest("EURUSD",30,MODE_LOW,1,1)];
on a audusd chart gives me the high of audusd not eurusd..
(real time)
 
oldman,

Really? But your code seems complex and confused to me. The following code produces the same result:

double uhigh = iHigh("EURUSD", 30, 1);

You should use "Highest" function if you intend to get the shift of the maximum value over a range of periods. MODE_LOW is generally used with "Lowest" function, not "Highest".

Best Regards
 
and maybe because of High[] function that call high of the active chart

iHigh(("EURUSD",30,Highest("EURUSD",30,MODE_LOW,1,1));
 
 
//or
      highest  =Highest("EURUSD",30,MODE_LOW,1,1);
      highestpt=iHigh("EURUSD",30,highest);
 

Sorry i did do wrong on that mode stuff in "double uhigh=High[Highest("EURUSD", 30, MODE_LOW,1,1)];"
and I had changed the 1 after the mode from 100 to test it and did not change it back... I was trying to get the high of the last 100 bars of eurusd.. and it returned the high of audusd cause it was on the aud chart... it would not cross or something. .. ihigh is different.. it will give you the high of a specific bar..
also the "Highest" returns an array which you need to use "High[]" to pick the high out of the array that is returned.. but the point is, it did not work. High[] might be the culprit because it evidently returns the current chart. .. so how are you supposed to get the low or high of the last 100 bars of a currency pair that is not the chart you are on?

double ulow= Low[Lowest("EURUSD",30,MODE_LOW,1,1)];
double uhigh=High[Highest("EURUSD",30,MODE_HIGH,1,1)];
double bidd =MarketInfo("EURUSD",MODE_BID);


Comment("high=" + uhigh + " low = " + ulow + " " + bidd);
returns "high=0.7759 low=0.7553 1.2789"
(marketinfo() seems to work)

 
oldman:

Sorry i did do wrong on that mode stuff in "double uhigh=High[Highest("EURUSD", 30, MODE_LOW,1,1)];"
and I had changed the 1 after the mode from 100 to test it and did not change it back... I was trying to get the high of the last 100 bars of eurusd.. and it returned the high of audusd cause it was on the aud chart... it would not cross or something. .. ihigh is different.. it will give you the high of a specific bar..
also the "Highest" returns an array which you need to use "High[]" to pick the high out of the array that is returned.. but the point is, it did not work. High[] might be the culprit because it evidently returns the current chart. .. so how are you supposed to get the low or high of the last 100 bars of a currency pair that is not the chart you are on?

double ulow= Low[Lowest("EURUSD",30,MODE_LOW,1,1)];
double uhigh=High[Highest("EURUSD",30,MODE_HIGH,1,1)];
double bidd =MarketInfo("EURUSD",MODE_BID);


Comment("high=" + uhigh + " low = " + ulow + " " + bidd);
returns "high=0.7759 low=0.7553 1.2789"
(marketinfo() seems to work)

 
// lowest value within bar 1 to 100
double ulow= Low[Lowest("EURUSD",30,MODE_LOW,100,1)];
 
I still did not have that 100 in there did i? sorry... it really is in there. and it works in real time but not in the tester. anyway, I went another way with

double EurUsd[];
ArrayCopySeries(EurUsd,MODE_CLOSE,"EURUSD");

and ran through the last 100 bars of the series to find the high and low. (skipping the current one)
I hope the below is correct.. it is running..


int i;
int ulow=3;
int uhigh;
for(i=1; i<101; i++) {
if(EurUsd[i]>uhigh) {uhigh=EurUsd[i];}
if(EurUsd[i]<ulow) {ulow=EurUsd[i];}
}
 
I would suggest you are better off using the iHigh(..) and iLow(..) functions; unless you do want to find the highest and lowest of close prices.
In either case, you need to protect for lack of data. A test begins with having only a single bar, and in that case, and for several subsequent EA invocations, there isn't the 100 prior bars to investigate.
 
Perhaps more helpful, I would suggest a code snippet for finding the highest price as follows
double EurUsdHi[]
int nHi = ArrayCopySeries( EurUsdHi, MODE_HIGH, "EURUSD" );
double uHigh = 0.0;
if ( nHi < 2 ) {
    // Not enough bars, but we do expect at least one bar
    uHigh = EurUsdHi[ 0 ];
} else {
    uHigh = EurUsdHi[ ArrayMaximum( EurUsdHi, MathMin( 100, nHi - 1 ), 1 ) ];
}
and then the similar snippet for determining the lowest.

There is still the potential problem that the accessed EURUSD series is not loaded, in which case ArrayCopySeries sets the error code to 4066 (and, I guess, returns 0). The function call will trigger a loading to happen, but there is of course no way of saying how long that will take. It would be sensible to add code to deal with the situation, e.g., as per https://docs.mql4.com/array/ArrayCopySeries

Also note the following paragraph from https://docs.mql4.com/series (my underlining):
"At the testing, price data of the same symbol but of another timeframe are modelled exactly, with the exception of volumes. Volumes of another timeframe
are not modelled. Price data of other symbols are not modelled, either. In all cases, the amount of bars in time series is modelled exactly."

By the sounds of it, you will always have difficulties in backtesting.

regards
Reason: