Equity curve trading

Place your new trading idea here to see if someone can automate it.
Post Reply
jcl
Trader
Posts: 82
Joined: Wed Oct 31, 2012 8:04 am
Location: Frankfurt / Germany

Equity curve trading

Post by jcl »

Strategy returns are almost always slightly correlated: wins and losses tend to cluster. This can be made advantage of with a method named "Equity curve trading", i.e. filtering trades dependent on the current equity situation. For this you need a platform that supports simulating trades in life trading mode for calculating a hypothetical equity curve.

I've tested about 20 strategies recently and found that not all, but most of them improve with equity curve trading. Especially the drawdown is reduced. This is an example Zorro script for equity curve trading:

Code: Select all

void checkEquity()
{
  var *EquityLongShort = series(WinLong-LossLong+WinValLong-LossValLong
    +WinShort-LossShort+WinValShort-LossValShort);
	var *EquityMA = series(SMA(EquityLongShort,100));
  if(*EquityLongShort < *EquityMA && falling(EquityMA))
    Lots = -1; // drawdown -> phantom trading
  else
    Lots = 1; // profitable -> normal trading
}
This can also work in Empty4 when someone writes an EA for simulating trades. It's important to check the direction of the equity MA as well as if it's below or above the current equity. These two conditions together give the most improvement by equity curve trading.
User avatar
Jemook
Trader
Posts: 1085
Joined: Thu May 10, 2012 10:19 am
Location: Bondi, Sydney, Australia

Re: Equity curve trading

Post by Jemook »

Could you please explain what that code aims to accomplish for the non-coders?

Jeremy
Please note I am no longer affiliated with Global Prime. I've moved on to my next adventure with Afterprime.

Catch me here: https://www.afterprime.com
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: Equity curve trading

Post by gaheitman »

Jemook wrote:Could you please explain what that code aims to accomplish for the non-coders?

Jeremy
Zorro has the ability to enter simulated (phantom) trades right along with regular trades . The code above determines which kind of trade (real or simulated) to enter depending on whether or not your current equity curve (with both real and simulated trades included) is above or below a moving average. If your current equity is below the 100 period SMA of your equity (and the SMA is falling?), it starts sending phantom trades. Once your equity is back above the 100 SMA, it goes back to sending real ones.

Wow, that's more parenthesis than the original code. :lol:

George
User avatar
Jemook
Trader
Posts: 1085
Joined: Thu May 10, 2012 10:19 am
Location: Bondi, Sydney, Australia

Re: Equity curve trading

Post by Jemook »

George as always you are a brilliant help, cheers. I like the idea of this - will have to check out Zorro me thinks!
Please note I am no longer affiliated with Global Prime. I've moved on to my next adventure with Afterprime.

Catch me here: https://www.afterprime.com
garyfritz

Re: Equity curve trading

Post by garyfritz »

I've tested equity-curve trading quite a bit in the past. Sometimes it works brilliantly, but quite often it hurts results.

It works well when, as jcl said, you have long strings of wins or losses. As long as the equity curve is moving strongly up or strongly down, the equity curve is far from the MA of the equity curve, and it "does the right thing" to keep you in or out.

It has trouble when you have mixes of wins and losses, and the equity curve goes roughly sideways. When the equity curve isn't moving up/down strongly, the MA catches up with it -- which means the equity curve is constantly crossing above & below the MA, turning your trading on and off.

The problem is: you take all the losses that drive your equity curve below the MA. Then you DON'T take all the wins that drive the equity curve ABOVE the MA. Result: a period that showed sideways results without the equity curve filter, now shows steady losses. In my testing, this often/usually outweighed the benefits you got from avoiding long losing periods.

It's exactly like trading with an MA. Try putting an SMA on a chart, say H1 USDJPY. Pretend each H1 candle is one "trade" -- up candles are winners, down candles are losers. Act only on the close of the H1 bars -- equivalent to the "close" of your trades. If a candle closes above the MA, your equity-curve filter says "trade," and if a candle closes below the MA your filter says "don't trade."

So the close-to-close change from "the first candle that closes above the MA" to "the first candle that closes below the MA" is the profit/loss from the trades you "took." The change while the bars are below the MA is the profit/loss you DIDN'T get because you were in "don't trade" mode.

Here's an example. The red lines show the profit/loss you made while in "trade" mode. It worked fabulously on the strong down-move on 25-26 Oct, not so good on 29-30 Oct, and OK after that. You avoided about 49 pips of loss by "not trading" in the 25-26 Oct down move -- great!! -- BUT you lost about 8+9+25+6 = 48 pips in the 4 trading periods on 25 & 29-30 Oct, giving back everything you saved.
EqCurve.gif
I find that this method often replaces "big drawdowns caused by long strings of losses" with "big drawdowns caused by sideways periods."

If you think your equity curve will tend to move up or down strongly most of the time, it might work great for you. If your wins and losses tend to be small, you'll flip trade/don't-trade very soon after crossing the MA so you won't miss much.

But any sideways periods are going to hurt.
You do not have the required permissions to view the files attached to this post.
User avatar
gaheitman
Trader
Posts: 655
Joined: Tue Nov 15, 2011 10:55 pm
Location: Richmond, VA, US

Re: Equity curve trading

Post by gaheitman »

garyfritz wrote:I've tested equity-curve trading quite a bit in the past. Sometimes it works brilliantly, but quite often it hurts results.

It works well when, as jcl said, you have long strings of wins or losses. As long as the equity curve is moving strongly up or strongly down, the equity curve is far from the MA of the equity curve, and it "does the right thing" to keep you in or out.

It has trouble when you have mixes of wins and losses, and the equity curve goes roughly sideways. When the equity curve isn't moving up/down strongly, the MA catches up with it -- which means the equity curve is constantly crossing above & below the MA, turning your trading on and off.

The problem is: you take all the losses that drive your equity curve below the MA. Then you DON'T take all the wins that drive the equity curve ABOVE the MA. Result: a period that showed sideways results without the equity curve filter, now shows steady losses. In my testing, this often/usually outweighed the benefits you got from avoiding long losing periods.

It's exactly like trading with an MA. Try putting an SMA on a chart, say H1 USDJPY. Pretend each H1 candle is one "trade" -- up candles are winners, down candles are losers. Act only on the close of the H1 bars -- equivalent to the "close" of your trades. If a candle closes above the MA, your equity-curve filter says "trade," and if a candle closes below the MA your filter says "don't trade."

So the close-to-close change from "the first candle that closes above the MA" to "the first candle that closes below the MA" is the profit/loss from the trades you "took." The change while the bars are below the MA is the profit/loss you DIDN'T get because you were in "don't trade" mode.

Here's an example. The red lines show the profit/loss you made while in "trade" mode. It worked fabulously on the strong down-move on 25-26 Oct, not so good on 29-30 Oct, and OK after that. You avoided about 49 pips of loss by "not trading" in the 25-26 Oct down move -- great!! -- BUT you lost about 8+9+25+6 = 48 pips in the 4 trading periods on 25 & 29-30 Oct, giving back everything you saved.
EqCurve.gif
I find that this method often replaces "big drawdowns caused by long strings of losses" with "big drawdowns caused by sideways periods."

If you think your equity curve will tend to move up or down strongly most of the time, it might work great for you. If your wins and losses tend to be small, you'll flip trade/don't-trade very soon after crossing the MA so you won't miss much.

But any sideways periods are going to hurt.
Some day I'm going to give a complete answer like Gary always does. Not today, not tomorrow, but some day.

EDIT: Nah.... ;)

George
jcl
Trader
Posts: 82
Joined: Wed Oct 31, 2012 8:04 am
Location: Frankfurt / Germany

Re: Equity curve trading

Post by jcl »

garyfritz wrote:The problem is: you take all the losses that drive your equity curve below the MA. Then you DON'T take all the wins that drive the equity curve ABOVE the MA. Result: a period that showed sideways results without the equity curve filter, now shows steady losses. In my testing, this often/usually outweighed the benefits you got from avoiding long losing periods.
Yes, that has been my experience also. That's the reason of additional "falling" condition that also checks the MA direction. Trades are only suppressed in the part of the equity MA curve that goes down. This does not really solve the problem, but it helps.
eigenvector
Trader
Posts: 20
Joined: Sat Jul 14, 2012 3:14 pm

Re: Equity curve trading

Post by eigenvector »

garyfritz wrote:I've tested equity-curve trading quite a bit in the past. Sometimes it works brilliantly, but quite often it hurts results.

It works well when, as jcl said, you have long strings of wins or losses. As long as the equity curve is moving strongly up or strongly down, the equity curve is far from the MA of the equity curve, and it "does the right thing" to keep you in or out.

It has trouble when you have mixes of wins and losses, and the equity curve goes roughly sideways. When the equity curve isn't moving up/down strongly, the MA catches up with it -- which means the equity curve is constantly crossing above & below the MA, turning your trading on and off.

The problem is: you take all the losses that drive your equity curve below the MA. Then you DON'T take all the wins that drive the equity curve ABOVE the MA. Result: a period that showed sideways results without the equity curve filter, now shows steady losses. In my testing, this often/usually outweighed the benefits you got from avoiding long losing periods.

It's exactly like trading with an MA. Try putting an SMA on a chart, say H1 USDJPY. Pretend each H1 candle is one "trade" -- up candles are winners, down candles are losers. Act only on the close of the H1 bars -- equivalent to the "close" of your trades. If a candle closes above the MA, your equity-curve filter says "trade," and if a candle closes below the MA your filter says "don't trade."

So the close-to-close change from "the first candle that closes above the MA" to "the first candle that closes below the MA" is the profit/loss from the trades you "took." The change while the bars are below the MA is the profit/loss you DIDN'T get because you were in "don't trade" mode.

Here's an example. The red lines show the profit/loss you made while in "trade" mode. It worked fabulously on the strong down-move on 25-26 Oct, not so good on 29-30 Oct, and OK after that. You avoided about 49 pips of loss by "not trading" in the 25-26 Oct down move -- great!! -- BUT you lost about 8+9+25+6 = 48 pips in the 4 trading periods on 25 & 29-30 Oct, giving back everything you saved.
EqCurve.gif
I find that this method often replaces "big drawdowns caused by long strings of losses" with "big drawdowns caused by sideways periods."

If you think your equity curve will tend to move up or down strongly most of the time, it might work great for you. If your wins and losses tend to be small, you'll flip trade/don't-trade very soon after crossing the MA so you won't miss much.

But any sideways periods are going to hurt.
Yes this is my experience also. I think the answer is not to be found with equity curve trading for a single system. With a single system you can either turn on / off or you can scale up/down size or just trade a fixed size all the time. But I think a better solution is a multiple-system strategy where size is scaled up/down based on performance.

For instance, let's say you trade 5 (uncorrelated) systems at the same time. Start each system with the same amount of cash so an even 1/5 split. Then as time progresses, there will be profits and losses but hopefully some systems will be making money, while some might be losing money. You alter trade size to match the amount of capital each system has won/lost.

So if you have $5000 divided between 5 systems, at the outset each system has $1000. Based on that each system trades a size per $1000 based on your target leverage, such as 3 times leverage for each system. After a time one system might have $1200, so trade size increases from $3,000 to $3600 for that system. Another system might drop to $800, so trade size on the losing system decreases from $3000 to $2400. So the strategy is essentially a survival of the fittest type of strategy where winning systems get more cash allocated, and losing systems are starved of cash. After a time, you might wish to reallocate funds, drop out some systems or even out the cash between systems.
Julez1982
Posts: 1
Joined: Mon Nov 11, 2013 9:59 pm

Re: Equity curve trading

Post by Julez1982 »

Hey,

iam looking for an Empty4 Expert advisor with an "trading the equity" code!
Can anybody help?

Thank you!
Julian
Post Reply

Return to “Ideas for Possible Automation”