Rules: Condition happened X bar ago / Condition Active X bars in a row
Author: Profitman57
Creation Date: 6/29/2015 7:13 AM
profile picture

Profitman57

#1
New use of Wealthlab.
Got a question.

Can i add 1 bar ago in the Wealtlab developer ?
I can drag and drop a rule, like : "RSI crosses oversold", and close must be > 200 MA.
But how about 1 2, or 3 bars back ?
Or can it only be done with coding ?


profile picture

Eugene

#2
QUOTE:
I can drag and drop a rule, like : "RSI crosses oversold", and close must be > 200 MA.
But how about 1 2, or 3 bars back ?


I'm having trouble understanding what is "add 1 bar ago". Could you clarify? If by saying that you mean that the RSI crossover could take place within 1-3 bars befire the close price rising above the 200-day MA, then yes, it's possible. The "Multi-Condition Group" rule adds some sort of 'fuzzy' logic, allowing you to create conditions that will trigger if any of the conditions in the group have triggered within a specified lookback period. Check out the User Guide > Strategy Window > Strategy Builder > MC, Multi-Condition Group topic.
profile picture

Profitman57

#3
Ok, let me explain:

In the strategy builder, one can add a condition,like, RSI crosses below oversold level.
How about that condition happened 4 bars ago ?
Buy at Limit next day open
if
close >200 MA
and
RSI 14 < 30 4 bars ago
and
RSI 14 is < 30 at bar yesterday
something like this ?
profile picture

Eugene

#4
Okay, topic title edited to better reflect your idea.

As suggested, Multi-Condition Group should take care of that if you're not strict on the RSI condition happening precisely 4 bars ago. If it's any number within the 4 period lookback, then it should do:



Otherwise you have to code that which is really simple:

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

Profitman57

#5
Thx Eugene for ur quick response.

Would prolly be very easy for a programmer to code the code....
But I'm a nitwit, who hasn't got a clue about coding.....

So how about, for me, and other non coders, show us how to "code" this in the Strategy builder:
All prices are EOD

If
Close today > MA 200
and
RSI 20 crossed the 25 oversold line 3 days ago(so at the close of today)
and
RSI 20 < 25 2 days ago
and
RSI 20 < 25 1 day ago
and
RSI 20 < 25 at today's close
Buy Limit at opening next day

So the RSI has to stay under the oversold line 3 day's in a row, after crossing the 25 line, then we buy at limit at the opening the next day.
Exit @ market next day, when price at the close is above the 75 line.

regards,
profile picture

Eugene

#6
QUOTE:
But I'm a nitwit, who hasn't got a clue about coding.....

When trying to express an advanced trading idea with Rules, inevitably you'll get to the point of exceeding its capabilities. Learning how to program basic trading strategies is an indispensable skill which will pay off in the long run. There are so much tutorials, strategy code examples, forum conversations to help you along the way.

QUOTE:
So how about, for me, and other non coders, show us how to "code" this in the Strategy builder:

Notice this line?
CODE:
Please log in to see this code.

Your next (very simple) task is to modify it accordingly. Substitute "4" with "2" (the day before yesterday), then make a copy and edit so that it refers to "yesterday" (bar-1). The condition for "today" (bar) is already there. This is a super easy excercise which is perfect for you to start.

References:

1. WealthScript Programming Guide > DataSeries > Accessing a Single Value from a DataSeries
2. If not sure about basic C# syntax: How do I start with C# ?

QUOTE:
So the RSI has to stay under the oversold line 3 day's in a row

FYI, Wealth-Lab customers can effortlessly implement your idea in Rule-based strategies by:

1. either using "Indicator is above (below) a value for n consecutive bars" condition from Community.Rules library
2. or using "Series is Below a Value" function from Community Components library
profile picture

Profitman57

#7
Thx again, I will scratch the surface on your link, big but however,

When one want to trade the markets, you trade, when u want to be a coder, you want to learn how to code.....
Sometimes however, it seems you need to be both.
Question however, no pun intended, do u want to spend time and effort to be both ?
Trading itself is hard enuf on it's own....;)
profile picture

Eugene

#8
QUOTE:
Sometimes however, it seems you need to be both.

Or you can try to hire a programmer to do the coding for you. ;) However, the problem here is to find the coder willing to do the job. Generally, we (technicians at MS123) usually try to help out with customers' coding tasks on the forums when possible.
profile picture

Profitman57

#9
Hi Eugene , got that part right, ur very helpfull...;)

Do I get this right, u can't access the Community rules library, unless you buy the program ?
So trial customers don't have access ?
Or do I need permission from an admin for access ?
profile picture

Eugene

#10
Trial users do not have access. Customers have full access to extensions and tech support. On our position regarding extension downloads by trial users, please see this FAQ:

FAQ | Miscellaneous, Extensions > "I can't download an Extension: the site says Wealth-Lab extensions are available only to Wealth-Lab Version 6 customers".
profile picture

Eugene

#11
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).