help on a High-Low Routine

 

Hello.

I want help about a problem on a High-Low Routine.

I have write the following one that works excellent on MQL5:

bool FindHighLow(string Pair, int Periods)
{
   double PHigh[], PLow[];
   ArrayResize(PHigh, Periods);
   ArrayResize(PLow, Periods);
   if (CopyHigh(Pair, PERIOD_M1, 1, Periods, PHigh) < Periods) return (false);
   if (CopyLow(Pair, PERIOD_M1, 1, Periods, PLow) < Periods) return (false);
   high = NormalizeDouble(PHigh[ArrayMaximum(PHigh)], digits);
   low = NormalizeDouble(PLow[ArrayMinimum(PLow)], digits);
   return (true);
}

But when I use this in a MQL4 EA it return false and close EA with message "Initialization Failed (32767)"!!

Can anybody help me???

Thanks.

 

can you please explain what are you trying to accomplish

can't you use iHighest and iLowest ?

 

Hello and thanks for your answer.

I'm searching 2 thinks:

1st with above procedure I want find highest and lowest values of pairs of currency (Using procedure 2 times) for a specific period (for ex. 25000 minutes).

2nd Using the every minute high and low of every one of pairs I want to find the maximum difference of them in the specific period.

The problem seems to be that CopyHigh and CopyLow don't copy the prices to arrays. Can you help me about?

Again Thanks for your help and sorry for my English!!

 
why do you want to copy them if you already have them (High[] And Low[])
 

Do you mean that in MQL4 there are arrays ready that had High and low prices of any pair on any TF?????????????????? That's excellent!!! In MQL5 you must use CopyHigh and CopyLow to make this arrays!!! How can I select the pair, TF and total of Period that I want???

Thanks

 

I just read about these arrays and I see that give you only current chart's data :(

But I check and your previous notes (about iHighest and ILowest) and I think that they will help me! I think that they don't have a command to copy them automatically to an array but I must using a loop to do it.

 
   double high = 0, low = 0;
   string Pair = Symbol();
   int Periods = 25000;
   high = iHigh(Pair, PERIOD_M1,iHighest(Pair,PERIOD_M1,MODE_HIGH,Periods));
   low = iLow(Pair,PERIOD_M1,iLowest(Pair,PERIOD_M1,MODE_LOW,Periods));
 

Thank you very much!!! That's exactly what I want!! But I need and the array of them that I will use frame per frame to find the maximum difference between pairs. As I wrote above I will use a loop for it except if you have another way!

Thanks again! You are great!!

 
don't understand, why do you need the array ? don't you ned the value ?
 
I need, for any minute bar from 0 to 25000, the max difference between the prices of the 2 pairs (ex. if pair1 price > pair2 price I want the: pair1 High price - pair2 Low price). Finally I want the max of these differences!
 
chronisb:

Hello and thanks for your answer.

I'm searching 2 thinks:

1st with above procedure I want find highest and lowest values of pairs of currency (Using procedure 2 times) for a specific period (for ex. 25000 minutes).

2nd Using the every minute high and low of every one of pairs I want to find the maximum difference of them in the specific period.

The problem seems to be that CopyHigh and CopyLow don't copy the prices to arrays. Can you help me about?

Again Thanks for your help and sorry for my English!!


I've tested your code as it looked right to me and guess what ? The arrays were correctly re-sized and data was indeed copied into the array but...

only if the array size was 1000 or less. Starting at 1001, the array re-size worked - printed out 1001 - but no data was copied into the array.

It appears that there are some limitations, not sure why.

Try it, set your Periods to 1000, test it and then above 1000 and let us know if it's true.

Hope it helps

Reason: