Download MetaTrader 5
To add comments, please log in or register
Have you found an interesting application? Publish it in Code Base - millions of traders will appreciate that!
Bert
28
Bert 2016.04.07 21:02 

In OnCalculate() I have a ArraySetAsSeries with reverse order

....
ArraySetAsSeries(open,false);
ArraySetAsSeries(high,false);
....

Then I want the Lowest Value over a specific range. I do this with:

x=low[iLowest(NULL,0,MODE_LOW,IdLastBullish-IdLastBearish,IdLastBearish)]

But this is not given me the correct value. I did a test for checking the program-line:

Alert (iLowest(NULL,0,MODE_LOW,16,12162));
Alert (low[iLowest(NULL,0,MODE_LOW,16,12162)]);
Alert (low[12178]);
Alert (low[12162]);

This gives me the values as shown in the attachment.

The red-arrow is the found value for low[12162] (plotted correctly by the program)
The green-arrow is the found value for low[12178] (plotted correctly by the program)
The blue-arrow is the found value for the lowest low in this range (plotted by the program)....?! Well this is ofcourse not the lowest low of this range.... but what I'm doing wrong??

I can't see what I'm doing wrong here..... :( Hope somebody gives me the light :D



Regards,

Fernando Carreiro
1428
Fernando Carreiro 2016.04.07 23:15  

Use "ArrayMinimum()" and not "iLowest()" in this case specifically! "iLowest()" works directly on the full history data (ordered as a Series Array), and not on the "low[]" array passed to the "OnCalculate()" function.

ArrayMinimum() - https://docs.mql4.com/array/arrayminimum

whroeder1
13590
whroeder1 2016.04.08 00:36  
RTFM

There is a difference between the arrays passed to OnCalculate (e.g. low[]) and the predefined variables (e.g. Low[])

To determine the indexing direction of time[], open[], high[], low[], close[], tick_volume[], volume[] and spread[], call ArrayGetAsSeries(). In order not to depend on default values, you should unconditionally call the ArraySetAsSeries() function for those arrays, which are expected to work with.



Bert
28
Bert 2016.04.08 08:01  

Thanks!


It works perfectly!!

x = low[ArrayMinimum(low,IdLastBullish-IdLastBearish,IdLastBearish)]


/
To add comments, please log in or register