ActiveTrader 2012-10 | Double-and-reverse money management
Author: Eugene
Creation Date: 9/6/2012 3:24 AM
profile picture

Eugene

#1
Code for ActiveTrader 2012-10 | Double-and-reverse money management strategy published.

We recommend downloading it directly using the convenient "Strategy Download" feature (found in Wealth-Lab's "Open Strategy" dialog).



Pyramiding PosSizer requires installed MS123 PosSizers library!
profile picture

Eugene

#2
Let's have it repeated once again:

1. Strategy requires Pyramiding PosSizer
2. Which in its turn requires installed MS123 PosSizers library.
profile picture

kcbars

#3
I've been attempting to run the Double Reverse strategy through strategy monitor. However, I've been trying to run it with a fixed number of shares, rather than with the position sizer, and want it to reverse with the same number of shares (rather than double). It seems to work well with the exception of the short entry after a long stop. When I use strategy monitor, the short entry after a long stop doesn't occur (though it does show up when I just run the strategy outright). If I take out the "if" language before the short entry and buy entry below, and remove the position priority language, does it makes sense that it should run as I'm hoping? Thanks to anyone who might be able to help.

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

Eugene

#4
Hi Kevin,

1. The NetProfit property should not be used in Strategies: as the QuickRef suggests, it's reserved for Visualizers.
2. The "p" in "p.NetProfit" does not exist at the time the SellAtStop has executed.
3. Running this code without the Pyramiding PosSizer is pretty pointless.

Since this code serves a specific task, your intention might be just to run a SAR strategy. In this case, please check out this strategy design pattern:

WealthScript Techniques | Creating a Stop-And-Reverse (SAR) system
profile picture

kcbars

#5
Eugene, thank you for the info. Based upon the above, I decided to try the pyramiding position sizer. However, I'm a bit confused on the NetProfit/Visualizer concept. If it is reserved for visualizers, does that mean it's for illustrative purposes only? Since the visualizers appears as a result of running a strategy, I guess I'm having a hard time following what that means. Is there a command I could use in place of NetProfit that would work in this case, or would I need to re-configure the strategy to use the first trade/subsequent trade idea? Thank you.
profile picture

Eugene

#6
Kevin, the Strategy is ready for backtesting and does not require a modification for that purpose, provided that it's used together with the Pyramiding PosSizer - which is the heart of it, allowing it to double on reverse.

As to the "fixed number of shares + reverse with the same number of shares", simply follow my Wiki link.
profile picture

kcbars

#7
Ok, yes it runs well for backtesting. But I guess what I'm asking is if I want to trade it through the strategy monitor, is there a way to get the reverse/double entries to happen without completely reinventing the wheel (since NetProfit shouldn't be used in strategies)? Thanks.
profile picture

Eugene

#8
Well, you can use NetProfit in Strategies - just keep in mind that the figure is always based on 1 share.

QUOTE:
When I use strategy monitor, the short entry after a long stop doesn't occur (though it does show up when I just run the strategy outright).

The entry does occur though an Alert does not. Quoting the FAQ: Alerts are not triggered:

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

kcbars

#9
Thanks so much for the help.
profile picture

Eugene

#10
You're welcome.
profile picture

kcbars

#11
As you stated:

The "p" in "p.NetProfit" does not exist at the time the SellAtStop has executed.

I can't figure out a way to get the code to recognize the loss and go short after the sell at stop (when running in strategy monitor). Would I have configure it like a stop and reverse, or is there a better way? Thanks.
profile picture

Eugene

#12
As stated, *AtClose should be replace to get an alert. Give the following a try:

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

kcbars

#13
Ok, I ran this today and one of the positions hit the sell stop. However, even though the subsequent short trade occurred, the strategy doesn't show any short entries (i.e. no "Loss" Short at Market entries). Thinking about this with my rudimentary skills, is it possible when the code gets to the if(Positions.Count > 0), the position count is zero? Yet the short entry occurred on the next loop, so I'll have to think about it. Thanks.
profile picture

Eugene

#14
The position count can be zero if you don't load enough bars to keep previous trades. For example, on Daily data load 500 bars and see if it helps. Besies that, I don't have any other ideas.