Jump to content



Photo

Key reversal code


  • Please log in to reply
33 replies to this topic

#1 dcengr

dcengr

    Member

  • Traders-Talk User
  • 13,391 posts

Posted 27 January 2007 - 01:33 PM

This is the first cut at it, results are.. interesting.

The code first, so one knows how it works..

Basically, it says:

1. Price Close of this bar is less than Price Low of previous bar
2. Price High of this bar is higher than Price High of previous bar
3. Price Open of this bar is equal or greater than Price Open of previous bar
4. Price High of this bar is 52 week high
5. Short when conditions are met, hold until open of 2 bars later (ie short for an entire week)

That is all.

var Bar, trigger, white: integer;

InstallTimeBasedExit(2);
for Bar := 2 to BarCount - 1 do
begin
ApplyAutoStops(Bar);
if not LastPositionActive then
{ Entry Rules }
begin
if ((PriceClose(Bar) < PriceLow(Bar-1)) and (PriceHigh(Bar) > PriceHigh(Bar-1)) and
(PriceOpen(Bar) >= PriceOpen(Bar-1)) and
(PriceHigh(Bar) > Highest(Bar-1, #High, 52))) then
ShortAtClose(Bar, '');
end
end;

Results on SPX going back to 1995.. the trade system doesn't quite work that well (ie entries and exits). As the graph shows, it doesn't do a bad job of spotting IT tops, however.

Btw, it did not pick this week as a keyreversal.. because my dataset shows that the open was lower than the close of previous week. I'm not sure if that's correct.

Posted Image

Posted Image

Edited by dcengr, 27 January 2007 - 01:34 PM.

Qui custodiet ipsos custodes?

#2 arbman

arbman

    Quant

  • Traders-Talk User
  • 19,504 posts

Posted 27 January 2007 - 02:29 PM

Thanks for sharing, it looks like it picks well the swing tops or bottoms which are lower probability success trades at 42%, rather than the IT tops or bottoms, the IT turning points came not much later though and there is tremendous symmetry both at the tops and bottoms in terms of a secondary low or high. So, it looks like the key reversals marked the clear turn of the momentum in the recent history, rather than the actual price turn. I will conclude that we are in a choppy rise higher for Feb for the price high, I think I will be correct with my liquidity based analysis...

OTOH, I think despite the other central banks still playing the hard ball, the Fed will not change their rate policy on Tue for further tightening at all. I expect this to give a short term boost to the stocks and pressure the USD a bit. The leading indicators and the credit growth are already showing severe slow down, this last few months upticks in the economic indicators are just seasonal upticks within the ongoing slow down, imho. The housing is still sending stress signals since the uptick in housing is also a seasonal (spring) effect, not a recovery or bottoming yet. I predicted that the economy could get a boost for the winter back in Aug and it did.

The Fed does not meet in Feb, they have to send a clear message that they will not do anything crazy in March. The market will probably sell off into the March low and the economic reality should show up better in terms of too tight monetary policy. If in fact, the USD manages to bounce or stay stable in the next 2 months, the Fed will have every reason to cut after March, or May through Dec. It should boost the market and the housing into the election year in 2008...

I think it will be a brief bear market or correction from March until fall. I also predict now that there will not be a severe recession...

- kisa

Edited by kisacik, 27 January 2007 - 02:31 PM.


#3 airedale88

airedale88

    Member

  • Traders-Talk User
  • 1,708 posts

Posted 27 January 2007 - 02:30 PM

dc, opening prices have NOTHING to do with key reversal days. nor does needing a 52 wk high, or any time length high or low.
airedale

Outspeaks the Squire, "Give room, I pray,
And hie the terriers in;
The warriors of the fight are they,
And every fight they win".

Ring-Ouzel, England

#4 dcengr

dcengr

    Member

  • Traders-Talk User
  • 13,391 posts

Posted 27 January 2007 - 02:39 PM

Thanks for sharing, it looks like it picks well the swing tops or bottoms which are lower probability success trades at 42%, rather than the IT tops or bottoms, the IT turning points came not much later though and there is tremendous symmetry both at the tops and bottoms in terms of a secondary low. So, it looks like the key reversals marked the clear turn of the momentum in the recent history, rather than the actual price turn. I am conclude that we are in a choppy rise higher for Feb for the price high, I think I will be correct with my liquidity based analysis...

OTOH, I think despite the other central banks still playing the hard ball, the Fed will not change their rate policy on Tue for further tightening at all. I expect this to give a short term boost to the stocks and pressure the USD a bit. The leading indicators and the credit growth are already showing severe slow down, this last few months upticks in the economic indicators are just seasonal upticks within the ongoing slow down, imho. The housing is still sending stress signals since the uptick in housing is also a seasonal (spring) effect, not a recovery or bottoming yet. I predicted that the economy could get a boost for the winter back in Aug and it did.

The Fed does not meet in Feb, they have to send a clear message that they will not do anything crazy in March. The market will probably sell off into the March low and the economic reality should show up better in terms of too tight monetary policy. If in fact, the USD manages to bounce or stay stable in the next 2 months, the Fed will have every reason to cut after March, or May through Dec. It should boost the market and the housing into the election year in 2008...

I think it will be a brief bear market or correction from March until fall. I also predict now that there will not be a severe recession...

- kisa


I should make it clear.. it did not pick EVERY turn.. far from it. The weekly key reversal was only met a few times as the trades show. But of the ones that it picked, the IT top wasn't too far off, it seems.

I ran this through the Dow going back to 1929.. there were only about 20 such occurances.. again the IT top wasn't too far off most cases.. but this is not a system I would feel comfortable trading off of.

The sell-off in may.. that I believe was orchistrated by large traders. By the time the actual sell off occured, many were heavily short as evidenced by COT.

At this time, large traders are still heavily long. These guys are strong hands, so it would not surprise me to see choppy advancing action much like going into may 06, while they flip from long to short positions.

On the other hand, the gigantic leverage in futures and margin data suggests to me that too many are leaning too heavily to one side, and some unexpected news may get people scrambling for the door.

The classic sell-off in a bear market is not rapid declines, but slow dripping declines where people constantly add to their losing position, and the declines start to accelerate, culminating in a massive sell-off. This is something I would prefer to see from the bear point, as it signals a shift from bull to bear market.
Qui custodiet ipsos custodes?

#5 jmicou

jmicou

    Member

  • Traders-Talk User
  • 2,749 posts

Posted 27 January 2007 - 03:10 PM

dc, opening prices have NOTHING to do with key reversal days. nor does needing a 52 wk high, or any time length high or low.


airedale88,

I respectfully ask, what is the best definition of a key reversal? It seems that some definitions confuse it with outside formations.

One thing that does seem important is to put it into context, such as the condition of the internals, as well as to other indices.

regards,

jmicou

#6 dcengr

dcengr

    Member

  • Traders-Talk User
  • 13,391 posts

Posted 27 January 2007 - 03:20 PM

dc, opening prices have NOTHING to do with key reversal days. nor does needing a 52 wk high, or any time length high or low.


I welcome any other definition that I can back test. If there's a better definition one can put into the form I've written above, I'll share the results once I get it coded.

The above definition was provided by TheEnd, who started the thread below.

However, I would like to get a more "limited" definition of KEY REVERSAL.. ie not a more general definition. My thoughts are the rarer the occurance, the better the signals.. but I could be wrong. If I took out the definitin of the opening prices or 52 week high, then the occurance of key reversal is much higher.

dc, opening prices have NOTHING to do with key reversal days. nor does needing a 52 wk high, or any time length high or low.


airedale88,

I respectfully ask, what is the best definition of a key reversal? It seems that some definitions confuse it with outside formations.

One thing that does seem important is to put it into context, such as the condition of the internals, as well as to other indices.

regards,

jmicou


Putting it in context of the condition of the internals would be useful, if one could provide a definition for it that can be coded.
Qui custodiet ipsos custodes?

#7 Caduceus

Caduceus

    Member

  • Traders-Talk User
  • 230 posts

Posted 27 January 2007 - 05:36 PM

dcengr, If my understanding is correct you do not need to include #3 if you are following what The end suggested. This is what The end stated: No. No gap required and the high does not have to come on the first day of the week. (when defining a weekly Key reversal). Just a new high and a close below the lowest low of the previous week. That is a rare event. Do note that that high must be a new high for the move however. In other words, the weekly bar must make a higher high than the previous week but doesn't need to occur on the open of the week or on the first trading day of the week. Hope this helps, C,

#8 mdwllc

mdwllc

    Member

  • Traders-Talk User
  • 574 posts

Posted 27 January 2007 - 05:42 PM

dc, opening prices have NOTHING to do with key reversal days. nor does needing a 52 wk high, or any time length high or low.


airedale88,

I respectfully ask, what is the best definition of a key reversal? It seems that some definitions confuse it with outside formations.

One thing that does seem important is to put it into context, such as the condition of the internals, as well as to other indices.

regards,

jmicou





dcengr: I have some s/w that automatically calculates KRD's. It's definition of KRD is:



"A KRD sometimes occurs as the top or bottom day of a significant move in the markets. A top KRD will be colored red for the top half of the bar which will be green on the lower half. A bottom KRD will be colored red for the lower half of the yellow bar.



If a market is moving up, the KRD will open higher than the previous close, move higher and then close lower than the previous close.



If a market is moving down, the KRD will open lower, move lower and then close above the previous close. KRD’s tend to be more meaningful at lows than at highs.

When first programmed the KRD, they showed up all over the chart. Therefore, we put in a number of filters that got rid of most of the insignificant KRD’s. For example, a KRD will have to be the lowest low for the last so many days. We allowed some tolerance for the open to be allowed a small range relative to the previous close. Another filter is that a low KRD must be a yellow day. There were all so a few other filters. Of course everything we pointed out for a low KRD also applies to a high KRD.



With all of these filters working, when you see a KRD, it should be a red flag that the trend may have become exhausted. This is the first indication you can get. If it is followed by a color change, then it is time to tighten up stops.



I looked over my charts and, in my opinion, works better on commodities rather than indexes. However, the

dates for the DJIA are: 1/8/07, 1/3, 12/26/06, 12/7, 11/28, 11/20, 9/29, 9/21, 8/10, 8/4, 7/18, 7/7, 6/30, 6/28, 6/19, 6/14, 6/2, 5/24, 5/15, 5/1, 4/7, 3/21, 2/17, 2/6, 1/3, 12/15/05. For the S&P: 1/25/2007, 1/16, 1/10, 1/8, 1/3, 12/7/2006, 11/28, 11/9, 9/29, 9/21, 9/11, 8/10, 8/4, 7/27, 7/18, 7/7, 6/30, 6/28, 6/14, 5/30, 5/24, 5/19, 5/15, 5/1, 4/7, 3/8, 2/21, 2/8,1/25, 1/23, 12/27/2006. Sorry for the reverse date order, bu I was having to read them off my charts. Let me know if I can be of any help... Mike
Lead, Follow or Get Out of the Way...

Be Sure to Perform Your Own Due Diligence

#9 dcengr

dcengr

    Member

  • Traders-Talk User
  • 13,391 posts

Posted 27 January 2007 - 06:00 PM

Theres some general confusion here with the definition of Key Reversal Date, and whether the actual prices do a key reversal. I think some believe Key Reversals need to gap higher at the open, some believe it doesn't have to be new highs, etc etc. But lets stick to the "sensible definition" here.. a key reversal indicator should do just that, indicate IT trend change. Hence it makes more sense to me, to filter out more of Key Reversal type signals with other parameters, such that they actually do a decent job at being a Key Reversal (ie marking an IT trend change), as a more general definition clearly do not mark IT trend changes yet occurs more frequently. I have been looking at this from a weekly perspective, and it may make sense to look for such reversals on a daily bar, as some have suggested, with more stringent filtering parameters.
Qui custodiet ipsos custodes?

#10 The End

The End

    Member

  • Traders-Talk User
  • 740 posts

Posted 27 January 2007 - 06:14 PM

I stand by my thoughts on the definition of the key reversal. Maybe Mark wants to interject something on the matter. My definition is the same definition that Jim Curry works off of.
NONE of what I type should be taken as financial advice.