Maximum & Minimum index
Maximum & Minimum index
12 Feb 2020, 14:26
Hi,
Is there a way to get the index of Maximum/ Minimum of given period, say 100 bars?
Thanks
Replies
vladimiroskyrkimtzis
12 Feb 2020, 22:01
RE:
PanagiotisCharalampous said:
Hi vladimiroskyrkimtzis
Try Minimum and Maximum functions. See below an example
Bars.HighPrices.Maximum(100);
Best Regards,
Panagiotis
Efxaristo Pano,
I am actually trying to establish the exact index in which the Max/Min occur. For example the functions you suggest will give me the Max price in the last 100 bars, but in which bar? Last 40th? Last 35th?
Hope there is an easy method to do this,
Vladimiros
@vladimiroskyrkimtzis
PanagiotisCharalampous
13 Feb 2020, 08:40
Hi Vladimiros,
It seems I did not read your question well :) There is no built in function for this, you will need to write it yourself. Here is an example for finding the index for the maximum
private int IndexOfMax(DataSeries series, int noOfBars)
{
double maximum = series[0];
int maxIndex = 0;
for (int i = 1; i < noOfBars; i++)
{
if (series[i] > maximum)
{
maximum = series[i];
maxIndex = i;
}
}
return maxIndex;
}
Best Regards,
Panagiotis
@PanagiotisCharalampous
vladimiroskyrkimtzis
13 Feb 2020, 11:14
RE:
PanagiotisCharalampous said:
Hi Vladimiros,
It seems I did not read your question well :) There is no built in function for this, you will need to write it yourself. Here is an example for finding the index for the maximum
private int IndexOfMax(DataSeries series, int noOfBars) { double maximum = series[0]; int maxIndex = 0; for (int i = 1; i < noOfBars; i++) { if (series[i] > maximum) { maximum = series[i]; maxIndex = i; } } return maxIndex; }
Best Regards,
Panagiotis
Hi again,
Many thanks for clarifying and the suggested code, it works fine for my purpose!
Have a nice day.
Vladimiros
@vladimiroskyrkimtzis
PanagiotisCharalampous
12 Feb 2020, 14:41
Hi vladimiroskyrkimtzis
Try Minimum and Maximum functions. See below an example
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous