Download MetaTrader 5

iLowest does not give the right shift...

To add comments, please log in or register
Follow the news. View our company's official channel!
Bert 2016.04.07 21:02 

In OnCalculate() I have a ArraySetAsSeries with reverse order


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


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


Fernando Carreiro
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() -

whroeder1 2016.04.08 00:36  

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 2016.04.08 08:01  


It works perfectly!!

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

To add comments, please log in or register