Managing extraordinary drawdown on A Seventeen-Liner
Author: marrtw
Creation Date: 11/29/2017 7:12 PM
profile picture

marrtw

#1
I've been playing with the seventeen liner strategy and have an issue with occasional single event drawdowns. The trades on the one bar in the attachment resulted in a 40% portfolio drawdown. I'm interested in recommended solutions to avoid this type of situation.

I've played with lots of PosSizers but don't get the desired results on this strategy. Unfortunately, I'm not a coder and the seventeen liner code is more complex than most example strategies.

A simple approach would be to exit the trade if the fastEMA is trending down for a certain number of bars after the trade was initiated (or exit immediately if the fastEMA crosses under the slowEMA). I've seen a code example for the latter condition but have no idea how to get this working in the fairly complex seventeen liner code.

Any help would be greatly appreciated.
profile picture

marrtw

#2
Here's the attachment...
profile picture

Eugene

#3
QUOTE:
I've played with lots of PosSizers but don't get the desired results on this strategy.

I wonder how you applied these PosSizers to not achieve a reduction of the drawdown?

Limit Monthly Drawdown
Control Drawdown
Drawdown / Runup
Trade Outcome
profile picture

marrtw

#4
Thanks Eugene,

I've tried them all except Trade Outcome. In fact, Limit Monthly Drawdown was selected for the backtest in the example I attached. Pcd of Equity was selected (7). A draw-down of 15% would reduce size by 100% (to see if it would do anything).

Perhaps the real problem is THIS trade is running away and there's nothing to stop it. I suppose the sizer would work on the next trade but it will already be too late. Some sort of simple stop process would probably work, then the sizer could kick in.

Or...perhaps I don't understand how it should work.



profile picture

marrtw

#5
So, I ran it again for the period. I've attached the Limit Monthly Drawdown settings. I've also attached the Equity Curve and Drawdown by Period. Drilling down further, I determined most of the draw down in the week in question came from the one trade I attached earlier.
profile picture

Eugene

#6
One thing about this PosSizer is that you would want to engage "Use intra-month equity". However, on second look nothing's going to help as all the losing trades are entered on the same bar.

This system has quite a number of degrees of freedom through its parameters (the various lookback periods and variables) so I'm not sure if throwing in a couple more by adding an extra EMA filter would avoid the mother of all drawdown.

Instead of the EMA crossover, how about a simple stop loss (ExitAt...(Position.AllPositions)) to end this misery? IMHO it's the absent risk management in play here - not the system's logic.
profile picture

marrtw

#7
Eugene,

I tried the code below with bad results. I've been "coding" for one week total. :) So, I'm sure something is wrong. On the other hand, I've purchased a couple books on C# and bought an online course so, eventually, I wouldn't have to ask stupid questions. Hopefully.

If you're inclined, would you show me where the ExitAt should go? If it requires too much coding, then forget it and I'll come back later with a more specific question if I never figure it out.

Thanks for the tip on the intra-month equity. I'll keep that in mind going forward.



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

Eugene

#8
That usage of IsLastPositionActive would be incorrect in a multi-position strategy like the "A seventeen-liner'.

I've thrown all of your conditions into the code and added a couple of entry coditions based on EMA for you to play with:

CODE:
Please log in to see this code.


The rest is the PosSizer's job. However, the system hardly could do anything about the 09/17/2001 gap (-40%).

profile picture

marrtw

#9
Thank you Eugene! Much appreciated.
profile picture

Eugene

#10
You're welcome.

You might be wondering what this conditions means:
CODE:
Please log in to see this code.

In conjunction with the "1" parameter which is used to indicate succession, the "5" argument in CumDown indicates 5 consecutive occurrences of the fast EMA declining. It's a pure streak. Replace the "1" with a greater number to make the condition more relaxed if you wish.
profile picture

marrtw

#11
Thank you. I did assume it's 5 or more consecutive occurrences of a fast EMA decline. Would you mind elaborating a bit about how the "1" relaxes the condition? It relates to Period, correct?

I've played with your code quite a bit and was able to add some more logic (plus a PosSizer) that improved back testing results. I did notice one thing that's a bit confusing. When adding a strategy parameter for later optimization and back testing, the results are different than when I hard code the parameter.

For example, the following statements (placed at the correct location in the code of course) yield different results:

CODE:
Please log in to see this code.


I should add that I was not in Raw Profit mode...but the differences were much larger than I normally see in Portfolio Simulation Mode.



profile picture

Eugene

#12
For your future record, let's keep the forum searchable and focused (to "Managing extraordinary drawdown on A Seventeen-Liner" in particular).

QUOTE:
Would you mind elaborating a bit about how the "1" relaxes the condition? It relates to Period, correct?

1 = 5 declines in a row. One failure and the counter restarts itself.
2 = up to 5 declines in every adjacent 2-bar window. Suppose you had 4 bars of an EMA going down. One up bar is not the end. Another down bar and the condition (5 declines) is true.
And so on.

QUOTE:
When adding a strategy parameter for later optimization and back testing, the results are different than when I hard code the parameter.
Could be Preferred Value or the default setting altered by "Save Parameters". Or maybe incorrect positioning in the code.

Please give forum's "search as you type" box a go and if the answer isn't found, the best practice is to discuss unrelated questions re: usage/coding in closely matching or new threads. tia.
profile picture

marrtw

#13
Got it. Thank you.
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).