I need to develop an indicator to seek for the second highest swing (it helps to discard unusual high points).
Was trying this (it works), but don't know if is an efficient way to do this.
if (CurrentBar < hT + 2) return; p1= -99999; p2= -99999; v1= 99999; v2= 99999; for (int x = 0; x < hT + 1; x++) { {if (myIndicator[x] < myIndicator[x + 1] && myIndicator[x + 2] < myIndicator[x + 1]) {if (myIndicator[x + 1] > p1) { p2=p1; p1=myIndicator[x + 1]; } else if (myIndicator[x + 1] > p2) { p2=myIndicator[x + 1]; } } } } a = p2;
Using Swing will be better? Can it be programmed to check for (user input) different highs (the third for example)? Perhaps I'm working in something already exists?
Thanks in advance,
Sergio
Comment