Strategy ran in WL5 but not in WL6
Author: rmpwealth
Creation Date: 9/6/2010 10:37 AM
profile picture

rmpwealth

#1
I just upgraded from WL 5.6 to WL 6, and one of my rule-based strategies that ran fine in WL5 will not run in WL6, nor will WL6 let me reconstruct the rules strategy again from scratch. Can you help?

The rules are as follow:

Buy at Market:
Indicator makes a new low within period (AvPrC, 6 bars)
Price is above Moving Average (SMA=22)

Sell at Market:
Indicator makes a new high within period (AvPrC, 6 bars)
Price is below Moving Average (SMA=15)
OR
Sell at Market:
Indicator % below moving average (AvPrC, Percent=5.00, MA Type=SMA, MA=Close, MA Pe=80)

The error message that appears is as follows:

"There were errors attempting to compile the Strategy:
c:\Documents and Settings\RMP1\Local Settings\Temp\wr6spfp5.0.cs(64,1):error CS1022: Type or namespace definition, or end-of-file expected"

FWIW, (1) The strategy seems to work OK without the "OR" condition. (2) When building the strategy from the rules, and I select the "Indicator % below moving average" item, I notice that the label on that item states "... when an Indicator is above its moving average ...". I presume that is just a typo in the note, but thought I'd mention it anyway.
profile picture

Eugene

#2
Drop the OR condition. An OR divider is not required between any two SellAtMarket's - Wealth-Lab will pick the right one by itself.

Wealth-Lab's handling of a hanging OR leaves something to be desired in 6.0 (read: buggy) - that's why the error message.
QUOTE:
I presume that is just a typo in the note, but thought I'd mention it anyway.

Fortunately, just a typo. To prove it, click "Open code in new Strategy Window":
CODE:
Please log in to see this code.
profile picture

Cone

#3
Thanks for point out the typo in the Rule description. We can get that fixed for next time.

It sounds to me like you've got a handing OR divider. If you want to OR that that last condition, you should put it in the same SellAtMarket grouping. It looks to me like you did something like this:

...having trouble again with "Error on page" when posting a CODE segment...
profile picture

Cone

#4
Oh well, can't post what I'm trying to for some reason, but basically, you've Sell at Market twice when it should be there only once. There must be Conditions on either side of the OR Divider.
profile picture

rmpwealth

#5
Thanks, guys. When I eliminated the 2nd "Sell at Market", the strategy executed.

However, now I am not clear on the correct syntax of the "OR" argument without use of the 2nd Buy at Market -- specifically, where to place the "OR" argument -- for the following reason. What I want to do is to Sell if both of the first two conditions are met, or Sell if only the third condition is met. I wrote the rules the following two different ways, but got the exact same results both ways (using SPY, Scale=Daily, Range=5-Yrs, Raw Profit Mode). I suppose that's possible, but I would think the odds would be against it, so am wondering.

The first set of rules, I simply deleted the 2nd "Sell at Market" from the original rules.

1. Sell at Market:
(a) Indicator Makes New High Within Period
(b) Price is Below Moving Average
OR
(c) Indicator % Below Moving Average

The second set of rules, fearing that my syntax was incorrect on the first, I tried to isolate the "Indicator % Below Moving Average".

2. Sell at Market:
(c) Indicator % Below Moving Average
OR
(a) Indicator Makes New High Within Period
(b) Price is Below Moving Average

Again, even though the two sets of rules are different, they yield the same results. As I understand the syntax for the "OR" argument, the evaluation of Rules #1 is: (a) must be met; AND either (b) or (c) also must be met. The evaluation of Rules #2 is: (c) must be met; or both (a) AND (b) also must be met. Is this not correct? If so, how can both sets of rules yield the same results?

In fact, after having said all that and looking back on it, I'm not even sure either set of rules would accomplish my original objective. What is the correct syntax to accomplish the following: Sell at Market if one of the following two conditions are met: (a) AND (b) both are met;, or (c) alone is met?
profile picture

Cone

#6
QUOTE:
Again, even though the two sets of rules are different,
But they're not different as you wrote them. Conditions that appear next to each other are AND'd, and the same 2 conditions are next to each other in both your examples.

I see what you want, however, and for that you can use the new MC grouping (Multi-Condition). Try this:

Sell at Market:
(a) Indicator Makes New High Within Period
MC: Required 1, Lookback 0
(b) Price is Below Moving Average
(c) Indicator % Below Moving Average

This should get you (a) AND ( b OR c )


Using the MC condition as shown above should be a short cut for doing the same thing like this:

Sell at Market:
(a) Indicator Makes New High Within Period
OR
(b) Price is Below Moving Average
Sell at Market:
(a) Indicator Makes New High Within Period
OR
(c) Indicator % Below Moving Average
Buy at Market
Indicator makes a new low within period (AvPrC, 6 bars)
Price is above Moving Average (SMA=22)

If you have multiple entry and exit conditions, note that you should group the exits above the entries that they should modify.
profile picture

rmpwealth

#7
QUOTE:
But they're not different as you wrote them. Conditions that appear next to each other are AND'd, and the same 2 conditions are next to each other in both your examples.


Aahhh; I see. Any conditions that are contiguous are considered to be nested AND's, regardless of the order in which they appear. Thanks.
profile picture

Cone

#8
QUOTE:
conditions that are contiguous
Right, they're AND'd, except when found in a MC (Multi-Condition) group. In a MC group, you pick the number of the conditions that must be true within the specified lookback period.
profile picture

dowen

#9
The following worked fine in version 5, originally translated from ver 4, but does not work in WLP 6. Do I need to use the new SavetoFile and ReadtoFile commands?


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

Eugene

#10
The following is a product of WSTL (WealtScript Translator, unsupported), but the problem here is that you don't have the write rights to create files in Program Files. Yes, even if you're logged in as admin. Either start WLP by right-clicking the icon and selecting 'run as admin' option, or (better) change the destination folder e.g. to your Documents folder.
profile picture

dowen

#11
Thanks Eugene
profile picture

Eugene

#12
To anybody interested in MC Groups. Check out our tutorial video on Youtube:

Wealth-Lab 101: Strategy Builder Multi-Condition Groups
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).