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.
double BCD_Ratio = 0.886;
double Delta = 10;
double BCDMinRatio = BCD_Ratio-((BCD_Ratio/100)*Delta);
double BCDMaxRatio = BCD_Ratio+((BCD_Ratio/100)*Delta);
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.
m_XADMaxPrice = m_APointPrice+(XADMaxRatio*m_XPointPrice)-(m_APointPrice*XADMaxRatio);
m_XADMinPrice = m_APointPrice+(XADMinRatio*m_XPointPrice)-(m_APointPrice*XADMinRatio);
m_BCDMaxPrice = m_CPointPrice+(BCDMaxRatio*m_BPointPrice)-(m_CPointPrice*BCDMaxRatio);
m_BCDMinPrice = m_CPointPrice+(BCDMinRatio*m_BPointPrice)-(m_CPointPrice*BCDMinRatio);
m_PRZ_High = NormalizeDouble(MathMax(m_XADMaxPrice,m_BCDMaxPrice),5);
m_PRZ_Low = NormalizeDouble(MathMin(m_XADMinPrice,m_BCDMinPrice),5);
m_PRZ_High = NormalizeDouble(MathMax(m_XADMinPrice,m_BCDMinPrice),5);
m_PRZ_Low = NormalizeDouble(MathMin(m_XADMaxPrice,m_BCDMaxPrice),5);
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?
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.
To add comments, please log in or register