Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 6/15/2008 Posts: 1,356
|
I'd like to find a way to create a rule to find charts like these.
parameters:
price needs to open or close at least "a" times within "b" percentage of high within "c" trading sessions
followed by a "d" percent higher close above the high.
anyone any idea on how to do this?
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You might want to try something similar to the following RealCode Rule:
'# WithinPerc = UserInput.Single = 3
'# TrueBars = UserInput.Integer = 10
'# OfBars = UserInput.Integer = 40
'# BreakPerc = UserInput.Single = 6
Static Within As Single
Static Break As Single
If CurrentIndex > OfBars Then
Dim Resistance As Single = Price.MaxHigh(OfBars, 1)
If Price.Last / Resistance >= Break Then
Dim Count As Integer = 0
For i As Integer = 0 To OfBars
If Price.Open(i) / Resistance >= Within OrElse _
Price.Last(i) / Resistance >= Within Then
Count += 1
End If
Next
If Count >= TrueBars Then
Pass
End If
End If
Else If isFirstBar Then
Within = 1 - WithinPerc / 100
Break = 1 + BreakPerc / 100
SetIndexInvalid
Else
SetIndexInvalid
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 6/15/2008 Posts: 1,356
|
Thanks Bruce, but shouldn't your For..Next loop look like this :
For i As Integer = 0 To OfBars
If Price.Open(i) / Resistance >= Within OrElse _
Price.Last(i) / Resistance >= Within Then
Count += 1
End If
Next i
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Yes it should.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
Bruce,
Is this suppose to find flat base brekouts?
I tried it and I don't get anything even JST doesn't get highlighted
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
thnkbigr,
You could ask pthegreat what it is designed to find, but I had nothing to do with the creation of the algorithm. All I did was attempt to help pthegreat implement his idea as faithfully as possible in StockFinder.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 6/15/2008 Posts: 1,356
|
Yes thnkbigr, that's the idea.
I create my rules by reverse engineering. I'm trying to find commonalities between charts that have broken out. I've had some success with different types of patterns.
One that has worked well lately, is stocks with good fundamentals, bouncing of MA's. More explosive movements are found in charts that have flatlined for a while, and all of a sudden draw interest from investors. SVA is a great example of such. see one of my previous posts.
I found JST through a scan that looks for inclining 200 and 50MA and price close above 50MA within a ceratin percentage. this scan triggered about twice before price broke out. with the scan in this thread I'm trying to do find the same pattern, but independant of MA's. So far I don't see the results I'd like. I'm still fiddling with it. At the same time, these kind of exercises are great to improve my programming skills. many times you'll use same type of routines in realcode for different rules.
|
|
Registered User Joined: 10/7/2004 Posts: 816
|
pthegreat,
Another approach to finding breakouts (up or down) is by using Point an Figure charts.
I think that PnF charts are easier to use when looking for support and resistance areas.
While inspection of the "X"s and "O"s doesn't easily show the actual periods involved, Bruce put me onto something that makes a scan for breakouts quite easy. In a PnF chart each column of "X"s or "O's is thought of as a period (even tho in actuality it might represent any number of periods) and because of that simple scans for new highs and new lows can be made for the timeframe of your choice (the PnF timeframe).
A quick visual inspection of the stocks that passed the scan can then narrow the candidates.
Hope this helps in giving a different perspective
Regards
BobMc
|
|
Registered User Joined: 10/7/2004 Posts: 816
|
I should have also said that I use Craig's PnF-using ATR layout/chart
BobMc
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
BobMc
Is that Layout shared if yes what is it shared under?
Thx
|
|
Registered User Joined: 10/7/2004 Posts: 816
|
Yes it was shared - but it's been a while. A search for Craig's PnF might find it. Also looking at Craig's old blog might have it too.
When I get back into SF I'll look for it
Regards
Bob Mc
|
|
Registered User Joined: 11/13/2009 Posts: 12
|
Can one of you please clarify how the final code should appear (with the inclusion of pthegreat's correction). I am not especially code literate, but I want to find support/resistance breakouts such as the postings above. I would also appreciate a real code that would find breaks of resistance in the same manner. Thanks.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
nimmer.jacob,
The correction was edited into the original post. You can use the RealCode as it is currently in my Wednesday, November 18, 2009 10:30:39 AM ET post (although it should be noted that the algorithm apparently does not produce the results that pthegreat was expecting).
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 12/31/2005 Posts: 2,499
|
Here is my take on the request:
'
'price needs To open Or close at least "a" times
' within "b" percentage Of high
' within "c" trading sessions
'followed by a "d" percent higher close above the high.
'
'=====================================================================
'# cTradingSessions = userinput.integer = 40
'# dPercent = userinput.integer = 5
'# bPercent = userinput.integer = 8
'# aTimes = userinput.integer = 5
' Approach:
' check for open above d% target first to avoid doing the counts
' if open is d% above high then
' compute bTarget and
' count occurances.
' Note: pick max or open and close and only increment by 1 per day
'
dim count as integer
dim dTarget as single
dim bTarget as single
dim biggerPrice as single
if currentindex > cTradingSessions then
dTarget = price.maxhigh(cTradingSessions, 1) * (1 + dPercent / 100)
if price.close > dTarget then
bTarget = price.maxhigh(cTradingSessions, 1) * (1 - bPercent / 100)
count = 0
for i as integer = 1 to cTradingSessions
biggerPrice = system.math.max(price.open(i), price.close(i))
if biggerPrice > bTarget then
count += 1
End If
next i
if count > aTimes then
pass
End If
End If
End If
I got JST to trigger with count all the way up to 29 of 40 sessions with 9% range and 4% breakout
|
|
Registered User Joined: 11/13/2009 Posts: 12
|
Thanks for the responses
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
nimmer.jacob,
You're welcome. Our pleasure.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |