Help with CandleStick Pattern Coding

 

As you can see from the above image i use bollinger bands, my strategy involves having 2 point of candles touching the BB band and the candles between these 2 points should form an upside down "V", i am having trouble coding the V part, i use array maximum to find the highest close between the 2 points, the close of the green candles should be greater or equal to the next green candle till the highest point and from highest  point to candle zero, the close of red candles should be less than or equal to the next red candle, i tried using a loop but it didn't work, please help with this

Thanks in advance

 
I propose the following algorithm: extreme bars cross the indicator line, and between them all bars have a 'Low' price higher than the indicator line.
 
Vladimir Karputov:
I propose the following algorithm: extreme bars cross the indicator line, and between them all bars have a 'Low' price higher than the indicator line.

i did not understand you

 
Ahmad861 :

i did not understand you

Look at your drawing: the inverted V has two outermost bars - the left bar and the right bar.

 
Vladimir Karputov:

Look at your drawing: the inverted V has two outermost bars - the left bar and the right bar.

i got that part figured out, i used arraymaximum/arrayminimum of close from candle 1 to 50 stored in an int variable and i have a condition that checks if the close of that variable crosses the bb band array i had created, the hard part is coding the V, from the left bar to the lowest point, taking your screenshot as an example the right bar would be the big blue candle, candle 1 and the left bar would be candle 9 and the lowest close is candle 5, what i need is close[9]>=close[8] && close[8]>=close[7]........close[6]>=close[5] and close[5]<=close[4] && close[4]<=close[3]..........close[2]<=close[1], this is easy when i know the value of the left bar, but from candle 1 to 50 , the left bar could be any one of them, that's where im struggling, im sorry if i wasn't able to make you understand, I explained to the best of my abilities. 

Thank you.

 

Any answers please ?

 
The main question: Are you looking for a signal on the current (# 0) bar or on a bar that has finally formed (# 1)?
 
Vladimir Karputov:
The main question: Are you looking for a signal on the current (# 0) bar or on a bar that has finally formed (# 1)?

bar 1

 
Ahmad861 :

bar 1

The algorithm is as follows (I'll post the finished code a little later) - if the bar crosses the indicator line, then we remember the date for the indicator. If the bar has not crossed the indicator line, it starts counting how many bars have passed since the crossing. And so on until we find a new intersection.

 

Picture 1

Picture 1

 

Picture 2:

Picture 2

Reason: