I have created a solution, using an array of pointers and node objects.

Seems to work in this basic sample version. It only builds then looks for overlaps in a very inefficient way. But for my purposes I think it will work.

**Files:**

intervalsearchi_2_.zip 15 kb

Im working with harmonic PRZ logic. I project areas of price using fib ratios +/- a delta. So a BCD fib ratios of 0.886 would return both a max and min price for that ratios projection as price.

So for each Harmonic pattern I will have a XAD and a BCD projection to create the basis of a PRZ. Combine this with ABCD projections and each pattern could have a number of overlapping zones inside a PRZ. The PRZ can be defined with simple use of MathMin and MathMax to find which are the bordering maximum and minimum prices.

This results in an cluster of zones with a high and low price level, especially when I project BAT, ALT BAT, BUTTERFLY, CRAB and GARTLEY ratios onto a single PRZ. In fact this produces two PRZs, one for the standard pattern and one for the extended patterns such as the ALT BAT.

PROBLEM: How do I efficiently search for confluence (overlapping) of these zones? I would like to rebuild the zones as probability areas, probability would be calculated on pattern frequency, probable outcome and the confluence on an area with other patterns.

In my search to resolve a coding solution, I came across tree data structure in MQL5s. As I have both a High and Low prices, the need to find overlapping data, the obvious choice (INHO) is the Interval Search Tree. I searched and found only a MQL5 binary search tree class called CTree (CTreeNode with CObject). Found here.

Im looking at the code, thinking that it could be converted into a MQL4 interval search tree. Am I barking up the right tree? Has anyone else found a similar solution? Is there a simpler solution?