# Indicators: Harmonic Pattern Finder V3 - page 2

13

Looking for help adjusting the values of the cypher pattern.  I've found in the code where the pattern is defined through a series of 14 integers.  I've extrapolated that the 14 numbers are as follows:

(1)Name 0=XA

(2)Name 1=AB

(3)Name 2=BC

(4)Name 3=CD

(5)Name 4=XAB

(7)Name 6=ABC

(8)Name 7=BCD

(8)Triangle XB

(9)Triangle BD

(10) Point X

(11) Point A

(12) Point B

(13) Point C

(14) Point D

Here is the code based on these for the cypher pattern:

0.382, 0.618, 0, 0, 0, 0, 0, 0, 0.786, 0.786, 1.13, 1.414, 0, 0

Can anyone help me understand how to adjust these numbers to get what I need out of them?  Currently the cypher pattern draws improperly.  To qualify as a cypher, Point B must reach the 0.382 fibonacci retracement of X-A but not close below the 0.618, Point C must reach the 1.272 fib extension of X-A but not close above the 1.41, and Point D must reach the 0.786 fib retracement of X-C.

Currently it appears 80%-90% of the cypher patterns this tool draws don't actually fit the criteria.  Most never reach a proper point D and many go well above the zone for point C.  Any help appreciated!!

13

note that above there is 14 numbers in the sequence but I used 8 twice so there is actually 15 in the code that I thought applied to the 14 number sequence....I may be wrong on those even applying to the 14 numbers....now I'm really lost
5738

jojo151579:
note that above there is 14 numbers in the sequence but I used 8 twice so there is actually 15 in the code that I thought applied to the 14 number sequence....I may be wrong on those even applying to the 14 numbers....now I'm really lost

The patterns are described by a structure of 18 doubles defined in "HPFMatcher.mqh":

```struct PATTERN_DESCRIPTOR
{
double            ab2xa_min;
double            ab2xa_max;
double            bc2ab_min;
double            bc2ab_max;
double            cd2bc_min;
double            cd2bc_max;
double            cd2xc_min;
double            cd2xc_max;
double            xc2xa_min;
double            xc2xa_max;
double            cd2ab_min;
double            cd2ab_max;
double            bc2xa_min;
double            bc2xa_max;
};```

So the variable names are pretty much explanatory; the first is the minimum accepted AB to XA ratio ("B must reach ... of XA"), the next is the maximum accepted ratio ("B must not touch ... of XA"), and so on. Because of this, it is not simple to make a change for the criteria "B must not close below ... of XA" to be checked as the matcher only uses highs and lows for calculations.

If you really want it, a possible way is to set the maximum ratio a little further down, say 0.618 + 0.1, alternatively the next harmonic level, and check in an ad-hoc filter whether or not the close-price really was above 0.618. Also note, that with the default indicator settings an 0.05 slack will be applied to this constraint which means that as long as the high/low on a B-point bar does not touch 0.668 the pattern will still be found. It is then up to you to verify the closing price criteria.

The pattern descriptor of Cypher ({0.382,0.618,0,0,0,0,0,0,0.786,0.786,1.13,1.414,0,0}) has

• ab2xa_min = 0.382
• ab2xa_max = 0.618
• cd2xc_min = 0.786
• cd2xc_max = 0.786
• xc2xa_min = 1.13
• xc2xa_max = 1.414

In plain English this means:

• B must reach the 0.382 XA retracement, but not touch 0.618
• D must reach the 0.786 XC retracement, but also reverse there
• C must reach the 1.13 XA extension, but not touch 1.414
So to have the matcher require a C point to reach the 1.272 extension simply change entry #11 from 1.13 to 1.27. Again, to change the maximum from a "cannot touch" to a "close below" is not that simple, and the same slack of 0.05 will be applied.

13

Andre Enger:

The patterns are described by a structure of 18 doubles defined in "HPFMatcher.mqh":

So the variable names are pretty much explanatory; the first is the minimum accepted AB to XA ratio ("B must reach ... of XA"), the next is the maximum accepted ratio ("B must not touch ... of XA"), and so on. Because of this, it is not simple to make a change for the criteria "B must not close below ... of XA" to be checked as the matcher only uses highs and lows for calculations.

If you really want it, a possible way is to set the maximum ratio a little further down, say 0.618 + 0.1, alternatively the next harmonic level, and check in an ad-hoc filter whether or not the close-price really was above 0.618. Also note, that with the default indicator settings an 0.05 slack will be applied to this constraint which means that as long as the high/low on a B-point bar does not touch 0.668 the pattern will still be found. It is then up to you to verify the closing price criteria.

The pattern descriptor of Cypher ({0.382,0.618,0,0,0,0,0,0,0.786,0.786,1.13,1.414,0,0}) has

• ab2xa_min = 0.382
• ab2xa_max = 0.618
• cd2xc_min = 0.786
• cd2xc_max = 0.786
• xc2xa_min = 1.13
• xc2xa_max = 1.414

In plain English this means:

• B must reach the 0.382 XA retracement, but not touch 0.618
• D must reach the 0.786 XC retracement, but also reverse there
• C must reach the 1.13 XA extension, but not touch 1.414
So to have the matcher require a C point to reach the 1.272 extension simply change entry #11 from 1.13 to 1.27. Again, to change the maximum from a "cannot touch" to a "close below" is not that simple, and the same slack of 0.05 will be applied.

Aweome!  Than you for the reply!  I figured setting a close below would pretty tough so I can skip that one (pattern is still valid if it goes abov ehte .618 just can't close above it so I can filter those myslef).  Changing the parameters to reach the 1.27 (C) and to reach the .786 but not stop there (I'll change the max to 0 as the pattern always goes past the .786 seeing as the .786 is the minimum and it is not required to reverse there so changing that I hope will fix that issue also)  I'll try these and update how it works.   Thanks!
13

Andre Enger:

The patterns are described by a structure of 18 doubles defined in "HPFMatcher.mqh":

So the variable names are pretty much explanatory; the first is the minimum accepted AB to XA ratio ("B must reach ... of XA"), the next is the maximum accepted ratio ("B must not touch ... of XA"), and so on. Because of this, it is not simple to make a change for the criteria "B must not close below ... of XA" to be checked as the matcher only uses highs and lows for calculations.

If you really want it, a possible way is to set the maximum ratio a little further down, say 0.618 + 0.1, alternatively the next harmonic level, and check in an ad-hoc filter whether or not the close-price really was above 0.618. Also note, that with the default indicator settings an 0.05 slack will be applied to this constraint which means that as long as the high/low on a B-point bar does not touch 0.668 the pattern will still be found. It is then up to you to verify the closing price criteria.

The pattern descriptor of Cypher ({0.382,0.618,0,0,0,0,0,0,0.786,0.786,1.13,1.414,0,0}) has

• ab2xa_min = 0.382
• ab2xa_max = 0.618
• cd2xc_min = 0.786
• cd2xc_max = 0.786
• xc2xa_min = 1.13
• xc2xa_max = 1.414

In plain English this means:

• B must reach the 0.382 XA retracement, but not touch 0.618
• D must reach the 0.786 XC retracement, but also reverse there
• C must reach the 1.13 XA extension, but not touch 1.414
So to have the matcher require a C point to reach the 1.272 extension simply change entry #11 from 1.13 to 1.27. Again, to change the maximum from a "cannot touch" to a "close below" is not that simple, and the same slack of 0.05 will be applied.

Got it working!  Changed the 1.13 to 1.27 and changed the second 0.786 to 1.000 (changing to 0 had disastrous results :) )   It works so much more accurately now!  Thanks for the code help.  Now I can make sense of all this stuff!    You're a life saver!  Happy holidays!
13

loving this indicator! (especially now that I can customize the fibo levels!)

If I want to set up a scanner to use this tool and automatically scan all the stocks listed in my market watch window, I assume I would have to create an EA correct?  I am not a coder...Is it required to know and be able to write code to build this EA?  I would want to say only search for a new cypher pattern in the last 150 bars or so.  This would be a saved setting that could be loaded as normal into the indicator.  Is this possible and easy to create or I am too wishful not being a coder?

Or maybe is there an easier way to load all the stocks into chart form at once and simply apply this tool?  Loading every stock one at a time to search through takes a lot of time!  (I'm new to MT all together so I have yet to work out all the kinks :)   )

Appreciate any input

Also, I have seen on the cypher pattern where the line from X to D shows the fibo retracement of XA...how would I change this to XC instead?   XA retracement only applies to point B and is irrelative to point D.  Thanks and awesome work!  (Sorry for all the questions too)

5738

jojo151579:

loving this indicator! (especially now that I can customize the fibo levels!)

If I want to set up a scanner to use this tool and automatically scan all the stocks listed in my market watch window, I assume I would have to create an EA correct?  I am not a coder...Is it required to know and be able to write code to build this EA?  I would want to say only search for a new cypher pattern in the last 150 bars or so.  This would be a saved setting that could be loaded as normal into the indicator.  Is this possible and easy to create or I am too wishful not being a coder?

Or maybe is there an easier way to load all the stocks into chart form at once and simply apply this tool?  Loading every stock one at a time to search through takes a lot of time!  (I'm new to MT all together so I have yet to work out all the kinks :)   )

Appreciate any input

Also, I have seen on the cypher pattern where the line from X to D shows the fibo retracement of XA...how would I change this to XC instead?   XA retracement only applies to point B and is irrelative to point D.  Thanks and awesome work!  (Sorry for all the questions too)

Seems like the newest version of MT has a feature to undock the charts. It is possible to open a chart for each stock, load the indicator, and minimize the chart until the next time it is needed. Still requires manually clicking through each window for searching though, but at least it's less cumbersome than loading the chart and indicator every time. MT does not have a built in scanner or features for this. It would require coding to make one, which could be done as a script btw.

The line from X to D is drawn using the same procedure for all patterns. More of a bug really that it doesn't take into account the specifics of Cypher (or the other patterns where the C-point exceeds the A for that matter), but it was never gotten around to.

To fix it for the Cypher, first add this line near line-number 880 in "HarmonicPatternFinderV3.mq5":

`string xcd=IntegerToString((int) MathRound(100*MathAbs(D-C)/MathAbs(X-C)));`

Then replace the current line-number 992 which reads:

`if(k!=FIVEO) ObjectSetString(0,name5,OBJPROP_TOOLTIP,prefix+_patternNames[k]+" XAD="+xad);`

into this:

```if(k!=FIVEO && k!=CYPHER)
else if(k!=FIVEO)
ObjectSetString(0,name5,OBJPROP_TOOLTIP,prefix+_patternNames[k]+" XCD="+xcd);```

This will add the most meaningful tooltip for confirmed patterns. To additionally have it on projections, do the same thing in the projection drawing procedure, i.e. add the first line at about line number 1130, and replace the current 1180.

13

Andre Enger:

Seems like the newest version of MT has a feature to undock the charts. It is possible to open a chart for each stock, load the indicator, and minimize the chart until the next time it is needed. Still requires manually clicking through each window for searching though, but at least it's less cumbersome than loading the chart and indicator every time. MT does not have a built in scanner or features for this. It would require coding to make one, which could be done as a script btw.

The line from X to D is drawn using the same procedure for all patterns. More of a bug really that it doesn't take into account the specifics of Cypher (or the other patterns where the C-point exceeds the A for that matter), but it was never gotten around to.

To fix it for the Cypher, first add this line near line-number 880 in "HarmonicPatternFinderV3.mq5":

Then replace the current line-number 992 which reads:

into this:

This will add the most meaningful tooltip for confirmed patterns. To additionally have it on projections, do the same thing in the projection drawing procedure, i.e. add the first line at about line number 1130, and replace the current 1180.

Thanks for the help again!  Unfortunately I copied and pasted all the above (entered the first code on line 881 and replaced the original line 992, compiled and restarted) and nothing changed.  It's not a big deal... I can trace out on my own if needed.  May have something to do with there being no zig zag line that goes from x to c to begin with.  Thanks for all the help!

Kind of figured a scanner would have to be written code...MT5 is great and terrible at the same time :).  Can't even get an xabcd drawing tool like tradingview has automatically built in...  Anyways, this indicator will still be great for backtesting.  I may just have to purchase a scanner one day (and when I find one that is not so darn expensive!)

5738

jojo151579:

Thanks for the help again!  Unfortunately I copied and pasted all the above (entered the first code on line 881 and replaced the original line 992, compiled and restarted) and nothing changed.  It's not a big deal... I can trace out on my own if needed.  May have something to do with there being no zig zag line that goes from x to c to begin with.  Thanks for all the help!

Kind of figured a scanner would have to be written code...MT5 is great and terrible at the same time :).  Can't even get an xabcd drawing tool like tradingview has automatically built in...  Anyways, this indicator will still be great for backtesting.  I may just have to purchase a scanner one day (and when I find one that is not so darn expensive!)

Yeah sorry for that **facepalm**, it must be done in "HPFDrawingObserver.mqh" instead, then add at line 300 replace line 410. Or you could just download an update which is pushed now fixing it for all patterns. If you only download the "HPFDrawingObserver.mqh" file it isn't even necessary to re-enter the modified pattern-descriptor for the Cypher.
13

Andre Enger:
Yeah sorry for that **facepalm**, it must be done in "HPFDrawingObserver.mqh" instead, then add at line 300 replace line 410. Or you could just download an update which is pushed now fixing it for all patterns. If you only download the "HPFDrawingObserver.mqh" file it isn't even necessary to re-enter the modified pattern-descriptor for the Cypher.
Oh ok.... thanks.....tried all the above too and no change. Still gives the info for XAD. Thanks anyways