Registered User Joined: 12/30/2004 Posts: 28
|
Hi,
I am using stockfinder 5 beta.
How do I create a scan condition that looks for stock within +/- 3% away from it's 21EMA, 50EMA, 150EMA and 200EMA. Trying to find stock with all of the above EMA converges within + or - 3% of price.
thanks
|
Registered User Joined: 12/31/2005 Posts: 2,499
|
|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 4.9 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:XAvg's within n% of Price
'|******************************************************************
' stock within +/- 3% away from it's 21EMA, 50EMA, 150EMA and 200EMA.
'# widthPercent = userinput.single = 3
Dim MaxXvg As Single
Dim MinXvg As Single
Dim top As Single
Dim bottom As Single
maxXvg = system.math.Max( _
system.math.Max( _
system.math.Max(price.xavg(21), price.xavg(50)), _
price.xavg(150)), price.xavg(200))
minXvg = system.math.Min( _
system.math.Min( _
system.math.Min(price.xavg(21), price.xavg(50)), _
price.xavg(150)), price.xavg(200))
top = price.Close * (1 + (widthPercent / 100))
bottom = price.Close * (1 - (widthPercent / 100))
If MaxXvg <= top AndAlso _
MaxXvg >= bottom AndAlso _
minXvg >= bottom AndAlso _
minXvg <= top Then
pass
End If
|
Registered User Joined: 12/31/2005 Posts: 2,499
|
Having confirmed the logic a minor rearragement will improve performance a bit
'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 4.9 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:XAvg's within n% of Price
'|******************************************************************
' stock within +/- 3% away from it's 21EMA, 50EMA, 150EMA and 200EMA.
'# widthPercent = userinput.single = 3
Dim MaxXvg As Single
Dim MinXvg As Single
Dim top As Single
Dim bottom As Single
maxXvg = system.math.Max( _
system.math.Max( _
system.math.Max(price.xavg(21), price.xavg(50)), _
price.xavg(150)), price.xavg(200))
top = price.Close * (1 + (widthPercent / 100))
If MaxXvg <= top Then
bottom = price.Close * (1 - (widthPercent / 100))
If MaxXvg >= bottom Then
minXvg = system.math.Min( _
system.math.Min( _
system.math.Min(price.xavg(21), price.xavg(50)), _
price.xavg(150)), price.xavg(200))
If minXvg >= bottom AndAlso _
minXvg <= top Then
pass
End If
End If
End If
|
Registered User Joined: 12/30/2004 Posts: 28
|
Very Cool, Thanks!!!!!!!!
|
Registered User Joined: 12/30/2004 Posts: 28
|
Help!
The above condition had stop working. Can someone tell me why?
Thanks
|