I loop from the bar previous to the current bar to the origin of the chart to detect the first change in trend but it doesn't work as expected...
My code
for (index = 0; index < Count-1; index++)
{
if ( Open[index] ==Close[index+2] && Close[index] < Open[index] && Open[index] == Open[index+1] && Close[index+1]>Close[0])
{
TP = index+1;
break;
}
}
In the image you can see that the two rightmost green peaks display the necessary decline to reach the last peak where the change in trend took place while the two peaks on the left are false.
However, when I extract the data from the chart to test it in an app that I developed in Delphi, everything is correct.
Furthermore, when I want to add a configuration to my test to only detect peaks where the Close is > close of the current bar, nothing is displayed and I get the following error message:
Error on calling 'OnBarUpdate' method on bar 16: You are accessing an index with a value that is invalid since it is out-of-range. accessing a series [barsAgo] with a value.
However, I have enough bars on my graph
My condition is
if ( Open[index] ==Close[index+2] && Close[index] < Open[index] && Open[index] == Open[index+1] && Close[index+1]>Close[ 0])
Thank you for your help, your advice, finally anything that will allow me to solve my problem ;-)

Comment