# Indicators: Harmonic Pattern Finder V2 - page 5

5843

So David,

I've been trying out your idea of a purist PRZ, must say I like it. Thought you might find it interesting so I'm posting a code-snippet which you can copy-paste in under line 802. This will not make the projected point D be the first ratio or the PRZ stop be the last ratio. Instead it will filter out the patterns which are there only for the holist and not the purist i.e. does not contain all ratios in the PRZ.

```               //--- Purist PRZ must contain the exact ratios
if(true)
{
if(cd2bcConstraint)
{
bool contained;
if(startsInTrough)
{
double nearRatio=C-pattern.cd2bc_min*BC;
double farRatio=C-pattern.cd2bc_max*BC;
contained=nearD>=farRatio && nearRatio>=farD;
}
else
{
double nearRatio=C+pattern.cd2bc_min*BC;
double farRatio=C+pattern.cd2bc_max*BC;
contained=nearD<=farRatio && nearRatio<=farD;
}
if(!contained)
continue;
}
{
bool contained;
if(startsInTrough)
{
contained=nearD>=farRatio && nearRatio>=farD;
}
else
{
contained=nearD<=farRatio && nearRatio<=farD;
}
if(!contained)
continue;
}
if(cd2xcConstraint)
{
bool contained;
if(startsInTrough)
{
double nearRatio=C-pattern.cd2xc_min*XC;
double farRatio=C-pattern.cd2xc_max*XC;
contained=nearD>=farRatio && nearRatio>=farD;
}
else
{
double nearRatio=C+pattern.cd2xc_min*XC;
double farRatio=C+pattern.cd2xc_max*XC;
contained=nearD<=farRatio && nearRatio<=farD;
}
if(!contained)
continue;
}
if(cd2abConstraint)
{
bool contained;
if(startsInTrough)
{
double nearRatio=C-pattern.cd2ab_min*AB;
double farRatio=C-pattern.cd2ab_max*AB;
contained=nearD>=farRatio && nearRatio>=farD;
}
else
{
double nearRatio=C+pattern.cd2ab_min*AB;
double farRatio=C+pattern.cd2ab_max*AB;
contained=nearD<=farRatio && nearRatio<=farD;
}
if(!contained)
continue;
}
}```

You can also replace the "true" in the parantheses of line 2 above with a variable like "InpPuristPRZ" and declare the variable as an input if you want to switch purist PRZ mode on/off in the settings. Interval ratios are checked by mere overlap, or that some part of the interval is in the PRZ (instead of just slack).

Regards,

André

215

Hi Andre,

I downloaded the files and installed alexstal_outsidebar in the "Include" folder. I then saved the alexstal_ZZprof, swingchart, fastzz and Harmonic Pattern Finder V2 in the \MQL5\Indicators\Example folder.

I closed the platform and once it was opened again I dragged the Harmonic Pattern Finder onto the chart. In the Experts tab I get the following message:

The indicator is loaded on the EU and XAG chart.

Regards Eckbert

Files:
215

Eckbert Gevers:

Hi Andre,

I downloaded the files and installed alexstal_outsidebar in the "Include" folder. I then saved the alexstal_ZZprof, swingchart, fastzz and Harmonic Pattern Finder V2 in the \MQL5\Indicators\Example folder.

I closed the platform and once it was opened again I dragged the Harmonic Pattern Finder onto the chart. In the Experts tab I get the following message:

The indicator is loaded on the EU and XAG chart.

Regards Eckbert

Hi Andre, managed to sort the problem out. Created a new Downloads folder and everything is OK.

Thanks Eckbert

20

Hi Andre,

Is it possible to use this indicator into an EA?

I am using the icustom with all the input parameters but I can't access the buffers necessary to detect peaks and troughs

and the most importante the buffer with points A, B, C and D

Is there any EA with an example?

5843

João José:

Hi Andre,

Is it possible to use this indicator into an EA?

I am using the icustom with all the input parameters but I can't access the buffers necessary to detect peaks and troughs

and the most importante the buffer with points A, B, C and D

Is there any EA with an example?

Hello João,

It is possible to use the code in an EA but that would require modifications unless you write an EA that interprets the objects drawn on the chart. I have not seen an EA based on it to provide an example but can give you my opinion on it.

Firstly, if considering going for an approach with copying of buffers, be aware that only double typed arrays are sharable through ICustom(). This means that you would need one array for each of the points, times that for each of the patterns. So suddenly you would need to have 4*18=72 buffers just for the AB=CD patterns, and twice that number for both projected and active patterns. Not to mention continuous reprocessing of these arrays to avoid "old" patterns confusing the receiving EA, and the information which goes lost like the PRZ stop (but that can be fixed with yet another buffer for each pattern). Even though it might be possible to do while keeping under the platform's limit of 512 shared buffers, it is not what most sensible programmers would have done.

Arguably a better approach is to incorporate parts of the indicator code directly in an EA to avoid the limitations of iCustom().This way you can delegate memory for each matched and projected pattern in an easy way, and also better track patterns as they develop. Needless-to-say that requires refactoring the pattern matching sections of the code (starting from "//--- main loop" at line 408) in such a way that it does not go and draw the patterns but instead provide information of them to other parts of the EA.This might involve some details like removing drawing specific functionality and keeping overhead to remove duplicates, but is the primary change needed to have a basic "matcher" that can be queried in the code to find patterns, after which trading orders can be sent.

172

Very nice indicator.. I think the best on the web. Have you considered to implement the elliott waves pattern in this indicator ? It could be really interesting with the projections....

20

Andre Enger:

Hello João,

It is possible to use the code in an EA but that would require modifications unless you write an EA that interprets the objects drawn on the chart. I have not seen an EA based on it to provide an example but can give you my opinion on it.

Firstly, if considering going for an approach with copying of buffers, be aware that only double typed arrays are sharable through ICustom(). This means that you would need one array for each of the points, times that for each of the patterns. So suddenly you would need to have 4*18=72 buffers just for the AB=CD patterns, and twice that number for both projected and active patterns. Not to mention continuous reprocessing of these arrays to avoid "old" patterns confusing the receiving EA, and the information which goes lost like the PRZ stop (but that can be fixed with yet another buffer for each pattern). Even though it might be possible to do while keeping under the platform's limit of 512 shared buffers, it is not what most sensible programmers would have done.

Arguably a better approach is to incorporate parts of the indicator code directly in an EA to avoid the limitations of iCustom().This way you can delegate memory for each matched and projected pattern in an easy way, and also better track patterns as they develop. Needless-to-say that requires refactoring the pattern matching sections of the code (starting from "//--- main loop" at line 408) in such a way that it does not go and draw the patterns but instead provide information of them to other parts of the EA.This might involve some details like removing drawing specific functionality and keeping overhead to remove duplicates, but is the primary change needed to have a basic "matcher" that can be queried in the code to find patterns, after which trading orders can be sent.

Thank you, I'll try the second approach (and yes, it will be only for D points at AB=CD patterns)
20

João José:

Thank you, I'll try the second approach (and yes, it will be only for D points at AB=CD patterns)

Andre,

I decided to go on the first approach.

Just after you call the function DisplayPattern, I added 9 new buffers to store A, B, C, D and bull/bear. And some more adjustments for defaults

5843

danizani95:

Very nice indicator.. I think the best on the web. Have you considered to implement the elliott waves pattern in this indicator ? It could be really interesting with the projections....

Thanks for the feedback.

As far as I'm aware, Elliot waves are not harmonic by themselves, it is a more loosely defined theory of wave structures. Elliot waves have three successively higher tops before two lower bottoms (buy at second bottom), and various compositions and classifications on how this may occur. Some technical analysts seem to believe, the relation between harmonics and Elliot waves is that the X-A segment should correspond to the Elliot impulse phase, and the ABCD part correspond to the Elliot correction. Therefore different harmonic patterns, like the Gartley and the Bat, are different manifestations of the same elliot phenomena.

Adding Elliot wave markers to the indicator is of less use, as the some of the patterns themselves are full Elliot waves. One thing I've considered though in a new version is a filtering mechanism which makes it easy to add user defined filters to the pattern finder. It is then quick to add say an "Elliot wave filter" which removes those harmonic patterns where there is no finer-scaled impulse structure in the XA leg. This could be detected for instance by checking if a ZigZag on a lower timeframe has three successive higher tops.

Regards

5843

João José:

Andre,

I decided to go on the first approach.

Just after you call the function DisplayPattern, I added 9 new buffers to store A, B, C, D and bull/bear. And some more adjustments for defaults