Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

4 moving average converges within +/- 3% of Price Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
abfs
Posted : Sunday, January 3, 2010 2:33:52 PM
Gold Customer Gold Customer

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
jas0501
Posted : Sunday, January 3, 2010 6:46:34 PM
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

jas0501
Posted : Sunday, January 3, 2010 7:05:45 PM
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

abfs
Posted : Monday, January 4, 2010 11:05:49 PM
Gold Customer Gold Customer

Joined: 12/30/2004
Posts: 28
Very Cool, Thanks!!!!!!!!
abfs
Posted : Sunday, April 25, 2010 4:55:55 PM
Gold Customer Gold Customer

Joined: 12/30/2004
Posts: 28
Help!

The above condition had stop working. Can someone tell me why?

Thanks
Users browsing this topic
Guest-1

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.