logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
MM_1  
#1 Posted : Monday, October 10, 2011 10:53:11 AM(UTC)
MM_1

Rank: Newbie

Groups: Registered, Registered Users
Joined: 10/10/2011(UTC)
Posts: 3

Hello!
I have question about trade system for Metastock.
Buy order:
If take place the following events consistently.
1. RSI crossed above 20,
2. Difference between the top and bottom Bollinger bands became less variable opt1.
3. Price (Close) crossed the top Bollinger band for previous opt2 time periods.

Cross( RSI(14), 20 ) and
BBandTop(CLOSE, 20, SIMPLE, 2) - BBandBot(CLOSE, 20, SIMPLE, 2)<opt1 and
Cross(CLOSE, BBandTop(ref( CLOSE, opt2 ), 20, SIMPLE, 2))

Please, look on my code. I'm not sure that the function "AND" will work correctly.
Events must occur sequentially rather than at one time.
jjstein  
#2 Posted : Monday, October 10, 2011 1:31:40 PM(UTC)
jjstein

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,

MM_1  
#3 Posted : Tuesday, October 11, 2011 4:25:03 AM(UTC)
MM_1

Rank: Newbie

Groups: Registered, Registered Users
Joined: 10/10/2011(UTC)
Posts: 3

jjstein, thanks you for your reply.
I must think about your questions.
I think I really want item (2.)

item 1: The probability of the three conditions together is zero.
item 2: The logic is as follows: first, a strong move to one side, second, consolidation and finally, the breakdown is.
item 3: The conditions in other order is meaningless.

What do you think about like this code?

RSI(14)>20 and
BarsSince(BBandTop(ref(C, -opt3),20,S,2)-BBandBot(ref(C, -opt3),20,S,2)<opt1) and
sum(C>BBandTop(C,20,S,2),opt2)=opt2;
jjstein  
#4 Posted : Tuesday, October 11, 2011 11:03:47 AM(UTC)
jjstein

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)
>>What do you think about like this code?

Suggest you take out the "optX" and put in sample parameters, so it can be plotted & seen on a chart.


>>I think I really want item (2.)

Then you will need to use "BarsSince". It may help to use the Expert Symbol, Highlight and/or Trend functions to see what happens, and when.

MM_1  
#5 Posted : Wednesday, October 12, 2011 3:09:18 AM(UTC)
MM_1

Rank: Newbie

Groups: Registered, Registered Users
Joined: 10/10/2011(UTC)
Posts: 3

I built four indicators and made simple test.
1. RSI (14).
2. Bollinger Bands (C, 20, S, 2)
3. _sumYK: If(C>BBandTop(C,20,S,2),1,-1)
4. _Bar_BB: BarsSince(BBandTop(C,20,S,2)-BBandBot(C,20,S,2)<50)
Please, look it!
http://imgur.com/v8ER8
jjstein  
#6 Posted : Wednesday, October 12, 2011 9:22:34 AM(UTC)
jjstein

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)
Try this: Either use Alt-PrtScrn, paste into Paint and save, or use "Save as HTML". Either way, use Windows Explorer and drag the *.JPG or *.PNG file to IMGUR.COM, then copy/paste the BBCode link into the forum msg.


Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.