How do I get the index of the return value of dataSeries.highest / dataSeries.lowest?

xerol

Active member
Joined
Apr 6, 2022
Posts
30
Likes
7
Hi everyone,

Is there a way or workaround to check the index of highestCloseValue or lowestCloseValue except iterating over the whole series again and comparing the CLOSE values? I need to know which of the values occurred first in the specific sequence.

Java:
double highestCloseValue = dataSeries.highest(startIndexA, periodX, Enums.BarInput.CLOSE);
double lowestCloseValue = dataSeries.lowest(startIndexA, periodX, Enums.BarInput.CLOSE);

Greetings
 
Last edited:
Not exactly sure your overall goal but a different way of doing it is as follows:

Java:
private float highestCloseValue=0, lowestCloseValue==Float.MAX_VALUE, curClose;

protected void calculate(int index, DataContext ctx) {
        
    ...
    
    var series = ctx.getDataSeries();
            
    // store the current close value
    curClose = series.getClose(index);

    // store off the highest and lowest close values for use later
    if (curClose > highestCloseValue) {highestCloseValue = curClose;}
    if (curClose < lowestCloseValue) {lowestCloseValue = curClose;}
    
    ...
 
Thank you for your input. I ended up iterating a second time over the dataSeries between startIndexA and (startIndexA + periodX) and just checking which of them occurred first.
 
Hi everyone,

Is there a way or workaround to check the index of highestCloseValue or lowestCloseValue except iterating over the whole series again and comparing the CLOSE values? I need to know which of the values occurred first in the specific sequence.

Java:
double highestCloseValue = dataSeries.highest(startIndexA, periodX, Enums.BarInput.CLOSE);
double lowestCloseValue = dataSeries.lowest(startIndexA, periodX, Enums.BarInput.CLOSE);

Greetings
I think that highestBar / lowestBar function in /com/motivewave/platform/study/general/Utility.java (MotiveWave_Studies.zip Sdk) is what you are looking for. It return the price and is bar_index.
 
Top