# System exits



## nizar (29 July 2007)

Does anybody here have a system that shuts off:

*when the index passes below a certain point ? (eg. moving average).

*Or when maxDD reaches a certain point?

Or any other parameter that causes the system to switch off?

Did this enhance results in backtesting and/or actual trading?

Some discussion would be appreciated.


----------



## wayneL (29 July 2007)

Jose Silva had a market breadth filter that worked on the AD line. Thats about all I know though... google pegasus trading, that might yield some ideas.


----------



## weird (29 July 2007)

Nizar, my 2 cents,

One of the more interesting short-term trading switches, and used by some successful short-term traders that I am aware of,  is using an MA or EMA of the system's equity curve. This could also be applied to longer-term systems.

I have done some 'basic' testing in this area, however I am still battling in properly coding this for my particular application in this area (still a WIP ... because my Equity Curves are flat during non trading periods, and these bars would be part of an MA calculation within my code !), so I unable to comment much further at this time.

Concerning switches in general, the benefit of such a switch, may only be obvious in hindsight, and using insufficent statistics to develop and make assumptions about the usefulness of such a switch (particularly in its future use).

On another note, but further to the discussion of long term trading, one switch or filter, that often comes up in these types of discussions is the Coppock Indicator.

http://www.incrediblecharts.com/technical/coppock_indicator.htm


----------



## tech/a (29 July 2007)

There are 2 clearly defined parameters here Nizar.

(1) Switching a system off when it performs outside the numbers it generates particularly at the top end of Deviations from the mean of Montecarlo analysis.

(2) Switching a system off with a filter of some sort.
I have tested a few switches and have many Id like to test.
(1) I have tried a Relative Strength Comparison between the Universe I am trading and the All Ords.While this did improve results it also killed Nett return due to TAX issues.
(2) Id like to try R/S V Universe Im using and stocks in my portfolio.
(3) Then there is trading the/your equity curve.
(4) Jose's A/D line is a proven technique as I orgininally discovered in 
"The Encyclopedia of Technical Market Indicators by Colby"

When trading longer term methods these filters generally shorten hold time and in doing so cause TAX problems unless of course their arent introduced until after 12 mths holding.---Havent tried that either.

Stevo Doesnt BUY any new positions if certain INDEX conditions arent met.

There are literally zillions of ways to filter a portfolio.
One thing I liked was to sell a portfolio at/near a top then re buy the whole portfolio identical to the one you sold at a low.

Ie sell at the top of a wave 3/5 buy back at a wave 4/1 of an index or Custom index of your universe of stocks or custom index of your portfolio.
Ive done quite a bit of work with *Custom Indexes *with which you can compare relative strength with.

Here are 2 Custom indexes I have.
The left chart is Techtrader.
The right 50 Small Uranium Miners.

The right chart tends to kick the Resourse theory of on going and stronger than other sectors in the head!!

Chart 2 is a comparison between Large Caps on the left with Small Cap uranium miners on the left.

As you can see endless things you can do with Filters.


----------



## nizar (29 July 2007)

Wayne, weird, thanks for your responses.
I'll be looking into Jose Silva's technique. He seems a bit of a MS/Tradesim guru.



tech/a said:


> One thing I liked was to sell a portfolio at/near a top then re buy the whole portfolio identical to the one you sold at a low.





Tech, thanks for your response, but for the quote above, i think this is beyond me, as this will rely on my discretion to try and pick the top and then try and pick the bottom. Dont really think i have the skill (or luck!) to be able to do so successfully.

And who says those same stocks are going to up again??


----------



## It's Snake Pliskin (29 July 2007)

nizar said:


> Tech, thanks for your response, but for the quote above, i think this is beyond me, as this will rely on my discretion to try and pick the top and then try and pick the bottom. Dont really think i have the skill (or luck!) to be able to do so successfully.
> 
> And who says those same stocks are going to up again??




Red: this is for fools and fools get burned.
Lime: exactamento! this is where I see the limitations with *assumptions* and the assumption that system trading works because of BACKTESTS.


----------



## R0n1n (29 July 2007)

How about an ATR based traling stop ? Works very well.


----------



## It's Snake Pliskin (29 July 2007)

> When trading longer term methods these filters generally shorten hold time and in doing so cause TAX problems unless of course their arent introduced until after 12 mths holding.---Havent tried that either.



Yes an issue.



> There are literally zillions of ways to filter a portfolio.



At the expense of ruining something in the process - issues galore.


----------



## theasxgorilla (29 July 2007)

It's Snake Pliskin said:


> Lime: exactamento! this is where I see the limitations with *assumptions* and the assumption that system trading works because of BACKTESTS.




What are the alternatives?  Its the best we've got to work with, isn't it??  The future is not the past but it is derived from it...there's a connection.  Inspite of people saying (assuming) history repeats, I don't agree with that...in my eyes (thankfully) it doesn't!

What allows one to make the assumption that the discretionary method they're using works?  The person who gave it to you was successful?  How do you know they weren't just lucky?  Have you been successful?  How do you know you weren't just lucky too?  ("you" is not YOU Snake...can be anybody).

ASX.G


----------



## weird (29 July 2007)

Nizar, 

A few more thoughts, not sure of your trading method, however concerning long term trading, I trade 2 weekly systems (which use quite different methodologies). And the entries are often long between, and so is the holding period. 

Usually I trade about 10 stocks at one time. Also I don't usually have the ‘luxury’ of picking stocks using a discretionary method, because there are not too many to choose from ! 

The conditions to trigger an entry, are not "extraordinary", but it is a very bullish indication for that stock, regardless of the market conditions. That is, not simply picking a stock because it simply above an MA.

I am not saying that my systems are not influenced by the broad market, because the equity curve often follows most of the troughs and peaks, however it does comfortably outperform the index.

For long term 'long' systems, the obvious filter in backtesting, would be to include some sort of broad market condition. I would agree in especially backtesting random or very simple systems, this would most definitely improve the results (and also in more advanced systems), however this does not mean that "all" long term systems would necessarily benefit from such filters. That is, also look at additional individual stock filtering, and this could even be compared to the broad market.


----------



## It's Snake Pliskin (29 July 2007)

theasxgorilla said:


> What are the alternatives?  Its the best we've got to work with, isn't it??  The future is not the past but it is derived from it...there's a connection.  Inspite of people saying (assuming) history repeats, I don't agree with that...in my eyes (thankfully) it doesn't!
> 
> What allows one to make the assumption that the discretionary method they're using works?  The person who gave it to you was successful?  How do you know they weren't just lucky?  Have you been successful?  How do you know you weren't just lucky too?  ("you" is not YOU Snake...can be anybody).
> 
> ASX.G




Exactly Mr Gorilla.

We all know discretion is corrupted due to the BRAIN. But it is also better than any backtest will ever be. With that bias in mind what assumptions we have are very important. Those with fundamental ones feed those who don't and vice versa. 

Backtesting gives us something to work with though. Maybe assumptions can be formed from this. When filters are added isn't this discretion?


----------



## Nick Radge (30 July 2007)

Here is some TradeStation code for an Equity Curve stop that was discussed in my first book (Everyday Traders) by Van Oadya. I have never used it, but others may find something in it. The theory is you turn the system off if the equity curve falls below an average, say 30-period. You turn it back on again when the equity curve passes back through the average.



Inputs: Period(0);

Vars:  Equity(0), UseEq(0), LastEq(0);
Vars:  Mo(0), Countr(0), J(0), K(0), CE(0), Size(200), Last(0);
Vars:  P1(0), P2(0), P3(0), P4(0);
Array: Per[5](""), EQ[200](0);

if (BarNumber = 1) then begin
  Per[0] = "Per-Trade"; Per[1]  = "Yearly"; Per[2] = "Quarterly";
  Per[3] = "Monthly";   Per[4] = "Weekly";  Per[5] = "Daily";
  print;
  print(Per[Period] + " profit:");
  end;

Mo = Month(Date);
Equity = I_ClosedEquity;

{ If our chosen period has expired, record the end-of-period equity }

if  ((Period = 0) and (Equity <> Equity[1]))
 or ((Period = 1) and (Year(Date) <> Year(Date[1])))
 or ((Period = 2) and (Mo <> Mo[1]) and (Mo=1 or Mo=4 or Mo=7 or Mo=10))
 or ((Period = 3) and (Mo <> Mo[1]))
 or ((Period = 4) and (DayOfWeek(Date) < DayOfWeek(Date[1])))
 or ((Period = 5) and (Date <> Date[1]))
then begin
  if (LastBarOnChart = False) then
    print(Date[1]:6:0,",",Equity:7:2,",",Equity-LastEq:7:2);
  LastEq = Equity;
  EQ[Countr] = Equity;
  Countr = Mod(Countr + 1, Size);       { Move pointer in buffer         }
  end;

{ On last bar, plot the last Size periods of equity }

if LastBarOnChart then begin
 Value3=2/(30+1);Value4=1-Value3;       { Setup 30 bar XMA factors       }
  for J = 0 to Size - 1 begin           { Loop to plot bars              }
    K = Mod(Countr + J, Size);          { Calc pointer into buffer       }
  If J=0 THEN Value5=EQ[K]              { Calc 30 bar XMA if not first   }
  ELSE        Value5=Value5*Value4+Value3*EQ[K];
    P1 = 0; P2 = 0; P3 = 0; P4 = 0;
    if (J > 0) then begin               { Set J=0 bar to 0 to "erase" it }
      if EQ[K] < Last then P1 = EQ[K];  { Plot losing periods in red     }
      if EQ[K] > Last then P2 = EQ[K];  { Plot winning periods in green  }
      if EQ[K] = Last then P3 = EQ[K];  { Plot flat periods in dark gray }
      P4 = EQ[K];
    end;
    Plot1[Size - 1 - J](P1,"ClosedEq");
    Plot2[Size - 1 - J](P2,"ClosedEq");
    Plot3[Size - 1 - J](P3,"ClosedEq");
    If J>30 then Plot4[Size - 1 - J](Value5, "average30");  { Plot white line at top of histogram }
    Last = EQ[K];
  end;
end;


----------



## tech/a (30 July 2007)

> at/near a top




This doesnt mean attempting to pick tops and bottoms.
This is placing a set of conditions within a system which when tested either improves or fails to improve a method.

Way Way different from attempting to pick a top or bottom.



> And who says those same stocks are going to up again




Well I do.
I've actually taken the time to check if this occures within portfolios.
AND it does in mine which is the (Broadly) ASX 300.
If a stock was/is performing strongly before a correction or downturn,I have found it will continue to do so when trading resumes bullish.
So you sell high and buy MORE with the profit at a lower price.
(As I say havent perfected it but has promise).



> assumptions and the assumption that system trading works because of BACKTESTS.




Snake no "Assumptions" relative to backtesting.
If you have a positive expectancy System it will have a "Blueprint" if trading subsequently trades within the Blueprint then you WILL be profitable.

If testing is purely based upon assumption then next time your in a plane just hope that the "Assumptions" made when testing "Metal Fatigue" stay within the "Blueprint"!


----------



## nizar (30 July 2007)

Nick Radge said:


> The theory is you turn the system off if the equity curve falls below an average, say 30-period. You turn it back on again when the equity curve passes back through the average.




Turning it back on does not mean buying back the same stocks again does it?

It could be -- but it could be different stocks, depending on which ones meet the entry criteria again (first).

Weird -- looks like you have a great system, one which doesnt trigger too many entries so doesnt leave alot of room for discretion.
Thank you for your thoughts.

ASX.G -- I agree.

Tech -- Well if you have tried and tested this method, then im not gonna argue with the results!


----------



## nizar (16 August 2007)

Does anybody have a metastock/tradesim code or any ideas on how to apply a signal for the system to turn off and then back on?

Nick's idea was interesting; an equity curve stop.
Any thoughts on how you code this?



> Stevo Doesnt BUY any new positions if certain INDEX conditions arent met.



Tech -- do you know how to code for this?

And what does system turning off actually mean?
That you dont take any new entry signals and only take exit signals?

Thanks.


----------



## tech/a (17 August 2007)

nizar said:


> Does anybody have a metastock/tradesim code or any ideas on how to apply a signal for the system to turn off and then back on?
> 
> Nick's idea was interesting; an equity curve stop.
> Any thoughts on how you code this?
> ...





Wow----Nizar need to do some crawling first.(As in learning not begging for the solution!!).
But I have Tried switches,For me I need to use the clunky "P" variable,for you with the newer version you can use the "Compare security".



> And what does system turning off actually mean?
> That you dont take any new entry signals and only take exit signals?
> 
> Thanks.




It can Steve Does this in his --Check his blog.
I'm still playing with the idea.
There are many possible answer to what it means.
(1) As suggested
(2) Sell all of the portfolio and buy it all back when the switch is turned.
(3) As (2) but buy new triggers.

*HINT*
For triggers I have made a composite chart of the portfolio--Equity curve.
one of the index asx300
one of those in my universe
and a few others these are my switches.

Do they improve things.
Marginally---from current testing,but there is potential---ask me in 6 mths when this settles.
I sold my entire portfolio/s at 6170 from analysis and the Switch was teling me to do the same!


----------



## Muschu (30 July 2008)

weird said:


> ......On another note, but further to the discussion of long term trading, one switch or filter, that often comes up in these types of discussions is the Coppock Indicator.
> 
> http://www.incrediblecharts.com/technical/coppock_indicator.htm




The Coppock Indicator was mentioned in today's Eureka Report. It mentioned that this indicator has now fallen below zero and that it can have some value in suggesting where the next bull market may lay. If I read it correctly the indicator was last at this point in May 2003.  Prior to that it was 1995. There are claims, I understand, that the Indicator can successfully pick the next wave up. 

I'd never heard of the Coppock indicator and did a search on ASF, finding this thread.  Any comments?


----------



## tech/a (30 July 2008)

Here are several variations take your pick

Coppock curve 22 250 150:

(Mov(ROC(Mov(C,22,S),250,%),150,E))/100
_____________________________________________

Coppock Curve Jose

mo1:=Input("Close MA:",1,252,21);
ro1:=Input("ROC periods:",1,2520,252);
Smooth:=Input("Coppock Smooth:",1,252,150);

Mov(ROC(Mov(C,mo1,E),ro1,%),Smooth,E)
_____________________________________________

Coppock curve 11 14 10 W signal

A:=Mov((((C-Ref(C,-11))/Ref(C,-11)) +
((C-Ref(C,-14))/Ref(C,-14))),10,W);
Sig:=Mov(A,5,S);
Red:=If(A<Ref(A,-1),A,0);
Green:=If(A>Ref(A,-1),A,0);
Sig;
Red;
Green;
_____________________________________________

Coppock curve W Kase filter 5 34 13

Pk:=Mov((((MP()-Ref(MP(),-5))/Ref(MP(),-5)) +
((MP()-Ref(MP(),-34))/Ref(MP(),-34))),13,W);
Per1:=30;
MN:=Mov(Pk,Per1,S);
SD:=Stdev(Pk,Per1);
Val1:=If(MN+(1.33*SD)>.382,MN+(1.33*SD),.382);
Val2:=If(MN-(1.33*SD)<-.382,MN-(1.33*SD),-.382);
Val3:=If(MN+(1.33*SD)>.25,MN+(1.33*SD),.25);
Val4:=If(MN-(1.33*SD)<-.25,MN-(1.33*SD),-.25);
LN:=If(Ref(Pk,-1)>=0 AND Pk>0,Val1,If(Ref(Pk,-1)<=0 AND Pk<0,Val2,0));
LN2:=If(Ref(Pk,-1)>=0 AND Pk>0,Val3,If(Ref(Pk,-1)<=0 AND Pk<0,Val4,0));
Red:=If(Ref(Pk,-1)>Pk,Pk,0);
Green:=If(Pk>Ref(Pk,-1),Pk,0);
Sig:=Mov(Pk,10,E);
Red;Green;LN;LN2;
Sig;
_____________________________________________

CCT Coppock curve

PK:=(ROC(CLOSE,14,percent )*10 + ROC(CLOSE,11,percent)*10 + ROC(Ref(CLOSE,-1),14,percent)*9 + ROC(Ref(CLOSE,-1),11,percent)*9 + ROC(Ref(CLOSE,-2),14,percent)*8 + ROC(Ref(CLOSE,-2),11,percent)*8 + ROC(Ref(CLOSE,-3),14,percent)*7 + ROC(Ref(CLOSE,-3),11,percent)*7 + ROC(Ref(CLOSE,-4),14,percent)*6 + ROC(Ref(CLOSE,-4),11,percent)*6 + ROC(Ref(CLOSE,-5),14,percent)*5 + ROC(Ref(CLOSE,-5),11,percent)*5 + ROC(Ref(CLOSE,-6),14,percent)*4 + ROC(Ref(CLOSE,-6),11,percent)*4 + ROC(Ref(CLOSE,-7),14,percent)*3 + ROC(Ref(CLOSE,-7),11,percent)*3 + ROC(Ref(CLOSE,-8),14,percent)*2 + ROC(Ref(CLOSE,-8),11,percent)*2 + ROC(Ref(CLOSE,-9),14,percent) + ROC(Ref(CLOSE,-9),11,percent))/2;
Per1:=30;
MN:=Mov(Pk,Per1,S);
SD:=Stdev(Pk,Per1);
Val1:=If(MN+(1.33*SD)>2.08,MN+(1.33*SD),2.08);
Val2:=If(MN-(1.33*SD)<-1.92,MN-(1.33*SD),-1.92);
LN:=If(Ref(Pk,-1)>=0 AND Pk>0,Val1,If(Ref(Pk,-1)<=0 AND Pk<0,Val2,0));

Green:=If(PK>Ref(PK,-1),PK,0);
Red:=If(PK<Ref(PK,-1),PK,0);
Signal:=Mov(PK,5,S);
LN;
Signal;
Green;
Red; 

Just another indicator---nothing magical---unfortunately


----------



## Muschu (30 July 2008)

tech/a said:


> Here are several variations take your pick
> 
> Coppock curve 22 250 150:
> ...................
> Just another indicator---nothing magical---unfortunately





Have no idea what this response means.  Was I meant to?


----------



## tech/a (30 July 2008)

Well if you own metastock then here is 4 versions (Metastock codes) of the Coppock indicator.
If you dont then I guess for you they are pretty useless.

Here a whole heap of questions relating to the Coppock indicator are answered.

http://www.bwts.com.au/qa.cfm?cmd=keyword&id=22

Youll also find here Colin Nicholsons Coppock Indicator spread sheets which you can up date.
For ASX NIKKI DJIA and others.
Note that the NIKKI has been negative for 6 mths! Way way negative!

http://www.bwts.com.au/text.cfm?15


----------



## wayneL (30 July 2008)

Muschu said:


> Have no idea what this response means.  Was I meant to?



It's the long term exponential moving average, of the long term rate of change, of a short term simple moving average.

Just another lagging indicator.


----------



## wayneL (30 July 2008)

tech/a said:


> Well if you own metastock then here is 4 versions (Metastock codes) of the Coppock indicator.
> If you dont then I guess for you they are pretty useless.




Tech

Those formulae are different to nicholsons formula 



> 1. Calculate the percentage change between the index value in the current month and its value 14 months earlier.
> 
> 2. Calculate the percentage change between the index value in the current month and its value 11 months earlier.
> 
> ...




Which in the clearly superior Amibroker formula language is (on monthly bars):

WMA(ROC(C,14)+ROC(C,11),10)

<edit to add because I clearly have nothing better to do\/>



> Coppock curve
> From Wikipedia, the free encyclopedia
> Jump to: navigation, search
> 
> ...


----------



## rub92me (31 July 2008)

Looks like it has the blessing of the Episcopal Church. Maybe I'll just pray instead; saves me coding it in Amibroker and looking at charts.


----------



## tech/a (31 July 2008)

WAYNE.

Collected them over the years.

Jose Silva was one formula contributor and the others were from Henry from Stock Central days.


----------



## stevo (25 August 2008)

nizar said:


> Does anybody here have a system that shuts off:
> 
> *when the index passes below a certain point ? (eg. moving average).
> 
> ...




This thread is a little old but I thought I would add some comments anyway. I am probably stating the obvious to many, although these sorts of thoughts come as revelations to me!

Since I only trade on the long side using a weekly time frame systems tend to stop giving signals when the market turns down, regardless of whether there are index filters, equity curve off/on switches etc. This would depend on the trading system entry signal strategy - oversold systems might give more signals when the market turns down, but systems that look for strength won't trigger as much.

So the system entry signal can stop entry signals from firing and effectively slow down a system.

I use an index filter with a couple of systems. I won't claim it's any sort of magic ingredient but it's nice to have a very clear off / on switch so I can go away and not even think about the market for a while. The switch I use isn't anything fancy - it just looks at short term down / up moves of an index to switch it off and on. I don't use moving averages - just the % moves of the index. I wouldn't even claim that it helps me make more money. But I believe that I would trade less for similar returns.

There is always the thought that something is running counter to the market and that opportunities are lost sitting on the sidelines watching. But with a longer term system this is probably not as important if the "Off" switch only turns off buy signals and holds onto longer term trades. It is not uncommon for the system to turn off and still hold stocks that continue to rise.

stevo


----------



## tech/a (25 August 2008)

Steve

A couple of questions from curiosity

Say over the last 6 mths in this last down trend.
(1) How many signals did you generate to the long side?
(2) How many are still in profit?
(3) How many do you usually hold in your portfolio and how many are in it now?
(5) Do you find your stopped out more often on entries generated during down periods.
(6) If your portfolio in more profit now than it was in say December?


----------



## stevo (26 August 2008)

tech/a said:


> Steve
> 
> A couple of questions from curiosity
> 
> ...




tech
I'll do my best to answer without running to a spreadsheet with fresh calculations.

I currently only have one trade running at the moment and it is in profit - NHC. 15 to 20 stocks is pretty typical number of stocks for me to hold. I am usually stopped out more in down periods, depending on the length of the down period and how wide spread it is across the market. 

I am down (cash and shares) from December last year, although in percentage terms the current holdings are up around 50% - but there is only one trade running! The rest is in cash earning 7.5%. 

The trading company is currently running 2 systems. In terms of question 1 since I have rationalised systems in the trading company I have no idea how many trades have been generated by different systems. I had 18 sell signals from January through to 1 July in the trading portfolio and probably a similar number of buy signals acted on. 

The answers show a certain amount of laziness on my part! There are equity curves and quarterly profit charts on my blog. July 08 wiped a lot of profit off my portfolios. It was like people were waiting for the start of the new financial year to sell stocks.

As mentioned I run 2 trading systems. One has an index filter and the other doesn't. The Index filtered system is off so no trades are signalled. The other system fired a couple of trades this week and I am really struggling to take them. I will force myself to take one signal (the other signal is a takeover) although it is tough to do when the other system is off and the market is so volatile. It's such a mind game and sometimes trading 2 systems doesn't help!

stevo


----------

