Strategy does not sell, when I think it should
Author: SimhaD04
Creation Date: 1/13/2012 2:26 PM
profile picture

SimhaD04

#1
The following script is automatically generated for a simple rule-based strategy:
CODE:
Please log in to see this code.


When both MACD Signal (10,22,8) <0 and price is below 160 day SMA it is supposed to sell. It does not. What am I missing?

Thanks,
If
profile picture

Cone

#2
It must be because the Position was not created by a "Group 2" entry signal, i.e., the BuyAtLimit order. If that's not the case, then be more specific.. data provider, symbol, scale, date of trade, etc.
profile picture

Eugene

#3
Ditto.
profile picture

SimhaD04

#4
It'd be easier to submit an image, but I can't figure how with this system. I'll try to answer your questions w/o it:

1. Data provider - Fidelity
2. symbol - MID index (tried different ones, same result, e.g. SPX)
3. With MID, on 9/4/08 the strategy makes a Buy.
4. Around 9/16/08, 160 SMA turns down and hence MACD signal (10,22,8) has been <0 since 9/5, I would expect a Sell. It does not sell all the way down to 12/17/08

Thanks
profile picture

Eugene

#5
Like we already told, it did not sell just because you instructed the Rule wizard to do so. Each entry rule has its own exit rules attached. You could expect a sell under those SMA/MACD conditions only if that trade was made by the entry that involves Ultimate Oscillator and MACDEx. However, the trade was created by the other rule (moving averages). Switch to the Trades tab, notice the "Entry name" saying "Group1" (moving averages) for that 9/4/08 trade, voila, case closed.

P.S. An image would not be helpful because it does not tell which entry was in charge of that exit. For your future reference, it's easy to upload a screenshot to any image hoster and then post the direct link here, wrapped between a pair of IMG tags.
profile picture

SimhaD04

#6
That's a bit too clever, don't you think?

Can you tell me where Group1, Group2, Group1| and Group2| are defined? I was trying to locate the scripts Boolean expressions in the manual, there is not even an index entry for Boolean.

Can you point me to the definitions so that I could read the code?

Thanks.
profile picture

Eugene

#7
QUOTE:
That's a bit too clever, don't you think?

No. You have designed that rule-based strategy, meaning that you dropped that exit rule onto one of the entry rules.
QUOTE:
Can you tell me where Group1, Group2, Group1| and Group2| are defined?

That's a FAQ:

Wealth-Lab Wiki FAQ | Strategies and WealthScript > After generating strategy code with "View Strategy Code", there are strings like "Group1" and "Group1|". What do they mean?
QUOTE:
I was trying to locate the scripts Boolean expressions in the manual, there is not even an index entry for Boolean.

That's right, hundreds of books have been already written on the subject so the manual wasn't designed to teach C# 101. It focuses on the WealthScript namespace's features so to say.
QUOTE:
Can you point me to the definitions so that I could read the code?

Sure, it's in the same FAQ -- scroll down to How do I start with C# ?

After studying some C# basics, you'll be able to both read and write the code.
profile picture

SimhaD04

#8
First off, thanks a lot for your comments, I'll check the references.

As to your comment:

You have designed that rule-based strategy, meaning that you dropped that exit rule onto one of the entry rules.

I am not clear what it means. My entries are listed first and exits last as follows:
www.daat.com/daatguest/WL-Strategy.gif

What did I do wrong? thanks.
profile picture

Eugene

#9
QUOTE:
What did I do wrong? thanks.

Not assigning the proper exit rule to an entry. The way it appears on the screenshot, the lower entry rule (Buy At Limit) can be exited with any of the two exit rules. To fix, simply drag an exit rule and place it right below an entry rule. For example:

+ Buy At Limit Channel Low
** conditions
- Sell At Limit Channel High
+ Buy At Limit
** conditions
- Sell At Close

Otherwise you're creating ambiguity in logic flow. Maintain the order of entries/exits by placing them in order i.e. entry/exit, entry/exit.
profile picture

SimhaD04

#10
did not help...

Before I attach pix, let me explain what I wanted to accomplish to make sure we are on the same page and that it is possible w/o coding. (My ultimate goal is to get as close as I can with automatically generated code and then adjust that as necessary.)

I want to Buy on either of my two conditions and I want to sell if either of my Sell conditions is fulfilled.

Using the example of MID index.

www.daat.com/daatguest/WLPro.gif

On 9/4/08 the strategy Buys based at least on Buy at Limit Channel Low. On 9/16-17, the Sell at Close condition is satisfied, but the strategy does not sell all the way till 12/17/08.

After reshuffling the code as you suggested:

www.daat.com/daatguest/WL-Strategy.gif

WL generates the following code:

CODE:
Please log in to see this code.


So, is there an error in the generated code, or it cannot do what I want w/o manual coding? Thanks.
profile picture

Cone

#11
User Guide > Strategy Builder:
An Exit is paired with the Entry directly above it. However, by placing an Exit at the top of the list (above any Entries) applies it to all Entries of the same type in the strategy.

Consequently, if you want to exit with any of the sell conditions, make sure that all of the exits appear above the entries in the wizard, i.e.,

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

SimhaD04

#12
I couldn't find the text you quoted from manual's Strategy Builder...

In any event, what you proposed worked. Thanks!
profile picture

Eugene

#13
QUOTE:
I couldn't find

Here's one convenient shortcut: Ctrl-F. Type in some text in a popup and it will find it assuming you're on the right page. If you don't know the location there's a Search tab in the help to run a full-text search through the open document.

Help menu, select Wealth-Lab User Guide > Strategy Window > Strategy Builder > How to: Create a Rule-based Strategy (Ctrl + Shift + R) > "2. Form your basic strategy by selecting Entries and Exits".

profile picture

SimhaD04

#14
sorry, I was looking at it and not seeing; the "not a screener" statement just threw me off so I skipped the next all-important paragraph. Thanks again, you were very helpful. I think I can take it up from here.
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).