[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Re: Using equity curve for trading - looking for an example



PureBytes Links

Trading Reference Links

Greetings --

The "shadow equity" is the equity that would have been realized if all the trades were taken.  When the equity curve filter blocks taking trades, the equity curve does not change, so the reason used to resume trading must come from something else.  Keeping track of the shadow equity lets you analyze the performance that would have been realized during the period while trades are blocked.  In the code I posted, "e" is the shadow equity.

You are correct that the equity function is calculating the equity of the single issue being evaluated.  If you are running a trading system on a watchlist, the equity curve filter is applied to each individual issue before the results are gathered into the portfolio.

If you want to use the portfolio equity of the current run, you will need to program in the Custom Backtester.

"Quantitative Trading Systems" discusses equity a little.  "Introduction to AmiBroker" (which will begin shipping later this month) documents the equity function but gives no guidance in its use.  Neither discusses the Custom Backtester.  (But you might still find my books useful.)

When evaluating use of an equity curve filter, the process is essentially the same as applying a trading system to a stock.  If the stock tends to trend well, the type of trading system that will be profitable is trend-following.  If the stock spends more time in a trading range and oscillating, the type of trading system that will be profitable is mean-reverting.  The length of time a typical position is held makes a difference. 

The same principle applies to the equity curve. 

If winning trades tend to be followed by winning trades and losing trades followed by losing trades, then the type of equity curve filter that will be helpful is a trend-following equity curve filter.  For example, a moving average applied to daily equity, allowing trades when the equity is above its moving average and blocking trades when it is below. 

If winning trades tend to be followed by losing trades and losing trades followed by winning trades, then the type of equity curve filter that will be helpful is a mean-reverting equity curve filter.  For example, an oscillator based on the RSI of the equity, allowing trades at low values and blocking trades at high values.

In the code posted, the equity curve filter is being used to evaluate daily equity and either allow or block new trades.  It can also be used to exit existing trades before the trading system causes the exit.  To do this, incorporate some calculation on the "e" variable as a component of the "Sell" command.  For example, Sell = Sell OR ROC(e,5)<0;

Over All ---- The important logic is that built in to your trading system's entries and exits (and position size and risk control).  Do not expect an equity curve filter to rescue the performance of an ailing trading system.

Thanks,
Howard


On Sun, Oct 5, 2008 at 9:19 AM, droskill <droskill@xxxxxxxxx> wrote:

Howard - as usual, thank you so much for your thoughts - a couple of
questions:

1. The Equity() function, as I've read, only calculates the equity of
current symbol, not the portfolio - so in the manual it says you need
to use the custom backtester to access portfolio equity. My issue
with this is that if you access the ~~~Equity symbol, it actually
represents the equity of the last run, not the current run.

2. In your example, aren't you filtering based on the equity curve?
I'm curious what you mean by shadow equity in this case.

3. Is this covered in your book? That would give me another reason to
purchase it!

Thanks in advance!


--- In amibroker@xxxxxxxxxxxxxxx, "Howard B" <howardbandy@xxx> wrote:
>
> Greetings --
>
> See if this helps:
>
> /////////////////////////////////////////////
> // EquityCurveFilter.afl
> //
> // Howard Bandy
> // October 2008
>
>
> MALength = Param("MALength",5,1,100,1);
>
> Buy = Cross(C,MA(C,MALength));
> Sell = BarsSince(Buy) >= 5;
>
> e = Equity();
>
> EquityFilter = ROC(e,5)>0;
>
> Buy = Buy AND EquityFilter;
>
> Buy = ExRem(Buy,Sell);
> Sell = ExRem(Sell,Buy);
>
> ef = Equity();
>
> Plot(C,"C",colorBlack,styleCandle);
> Plot(e,"e",colorGreen,styleLine|styleLeftAxisScale);
> Plot(ef,"ef",colorBlue,styleLine|styleLeftAxisScale);
> //////////////////////////////////////////
>
> Trading the equity curve is essentially the same as trading a price
series.
> Apply any indicator you want to the daily equity.
>
> With a little more complexity, you can wait for trades to exit normally,
> then use the equity curve filter to allow or block the next signaled
trade.
> Keep track of the "shadow equity" to determine when to resume trading.
>
> Thanks,
> Howard
>
>
>
> On Sun, Oct 5, 2008 at 7:43 AM, droskill <droskill@xxx> wrote:
>
> > I'm trying to create a system that uses the equity curve to make
> > determinations of what trades to take. I understand I need to use the
> > custom backtester - but I could really use an example if anyone has
> > one lying around. Any help greatly appreciated!
> >
> >
> >
>


__._,_.___

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html

*********************************




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___