Hello,
I am new to Wealth-Lab and I am trying to build a simple strategy from rules. I do not have programming experience at the moment.
I want to test buying (SPY) when the MACD crosses above its 9-day EMA. I want to sell the following year after April 20, whenever the MACD crosses below its EMA.
When I use the rules to build this strategy, I will get multiple entries and exits in November (and beyond). If I add additional sell conditions (i.e. sell after April 20 and before October 16), all my positions remain open (no sells).
I have pasted the code below (containing just two sell and two buy conditions). Can someone please tell me how to get around this?
CODE:
Please log in to see this code.
Size:
Color:
Welcome to the forums Evan.
You can get multiple entries in the Rule Wizard when allowing multiple open positions (at the bottom), and using a Multi-Condition Group on top of that (this is what your code shows). This is presumably causing the strategy to misbehave.
To test "Sell in May and go away", there's a ready-made Strategy called >>>
April_October that you can download straight from within WLP (be sure to follow
Instructions for Script Download). If we add your additional rules and exclude the short trades, here's how it may look like:
CODE:
Please log in to see this code.
Size:
Color:
Thank you Eugene, that was useful. I noticed that the trades will not execute if the MACD has already crossed the EMA trigger prior to the dates I specified. I will try fiddling around with the code a little bit to see if I can figure this stuff out. I presume I'll have to insert some "ORs". Thanks again.
Size:
Color:
Size:
Color: