Pyramiding Positions and Exiting All Positions
Author: paul3nt
Creation Date: 8/22/2010 11:13 AM
profile picture

paul3nt

#1

I wish to implement a simple pyramiding scheme: on trigger 1) I wish to add 1 Investment or Position of say $ x; on trigger 2) add $ 2x, etc up to trigger 4), so that I have in total 1`+ 2+ 3+ 4 = $ 10x. Then I wish to exit them all on trigger 5). How do I code that? Is there a simple one line expression to exit "AllPositions?"

Thanks for your help.
profile picture

Eugene

#2
QUOTE:
How do I code that?

Check out this design pattern:

* WealthScript Techniques | Pyramiding (Adding to position) in the Wealth-Lab Wiki
* download this strategy using Wealth-Lab's "Open Strategy" window: ActiveTrader 2010-04 | Volatility scale in system

QUOTE:
Is there a simple one line expression to exit "AllPositions?"

Yes. Like mentioned in the QuickRef ("Trading", in several places), you should use Position.AllPositions for that.
profile picture

paul3nt

#3
Thanks Eugene, but frankly your original code is so complicated that I cannot decipher it. Also apparently it was written before the SetShareSize function was available, enabling users to pyramid very general schemes.

Accordingly I wrote a generic code, "Pharaoh_generic", that can pyramid almost anything. In the example I coded a "1-2-3-4" pyramid buying (or shorting) 1 investment unit, then 2 ... up to 4 ( for a potential total of 10) as we get deeper into the position. I've achieved great results taking a common oscillator trading scheme to new heights and achieving a WLscore > 20 and Sharpe ratios > 1.

Here's the code.
CODE:
Please log in to see this code.


Paul3nt
profile picture

Eugene

#4
Thanks for sharing your code.

Note that SetShareSize only lets you define a fixed share size, while a portfolio equity is changing every day. Furthermore, without a PosSizer, pyramiding on a portfolio can't be tested because it's always possible that the primary position is skipped due to capital constraints while your pyramid trades are taken (by design). The pyramiding PosSizer in this PosSizer Library takes care of that.

fyi: Please use the CODE tags when posting code, as it makes your code easier to read.
profile picture

paul3nt

#5
Eugene,

Thanks for your clarifications. But I have two questions:

1) Just downloaded WL6 and installed all the extensions available to Fidelity patrons through
the WL6 extension tool.
The PosSizer includes just 5 options ( Avg Down with Pct ...; DoubleDown; MaxEntries;
One Trade per Symbol; and PctWinners.) Would greatly welcome access to the other PosSizers
including Pyramid, but apparently it is not available. Is it possible to obtain these
other PosSizers ?

2) Re your suggestion of a "Tag" on a code to make it more readable: How do users attach tags to code ?

It looks like we must write C# code in Visual Studio, then compile ( and debug) to supplement
the Extra Performance Visualizers and obtain the industry standard Performance metrics like Adj. Sortino,
and M^2. I am an experienced and very busy trader and I just don't have the time to do all this. Isn't there
a simpler way to obtain a strategy Equity Curve data and process it, even using "Old-Hat" methods like
Excel ?

Thanks again for all your help.

Paul3nt
profile picture

Eugene

#6
Paul,

1) Restart WLP for the changes to apply.

2) Wrap pasted code block in a pair of CODE tags. Do you see Bold,Italic,Underlying... just below "Add a new Post"? Next to them is the CODE button that adds CODE tags.

3) Yes, right. If you have a valuable performance metric to suggest with the formula, then someone could take a look at including it in the Visualizers library someday.

Strategy equity curve data available by right-clicking in "Equity Curve" tab and selecting "Copy Equity Curve Data to Clipboard".
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).