Only look for entries when Weekly indicator is rising
Author: mgreco19
Creation Date: 8/24/2017 3:00 PM
profile picture

mgreco19

#1
How would I code to only look for daily entries while the weekly derivative oscillator histogram or MACD Histogram is rising in value? ex. The weekly derivative oscillator for AAPL was rising from 12/9/16 to 3/10/17 and I would only look to enter trades during this time let's say if price dropped below SMA 20 to buy at market.
profile picture

Eugene

#2
There are lots of examples on the forum and in Wealth-Lab itself. Check them out:

1. WealthScript Programming Guide > Multi-Time Frame Analysis > Daily/Weekly
2. Built-in "Elder Triple Screen" system
3. Some downloadable Strategies based on multiple time frames i.e. Weekly:

RSI Trifecta
ActiveTrader 2009-04 | Crossover system filtered by Impulse system (weekly)
profile picture

mgreco19

#3
Thanks, Eugene. I took a look at the scripts and found the Elder Triple Screen helpful but I'm still doing something wrong here because trades are still triggering in the down trend. Can you let me know what I'm doing wrong here?

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

Eugene

#4
You're making good progress. Your intention was to compare for equality but a couple of syntax errors has turned it into an assignment i.e. an everlasting uptrend or downtrend:

CODE:
Please log in to see this code.

CODE:
Please log in to see this code.


profile picture

mgreco19

#5
I'm trying to do a similar trend rule where when a weekly moving average is moving up a consecutive number of days it starts an uptrend and it ends after a consecutive number of days down. I've pretty much just replaced the DOweekly with MAweekly from the above code but it looks like it's just getting stuck in a down trend.


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

Eugene

#6
Should I guess how the MAweekly is defined and positioned in the code? ;)
profile picture

mgreco19

#7
ha you could try but probably better for me to just do that in the first place :)

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

Eugene

#8
The code is OK on the surface except a popular error. Actually, the culprit was seen straight in your reply #5. Take a careful look at the first line which contains the subtle error:
CODE:
Please log in to see this code.

Now, when you find out what makes it different from the correct syntax of the line above it (see below), you'll know what to fix.
CODE:
Please log in to see this code.
profile picture

mgreco19

#9
All I see is the ; which I've removed prior to posting and it doesn't work correctly. The ; actually should have been removed before posting but I'm obviously missing something here.
profile picture

Eugene

#10
The ";" is what makes the difference. It is not removed prior to posting. See your own post #7 above.

Don't forget to recompile after making changes.
profile picture

mgreco19

#11
I've tried both with and without the ";". yes it wasn't removed before posting in the forum, what I meant was it should have as I've tested with both.

Whatever the case, when I copy the code from #7, remove the ";", recompile and run, the chart it's entirely red signaling a down trend. I'm running over a 4 year period.
profile picture

Eugene

#12
I see now, it doesn't play a role. The error is in the logic: the MAweekly cannot take a 3 value. If you plot it on the chart you should see that...
CODE:
Please log in to see this code.

...it may change on Fridays only (typical behavior of compressed series). Since there cannot be 3 increases in a row, as a quick & dirty solution you may want to change the "1" to "5" (the number of daily bars in a week):
CODE:
Please log in to see this code.
profile picture

mgreco19

#13
Thanks! That get's it closer but it's still off some. For example, if we look at TQQQ, I would think that it would switch to an uptrend on 6/10/16 but instead it changes midway through 5/27. Also, why would it switch midway through and not at the end when you see the increase?
profile picture

Eugene

#14
That's right, my quick take at it was imprecise. Here's how you probably envisioned it - with CumUp/CumDown on Weekly scale:

CODE:
Please log in to see this code.
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).