So there is a certain number of bars

I want to write a logical expression in such a format that if 3 bars are placed in the height of the first bar then do so-and-so.

The condition as we can see is fulfilled here there are 3 bars that are placed in the height of the 1st bar so I did not screw up. I need to count the number of elements that appear in this condition. You can do this in 2 ways to calculate the date of the first element (1st element under the number 1) and calculate the date of the last element (under the number 4) but how to do this I do not know. After calculating the dates, you can count the number of elements between them using the Bars function and, as I understand it, return the number. The second way is to count the number of elements using the ArrayRange array function, but in this case you need to declare an array and somehow pass the data from the condition to the array. Who can help you determine the dates or pass data from the condition to the array in order to eventually count the number of elements in the condition in order to use it later?

## seric29

Some say that it counts from left to right but if I understand the help correctly it counts from right to left starting from the 0th bar. From your example I need to compare with the 1st element in the fifth with 6 but this is no problem there is a problem with how to count the number of elements used in the condition, for example I recorded 6T bars in the condition how do I calculate this number which is equal to 6T or return the date of the first element and the last which is for example below or above the range to also count the number of them in this example, their 7m 6 in and after fulfilling the conditions outside one how to count them?

## mvs

First you need to learn the basics, and then start programming

When you learn the basics, then you can use:

`double low = iLow(NULL,PERIOD_M15,iLowest(NULL,PERIOD_M15,MODE_LOW,CountBsr,1));`

double high = iHigh(NULL,PERIOD_M15,iHighest(NULL,PERIOD_M15,MODE_HIGH,CountBsr,1));

Well, compare in the right bar, which should fit the channel