Topic: Two Candles Pattern"s"

footon again smile

My new idea :

compare HLC for two consecutive candles this gives many combinations
Some Scenarios:
A- using one combination only :
High[iBar - 1] > High[iBar - 2]
High[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > Close[iBar - 2]
Low[iBar - 1] > High[iBar - 2]
Low[iBar - 1] > Low[iBar - 2]
Low[iBar - 1] > Close[iBar - 2]
Close[iBar - 1] > High[iBar - 2]
Close[iBar - 1] > Low[iBar - 2]
Close[iBar - 1] > Close[iBar - 2]

B-Using Two Combinations:
High[iBar - 1] > High[iBar - 2] && High[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
High[iBar - 1] > High[iBar - 2] && High[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Close[iBar - 2]
Low[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Low[iBar - 2]
Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > High[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
Low[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Close[iBar - 2]
Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
Low[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
Close[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
Low[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
Close[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > High[iBar - 2]
Low[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
Close[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > Low[iBar - 2]
Low[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > Close[iBar - 2]
Low[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && High[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
Low[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > High[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
Low[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]

Using Three Combinations:
High[iBar - 1] > High[iBar - 2] && High[iBar - 1] > Low[iBar - 2] && High[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > High[iBar - 2] && High[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
Low[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > High[iBar - 2] && High[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > High[iBar - 2]
High[iBar - 1] > High[iBar - 2] && High[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && High[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
Low[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > High[iBar - 2] && High[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > High[iBar - 2] && High[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && High[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
Low[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > High[iBar - 2] && High[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && High[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
Low[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
Close[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > High[iBar - 2] && High[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Close[iBar - 2]
Low[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Close[iBar - 2]
Low[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
High[iBar - 1] > High[iBar - 2] && High[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
Low[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
Low[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > High[iBar - 2] && High[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
Low[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
Low[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > High[iBar - 2] && High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > High[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
Low[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
Low[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > High[iBar - 2] && High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > High[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
Low[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
Low[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > High[iBar - 2] && High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > High[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Close[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Low[iBar - 2]
High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
Low[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > Low[iBar - 2]
Low[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]

Up to Nine combinations :
High[iBar - 1] > High[iBar - 2] && High[iBar - 1] > Low[iBar - 2] && High[iBar - 1] > Close[iBar - 2] && Low[iBar - 1] > High[iBar - 2] && Low[iBar - 1] > Low[iBar - 2] && Low[iBar - 1] > Close[iBar - 2] && Close[iBar - 1] > High[iBar - 2] && Close[iBar - 1] > Low[iBar - 2] && Close[iBar - 1] > Close[iBar - 2]

Re: Two Candles Pattern"s"

I did that  manually using excel   you will find some of these combinations repeated but in different orders


But the idea is if we have an indicator comparing six different values only using > and <  we could find lots of winning combinations " or this is what i think "


Any ideas

Re: Two Candles Pattern"s"

Yeah, it's like a pre-defined pattern search engine.

It should be done like a matrix I think, writing all combos down might be extremely prone to error.

Do I understand it correctly that A scenario is the most simple one, the basis, and after that it just gets repeated?

4 (edited by ahmedalhoseny 2012-08-18 23:26:26)

Re: Two Candles Pattern"s"

yes its getting complicated when we add more combinations

but  my idea is to simplify that by only comparing 6 variables H1, L1, C1, H2, L2 ,C2

as i see some indicators compare more than point of reference lets have an example: price > Ma , Price< Ma, Ma > other Ma .... and so on

we donot need to hard code every possible combination " the combination scenarios i posted for demonstration only" and it should be calculated automatically by comparing the 6 points only
you got my idea!!!!

Re: Two Candles Pattern"s"

footon wrote:

Yeah, it's like a pre-defined pattern search engine.

Can I jump in here because at the moment I'm looking at different candle patterns and have concluded that a pattern of 9 bars works best for the strategy I'm using. Unfortunately the number of combinations is immense, a lot of the combinations always lose but there are several combinations that win more than they lose or lose more than they win but return a profit. It is a very long testing process and I would appreciate any ideas that I could use that would speed up the process.
Thanks
Mick

Re: Two Candles Pattern"s"

Jagmanmick wrote:
footon wrote:

Yeah, it's like a pre-defined pattern search engine.

Can I jump in here because at the moment I'm looking at different candle patterns and have concluded that a pattern of 9 bars works best for the strategy I'm using. Unfortunately the number of combinations is immense, a lot of the combinations always lose but there are several combinations that win more than they lose or lose more than they win but return a profit. It is a very long testing process and I would appreciate any ideas that I could use that would speed up the process.
Thanks
Mick

Mick, you are more than welcome to jump in!

Have you done the patterns the same way as Ahmed has done it in Excel? Can you give here one example of that 9bar pattern?

Only 2 combinations but tens of lines of code is not a good solution. I'm currently thinking about the best possible solution (best as within my coding capacity).

One more thing - what is the most basic part of any pattern? Is it High > High, High > Close etc? How many basic combos you deal with?

Thanks!

Re: Two Candles Pattern"s"

I'm looking at the patterns as white black (and doji) and basically I have coded each 9 bar pattern separately. To obtain the different combinations of Black and White I just let excel produce the binary coding for 9 bars as 1's and 0's and changed the 1's for W and 0 for B. I test each one individually using the HLCMA I modified and if it gives a good result I include it in my indicator.(Attached and still in progress) If it's possible to code it a different way please feel free to do it or let me know how and I'll have a go. I'm also experimenting with OHLC parameters in the iBar. We know the open is set but HLC are variables and moving as the price moves but we also know that as the price initially moves up High and Close are the same until the price recedes and conversely as the price initially goes down  Close and Low are the same until the price increases again. At that point when the Close pulls away from the High or Low I compare the difference with a set pip value between them and enter Long or Short. Unfortunately because everything in the iBar is time dependent back testing looks good but on further analysis of the bar data the results are flawed. Any ideas or comments would be appreciated.
Thanks
Mick

Post's attachments

A HLC Candle formation 9 Bars Moda.cs 45.24 kb, 54 downloads since 2012-08-19 

You don't have the permssions to download the attachments of this post.

8 (edited by Jagmanmick 2012-08-19 16:36:01)

Re: Two Candles Pattern"s"

Forgot to add I have found that the 5min timescale EURUSD gives the best results and all pairs have their own unique bar patterns that work best for them. What a complex world we live in. Realized I also use v2 of the HLCMA attached

Post's attachments

A High Low Close Moving Average v2.cs 29.58 kb, 50 downloads since 2012-08-19 

You don't have the permssions to download the attachments of this post.

Re: Two Candles Pattern"s"

That's one massive coding, Jag. Can I call you Jag?

Am I correct assuming that you have tested those patterns before, proved their profitability and then included them in the A HLC indi?

I did one simple indi (first try), which actually isn't an indi. I was thinking of exporting the values and results from FSB to excel. Then further analysis can take place - aligning types and results and porting better performing patterns to the "real" indi. Alignment would take place by using pattern-specific values. I'll try to get that far and see how it goes. Jag and Ahmed, any comments about my approach?

Ahmed, I think you have made some logical mistakes in your first post:

High[iBar - 1] > High[iBar - 2] && High[iBar - 1] > Low[iBar - 2]

If first part is true, there's no point in checking the second half as it is true as well, therefore it has no real sense. Or you think otherwise?

Re: Two Candles Pattern"s"

footon wrote:

That's one massive coding, Jag. Can I call you Jag?

Ahmed, I think you have made some logical mistakes in your first post:

High[iBar - 1] > High[iBar - 2] && High[iBar - 1] > Low[iBar - 2]

If first part is true, there's no point in checking the second half as it is true as well, therefore it has no real sense. Or you think otherwise?

Yes you are right footon , because iam using excel and have no time to remove the urological combinations so you will find some of combinations not logical at all even some will contradict themselves smile  this is the problem of manual editing

Re: Two Candles Pattern"s"

footon wrote:

That's one massive coding, Jag. Can I call you Jag?

Am I correct assuming that you have tested those patterns before, proved their profitability and then included them in the A HLC indi?

I did one simple indi (first try), which actually isn't an indi. I was thinking of exporting the values and results from FSB to excel. Then further analysis can take place - aligning types and results and porting better performing patterns to the "real" indi. Alignment would take place by using pattern-specific values. I'll try to get that far and see how it goes. Jag and Ahmed, any comments about my approach?

I answer to anything so yes. I have back tested those using TrueFx data going back to Jan 11 and those are the one's that have proven to be profitable over that period. I am slowly working through the list and add others when I find profitable ones. I test one long and one short pattern at a time on 3 currency pairs and note the win loss results on my table against each pattern adding the good ones to the indi. I use the HLCMA set as Bar Opens above the upper band after opening below  it and that is also the reason why all the long patterns Bar 1 is White and the Short Black.
Your idea sounds pretty good, will look forward to seeing the results.
Mick

Re: Two Candles Pattern"s"

Guys, I have a problem. My machine refuses to eat .xls format, do you know any good converters from .xls to .odt? I spent nearly 40 minutes to find a decent one but failed...

Re: Two Candles Pattern"s"

I did something similar to this to search for patterns. I found it helpful to convert the price differences (Close > Open) to an array of 1's and 0's (similar to Jagmanmick's spreadsheet above). It's a bit tricky to do the code to get sample from the binary array and match to a pattern, but after that, it's easy to enter new patterns as "1,1,0,0,1,0,1" etc. somewhere up at the top of the indicator.

Then you can do something like, instead of entering the patterns, tell it to get the first 9 bars's pattern, get results for that pattern; get bars 1-10 pattern, get results; then get bar 2-11, get results ... up to some meaningful cut off point, like the first quarter of your data. There is not much point in getting the 9-bar pattern in the last 20 bars -- if the pattern did not appear before that, the pattern will be tested against only 20 bars of data, not meaningful. This also avoids testing against a pattern that never occurs. I can't remember if I did this in the code or did it manually.

One problem I found was a lot of overlap, like "1,0,1,0,1,0" is very similar to "0,1,0,1,0,1", or "1,1,1,0,0,0" and "0,0,0,1,1,1". Also, with 9-bar patterns, a lot of them will overlap in the data, so it takes some logic to set it as "first come, first serve", or "go back for each pattern and test independently".

Re: Two Candles Pattern"s"

footon wrote:

Guys, I have a problem. My machine refuses to eat .xls format, do you know any good converters from .xls to .odt? I spent nearly 40 minutes to find a decent one but failed...

I saw one forum suggested rename from ".xls" to ".xslx" if it's a later version of Office. With the last Office release, they did some thing to turn them all into xml files or something. But I'm pretty sure there is an add in for OpenOffice to do this, I had to do it a few years back, I'll search for it.

Re: Two Candles Pattern"s"

I think it's for OpenXML, I found a link to something here:
http://sourceforge.net/projects/odf-converter/

But just to note -- I don't remember if that's the one I had success with, or if there's a later version or anything, might be good to do some searching on OpenXML for the latests.

Re: Two Candles Pattern"s"

I think it's better to make them 1's and -1's -- if you have a 0, that won't show up on a Histogram chart at the bottom; it would be some bars of height 1, with some empty areas. If it's -1, then the bar will point downwards. I'll see if I can make something for this.

Re: Two Candles Pattern"s"

Jagmanmick's idea and ahmedalhoseny's idea are different -- I'll focus on Jagmanmick's, it's closer to what I've done before.

Re: Two Candles Pattern"s"

Well, I guess I'm the first one to come up with what I built.

WARNING!
It gives system out of memory exception, it's the first time I've dealt with this kind of error, so I'm pretty clueless how to deal with it. All I can say that if bars < 10000 it works fine, sort of fine - no crashes at least.

It looks up 3 combination patterns, and that's the maximum actually. Let me explain - Ahmed, you did a lot of work compiling the patterns above, but most of them are logically incorrect as I reasoned previously. So, 9 base combinations means a theoretical 27 maximum 3 combo patterns, the limitation lies in the way the basic combinations are built up - if first is go-go-go, the other two are as well.

Reading the indi - the bar with the trade shows three numbers - first, second and third. That's the combination of the triggering pattern, you have to match the number to the matrix to figure out what pattern it exactly is. That's pretty straightforward.

Prototype like it is it kind of works, is it worth further developing? Can't answer that, lets see what Krog brings up.

But the coding part was fun for me, learned little valuable lessons, good music helped a lot though.

New version:http://forexsb.com/forum/post/16120/#p16120

Re: Two Candles Pattern"s"

Here's mine, it's only for if you're comfortable editing the indicator and recompiling. It figures if the bar is black (close lower than open) or white (close higher than open), you can type in patterns to test against.

- open in editor
- find CodePatterns at top
- follow guidelines in comments
When pattern is found, indicator draws a blue spike over histogram. Dynamic info will show which pattern was found as 0-based index (unfortunately will show a "-" if it's the first because the indicator components do that instead of 0).

Enter as 1 or -1, and it will convert to the opposite for shorts. If you enter "1,1,1,-1,-1,-1" (w,w,w,b,b,b) for long entry, it will also include "-1,-1,-1,1,1,1" (b,b,b,w,w,w) for short entry.

To test naturally occurring patterns, click the "Search Mode" box, set the Length parameter to how many bars you want in your pattern. Then, use the Index parameter to step forward. This takes a sample from your dataset and tests against that pattern and its opposite. If clicking the stepper takes too long, you can also use the Optimizer with it, I tried it a couple of times, it seemed to work. But then if you like the pattern, have to look at the  histogram to figure it out, I couldn't think of a way for it to display what the pattern is.

Mostly the same type of idea as Jagmanmick's, hopefully this approach saves some typing and makes the patterns easier to read. These are patterns of black - white bars, not comparing highs, lows and closes like ahmedalhoseny's idea.

Post's attachments

B W Patternator.cs 14.79 kb, 44 downloads since 2012-08-21 

You don't have the permssions to download the attachments of this post.

20 (edited by ahmedalhoseny 2012-08-21 09:24:58)

Re: Two Candles Pattern"s"

// number should 2 times how many code patterns you have
// eg, 4 patterns -  public int[][] aiCodes = new int[8][];
// eg, 2 patterns -  public int[][] aiCodes = new int[4][];
public int[][] aiCodes = new int[6][];

this means the indicator will search in three groups of candles combinations only , these three groups will written in the next part of code which is


// enter your patterns here
// patterns must be 1 or -1
// enter in order of complexity and preference; if simple codes come first, more complex patterns will not be found
// patterns can be different lengths
aiCodes[0] = new int[] {-1,1,-1,1,1,1,-1,-1,-1};     9 candles
aiCodes[1] = new int[] {1,1,1,1,1,1,1,1,1};           also 9 candles
aiCodes[2] = new int[] {1,-1,1,1,1};                      5 candles

and if we want to add a fourth candles combinations group lets say
aiCodes[3] = new int[] {1,1,1};   a three candles combination we have to change  int[6][]; to int[8][];

Am i right

Re: Two Candles Pattern"s"

krog wrote:

Enter as 1 or -1, and it will convert to the opposite for shorts. If you enter "1,1,1,-1,-1,-1" (w,w,w,b,b,b) for long entry, it will also include "-1,-1,-1,1,1,1" (b,b,b,w,w,w) for short entry.

Could you make it non directional indicator i mean for example "1,1,1" to be tested for buy and sell ,also"-1,-1,-1" to be tested for sell and buy  !!!!

Re: Two Candles Pattern"s"

ahmedalhoseny wrote:

// number should 2 times how many code patterns you have
// eg, 4 patterns -  public int[][] aiCodes = new int[8][];
// eg, 2 patterns -  public int[][] aiCodes = new int[4][];
public int[][] aiCodes = new int[6][];

this means the indicator will search in three groups of candles combinations only , these three groups will written in the next part of code which is


// enter your patterns here
// patterns must be 1 or -1
// enter in order of complexity and preference; if simple codes come first, more complex patterns will not be found
// patterns can be different lengths
aiCodes[0] = new int[] {-1,1,-1,1,1,1,-1,-1,-1};     9 candles
aiCodes[1] = new int[] {1,1,1,1,1,1,1,1,1};           also 9 candles
aiCodes[2] = new int[] {1,-1,1,1,1};                      5 candles

and if we want to add a fourth candles combinations group lets say
aiCodes[3] = new int[] {1,1,1};   a three candles combination we have to change  int[6][]; to int[8][];

Am i right

Hi ahmedalhoseny,
yes, that is right.

Most important point is that:

public int[][] aiCodes = new int[6][];

your number of patterns times 2; so, if you include another pattern, for aiCodes[4], change the "6" to "8".
If you take patterns out, remember to reduce the number.

It needs the multiply by 2 because the indicator automatically gets the inverse patterns for shorting:

// these patterns entered by user
aiCodes[0] = new int[] {-1,1,-1,1,1,1,-1,-1,-1};     9 candles
aiCodes[1] = new int[] {1,1,1,1,1,1,1,1,1};           also 9 candles
aiCodes[2] = new int[] {1,-1,1,1,1};                      5 candles

// indi automatically fills in the inverse patterns for shorting
aiCodes[3] = new int[] {1,-1,1,-1,-1,-1,1,1,1};     9 candles
aiCodes[4] = new int[] {-1,-1,-1,-1,-1,-1,-1,-1,-1};           also 9 candles
aiCodes[5] = new int[] {-1,1,-1,-1,-1};                      5 candles

If you get a "Index out of Bounds" error, check this section first, check how many patterns you have and the number in new int[6][]. When I was using this indicator, I often forgot to change it and had to go back and recompile several times. I'll be the first person to say -- be careful, this indicator is not very user-friendly !!

Re: Two Candles Pattern"s"

footon, krog thanks to you both will try them out.
Mick(Jag)

Re: Two Candles Pattern"s"

Thanks Krog
in your opinion How many aiCodes[]s we could add without hurting the speed of scanning
aiCodes[0] = new int[] 
aiCodes[1] = new int[] 
aiCodes[2] = new int[] 
aiCodes[3] = new int[] 
aiCodes[4] = new int[] 
aiCodes[5] = new int[] 
.
.
.
.
aiCodes[N!!!] = new int[]

Re: Two Candles Pattern"s"

Jagmanmick wrote:

footon, krog thanks to you both will try them out.
Mick(Jag)

Million thanks for footon and krog