Days below value
Author: seano
Creation Date: 5/23/2011 9:00 AM
profile picture

seano

#1
I am an experienced trader but not familiar with WealthLab. So far, I am impressed but I am struggling trying to get my personal strategy into the system. I can read code fairly well but not a great programmer so was hoping to do rules as much as possible.

My current stumble is that my system needs to not allow a trade unless the RSI is below 70 for 5 trading days. I can see how to insure that RSI is going down or that today is lower than yesterday (or even 5 bars ago) but I cannot see how to insure that the RSI of every day for 5 days is below 70.

I appreciate your help for this potentially newbie question.
profile picture

Eugene

#2
Here you go:
CODE:
Please log in to see this code.


The Community Indicators extension has a more convenient DataSeries to facilitate programming this kind of trading rule:

Series is Below a Value

It (as well as its sister functions SeriesIsAboveValue, SeriesIsAbove and SeriesIsBelow) is more precise than what is programmed above i.e. my quick & dirty code doesn't account for cases when RSI briefly jumps above 70 for a day or two during the 5-day period.
profile picture

seano

#3
Thank you Eugene for the quick response!!

So I am assuming by your response that this would need to be coded and can't be built with the interactive rules?
profile picture

seano

#4
Eugene - I apologize for my quick reply, I didn't note your last few comments below the code. I am going to investigate the Community Indicators extension as that may be the best answer for my needs.

Once again, thank you for your quick response. I will post again if the "point in the right direction" that you have given me still finds me lost in the maze. I appreciate your wisdom.
profile picture

Eugene

#5
QUOTE:
i.e. my quick & dirty code doesn't account for cases when RSI briefly jumps above 70 for a day or two during the 5-day period.

On a second thought, it's possible by throwing in an extra condition: require that the RSI declines for 5 day in a row:
CODE:
Please log in to see this code.

QUOTE:
So I am assuming by your response that this would need to be coded and can't be built with the interactive rules?

It can be coded with the interactive rules. Set it up the following way:
profile picture

seano

#6
Thanks Eugene. I don't think the interactive will work. For instance, in this scenario:
Today -1 is 55
Today -2 is 50
Today -3 is 60
Today -4 is 65
Today -5 is 69
Today -6 (out of the range) is 74

My strategy would be that this would be time to buy however in the interactive rules it would fail.

I really don't see how to do this without me learning to code a bit better (which is probably not a bad thing).
profile picture

Eugene

#7
In this case simply remove the 1st rule (indicator decreases for a consecutive number of days).
profile picture

seano

#8
As I understand the rule "Indicator is below its value a number of bars ago", that would mean that this scenario would prove true (when it shouldn't):
Today is 69
Today -1 is 75
Today -2 is 80
Today -3 is 88
Today -4 is 75
Today -5 is 79

What I really need is "Indicator is below a value a number of bars ago" and then I could just AND 5 of them together to make sure that the RSI indicator was always below 70.

Thank you for your help and I hope I am not being too much of a pain.
profile picture

Cone

#9
Let me see if I can figure out how to add a "Indicator above/below its value for n consecutive bars" rule to the Community.Rules.
profile picture

Eugene

#10
This is possible with the ShiftDelay indicator...

...if you plot an RSI on the chart before.
profile picture

Cone

#11
Let's make it easy. New set of Rules uploaded at Community.Rules. If you can't see the Attachment after logging in to the Wiki, please create a Support ticket.
profile picture

seano

#12
Thank you. I downloaded the Community.Rules and that seems to do what I wanted.
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).