3 candle pattern (down/up/up bars and vice versa)
Author: neowaver
Creation Date: 2/6/2009 4:28 PM
profile picture

neowaver

#1
I've been looking at 5 minute charts to augment my Elliot Wave analysis and a friend suggested this little trick that is helpful. I'd like to backtest it but I just downloaded Wealth Lab and took a class in C programming in 1992 so I can forget that being useful. I used Tradestation 15 years ago and it was a good deal easier and intuitive. I opened up the coding and I have no idea what it is saying at this time.

If anyone can provide this simple script for the code (that's greek to me without hours of reading)it might help you also, so if someone undertakes this task, feel free to post it publicly.

There is a both a buy system and a sell system based on candles bars on a 5 minute timeframe.

To view the chart, up bars are hollow and down bars are colored.

BUY criteria:

Bar 1 = down (colored) bar
Bar 2 = up bar (not colored) making a lower low than Bar 1
Bar 3 = up bar (not colored)that closes higher than the opening price of Bar 1


NOTE: it does not matter if bar 3 also makes a lower low than bar 1

---------------

Sell criteria

Bar 1 = up (non colored) bar
Bar 2 = down bar (colored) making a higher high than than Bar 1
Bar 3 = down bar (colored) that closes lower than the opening price of Bar 1


In both systems if the criteria is met it's a buy/sell with a tight stop above bar 2's high/low.

NOTE: It does not matter (that I know off yet)if bar 3 also makes a higher high or a lower low than Bar 1. It just needs to be a bar that has reverse candle color from Bar 1 and closed with regard to the rules for each one

If anyone can write that up in a few minutes and post the code it would be quite nice of you and I hope you can integrate it into your own trading also.


Thanks,
Mike Walsh
profile picture

Cone

#2
1. Is Bar1 before Bar3 in time, or vice-versa?
2. What's the definition of "up bar (not colored)"? Is it a doji candlestick that closes higher than the previous bar?
3. Is this strictly buy/sell long positions, or is the sell trigger actually a short trigger?
4. If this is long and short, besides bar 2 stop, what are the exit criteria?
profile picture

neowaver

#3
QUOTE:


1. Is Bar1 before Bar3 in time, or vice-versa?



Yes, Bar1 is before Bar2. But it does not matter what happens before Bar1. The signal is triggered by a comparison of three bars. So for a buy signal the logic (without using names as I don't know the terms) written one way is as follows:

1- Is Bar3 (which would be the current bar) an up bar?
2- Is Bar2 an up bar?
3- Is Bar1 a down bar?
4- Is the low of Bar2 lower than the low of Bar1?

(if all are affirmative the next question is asked)

5- If close of Bar3 (the latest one in time) is greater than the opening price of Bar1 then buy at the market.

A sell would have the reverse logic.

QUOTE:


2. What's the definition of "up bar (not colored)"? Is it a doji candlestick that closes higher than the previous bar?



The definition of an "up bar" is that the close of the bar is higher than the open of the bar (no color using Active Trader Pro).Questioning if it is an up bar is the first criteria in an by itself. Bar3 (the latest) must be an up bar and Bar1 must be a down bar else the further comparisons stop as no signal can be given.

The definition of a "down bar" is that the close of the bar is lower than the open of the bar (colored in ATP)and an "up bar" is that the baar closes higher than it opened.

QUOTE:


3. Is this strictly buy/sell long positions, or is the sell trigger actually a short trigger?



It is both a long and a short signal. I realize it can be made more complicated but this is just to trigger that the market performed a "buy formation" or a "sell formation". My exit will be based on what I am looking at with reagard to wave movements.

QUOTE:


4. If this is long and short, besides bar 2 stop, what are the exit criteria?



Yes, it is long/short. The exit rules can be completely left out for now if it is too complicated to write. But if there is a way for me to change a value in the code to exit the trade at dollar value objectives, that would be great to have as a variable.

I'm primarily trading DXD and would want to test exiting at various dollar values as wave structure has too many facets to it to be programmed. This is primarily a system where the trader then needs to use his experience with wave movement to decided to exit. But using a dollar value would be great to get an idea of the percenatage of times you are started off profitable.

So one could assume the extry price, if all criteria were met, is the close of Bar3. Setting a stop (in a buy signal) below the low of Bar2 and also being able to enter various dollar values to exit at a profit would at least tell me how often the market gave the signal and the next move was profitable or not.


As I say, I just loaded up Wealth Lab. If there is another funtion available in Wealth Lab that allows me to set the exit rules seperately on a dollar value that's already built in that would be perfect as the system would jusst geenerate the signal and be simple to write (if one knows the code, which I don't).

I hope this made sense. It's really an amazing little signal. A trader I know who is successful year-after-year told me to look at this on a 5 minute time frame, but also on 15min, 30min, and 60min. I have looked at the longer time-frames but they rarely occur and aren't much use for day trading.

If you have Active Trader pro I can pick out a few days and the time on a 5 min chart of DXD (Powershare 2x Dow) and show you what I mean, or I can e-mail you an illustration if I wasn't clear.

Thank you,
Mike Walsh

p.s. If the formation isn't clearly explained I can e-mail you a file with the formation illustrated if you send me a message with your e-mail address.
profile picture

Eugene

#4
CODE:
Please log in to see this code.
profile picture

neowaver

#5
Thanks Eugene...I just logged on and will get to it later tonight and get back to you.

MW
profile picture

neowaver

#6
Hi Eugene,

I got it running (compiled and results given) and it looks like you have it written so it is always in the market with reversals taken when a reverse signal comes in as I see an exit on top of a new position. Is that correct?

Something is a bit off with the patterns and I'll study the code and try to follow it's reasoning as to why some trades are taken that don't qualify and get back to you later.

UPDATE: I fixed the code. It looks like the last criteria (that on a buy signal the close of "Bar" is > open of Bar-2) was omitted. (reverse reasoning for a sell).


I'll stick to DXD (Proshares 2x inverse of DOW)for testing as that is what I have primarily traded. Is there a way to tell it to take either a profit at a variable that I insert in the code ($1 for example) or exit (assuming a buy signal) if the low of bar2 is broken? Knowing that would tell me how often the system signals a change in trend. Put simply, when the signal is given it would tell me the probability of the next move being a profitable $1 move or a losing trade.

Thanks,
MW
profile picture

neowaver

#7
Eugene,

Here is what I put in that looks to be correct as I look at the patterns and trades taken..

buyCondition = ( Close[bar-2] < Open[bar-2] ) & ( Close[bar-1] > Open[bar-1] ) &
( Low[bar-1] < Low[bar-2] ) & ( Close[bar] > Open[bar] ) & ( Close[bar] > Open[bar-2] );

sellCondition = ( Close[bar-2] > Open[bar-2] ) & ( Close[bar-1] < Open[bar-1] ) &
( High[bar-1] > High[bar-2] ) & ( Close[bar] < Open[bar] ) & ( Close[bar] < Open[bar-1] );

Can a 2nd system be run where if there is an open position it can be told to take a $1 profit or a $1 loss, whichever occurs first?

This is a system that needs a human to overide trades. I'm pretty good at looking at wave theory and there are times when a move up, for example, has sideways action that is corrective and the market needs to make a new high on that move. I see where this takes some trades while the market is going nowhere and that's where I feel the weakness is in any system. The best trades looking at this pattern are reversals at the end of a move where the mkt has extended itself in a direction and is about to make a significant retracement of at least 38%.

Is there a link that you'd recommend reading up on the way the code is written so I can start trying to implement some other ideas?

Thanks,
MW
profile picture

Eugene

#8
QUOTE:
I got it running (compiled and results given) and it looks like you have it written so it is always in the market with reversals taken when a reverse signal comes in as I see an exit on top of a new position. Is that correct?

Yes, it was coded as a SAR system which, of course, can be changed hands down.

QUOTE:
Here is what I put in that looks to be correct as I look at the patterns and trades taken..

CODE:
Please log in to see this code.

This was the only difference from my code above. Note that it:
1) makes the long/short signals asymmetric.
2) is not in line with your spec. (Since bar1 precedes bar3 as you say, but Wealth-Lab lives by the reverse method.)

QUOTE:
Can a 2nd system be run where if there is an open position it can be told to take a $1 profit or a $1 loss, whichever occurs first?

Yes, using the Sell*/Cover*/Exit*+AtStop/AtLimit commands.
profile picture

neowaver

#9
Hi Eugene,

I have a general rule for things. I will try for an hour before asking a simple question that I know is right in front of me as I don't want to be a PITA. Well I've gone snow blind missing what is assuredly right in front of me.

I want to open the strategy and look at it. From your comment above I think I made a correction on one half only. Here's what I think it should be, which should make the buy and sell conditions exact opposites. But I can't tell if I entered it wrong in the system or just in the post. In both cases, the last criteria for a trade has to do with the close of the last bar that would generate a signal compared to the open two bars before it. In a buy, the close of the bar must be higher than the open of bar-2. In a sell, the close must be lower than the open of Bar-2.

I wrote above under the sellcondition as the last criteria:
QUOTE:

( Close[bar] < Open[bar-1] );


It should be ( close[bar] < Open[bar-2);

The last criteria is a comparison of the last examined bar's close to bar-2's open in both cases.

I don't know if that was a typo here or if I wrote it that way in the system. I suspect that latter as I think I copied-and-pasted it into the message. It should be the following:

CODE:
Please log in to see this code.


That should be symetrical in that it should be the exact reverse of each other.

Thank you,
MW
profile picture

Eugene

#10
Hi,
QUOTE:
I don't know if that was a typo here or if I wrote it that way in the system. I suspect that latter as I think I copied-and-pasted it into the message. It should be the following:

Looks like you're absolutely correct with the Close being higher/lower than the Open of [bar-2]. When we see "Bar1", bar-1 automatically comes to mind, which is after Bar3. That was the source of mistake (now fixed, thanks). Please adopt the WealthScript convention of bar numbering as soon as possible (just kidding) :-)
profile picture

neowaver

#11
QUOTE:


Looks like you're absolutely correct with the Close being higher/lower than the Open of [bar-2]. When we see "Bar1", bar-1 automatically comes to mind, which is after Bar3. That was the source of mistake (now fixed, thanks). Please adopt the WealthScript convention of bar numbering as soon as possible (just kidding) :-)



I will get to it immediately. Now, how do I open just the system to do it?

Life was easier before bifocals! :)

Thanks,
MW
profile picture

Eugene

#12
QUOTE:
Now, how do I open just the system to do it?


Not sure what do you mean?
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).