Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/13/2005(UTC) Posts: 715 Location: Midwest, USA
Was thanked: 1 time(s) in 1 post(s)
|
The "AND" should be OK, but your conditions need to more accurately describe what you want.
Your statement "Events must occur sequentially rather than at one time." is a bit ambiguous. The possibilities implied are:
1. Each condition must happen at the EXACT same time -- meaning on the EXACT same bar (same periodicity -- day/week/month/whatever).
2. Sequentially would mean the timing of the conditions must occur in the EXACT order you describe (first the RSI, then the narrowing, then the close over the top band). This is possible, using the "BarsSince" function, but a bit on the complex side.
3. All three conditions must hold, but need not happen on the same bar and it doesn't matter which happens first; you want the conditions to be simultaneous, rather than sequential.
It looks like the last item (3.) is what you really want. If so, then the RSI must be over 20, BBands are narrowing and the Close is higher than the Top band for "x" bars, all at the same time, but not neccessarily on the same bar and it doesn't really matter which condition comes first. That being the case, then, instead of CROSS, just use ">" (greater than):
RSI(14)>20 and BBandTop(C,20,S,2)-BBandBot(C,20,S,2)<opt1 and C>BBandTop(ref(C,opt2),20,S,2);
NOTE: 2nd condition: If what you're after is truly a narrowing of the bands, you'd rewrite the code for the difference to be less than the previous, using REF().
NOTE: 3rd condition: Also, am not so sure about that last line; I might restate it as:
sum(C>BBandTop(C,20,S,2),opt2)=opt2;
...where "opt2" would be how many bars the CLOSE has been higher than the top band.
Hope that helps,
|