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 |

Real Code Condition Not Working Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
jimirak
Posted : Friday, November 5, 2010 11:07:08 AM
Registered User
Joined: 3/6/2005
Posts: 25

Here is a simple condition I want to use to ID stocks that have a high or a low price within 10 percent above the 20 day moving average. I have a user defined indicator of that moving average called 20SMA.
This does not seem to be working.

'|******************************************************************
 '# PH = indicator.Library.Price

 '#High = indicator.Library.High

 '#Low = indicator.Library.Low

 '#SMA20 = indicator.MyLibrary.SMA20


Dim delow As Single, delhi As Single

delow = low.value / SMA20.value
delhi = high.value / SMA20.value

If   delow <= 1.1 And delow >= 1.0 Or _
     delhi <= 1.1 And delhi >= 1.0 Then pass

Bruce_L
Posted : Friday, November 5, 2010 11:16:23 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I obviously don't have the SMA20 Indicator in my own Web Library. That said, it seems to work correctly for me when written as either:

'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Price within 10% Above MA
'|******************************************************************
'# High = indicator.Library.High
'# Low = indicator.Library.Low
Dim delow As Single, delhi As Single
delow = low.value / Price.AVGC(20)
delhi = high.value / Price.AVGC(20)
If (delow <= 1.1 AndAlso delow >= 1.0) OrElse _
    (delhi <= 1.1 AndAlso delhi >= 1.0) Then Pass

Or as:

'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Price within 10% Above MA
'|******************************************************************
Dim delow As Single, delhi As Single
delow = Price.Low / Price.AVGC(20)
delhi = Price.High / Price.AVGC(20)
If (delow <= 1.1 AndAlso delow >= 1.0) OrElse _
    (delhi <= 1.1 AndAlso delhi >= 1.0) Then Pass

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
jimirak
Posted : Saturday, November 6, 2010 4:18:08 PM
Registered User
Joined: 3/6/2005
Posts: 25
Thanks a lot, Bruce. I suspected that SMA20 was the problem and now I am working on learning how to debug  realcode so I can see what's happening. I do a lot of VB programming and rely on its debugger.
Bruce_L
Posted : Monday, November 8, 2010 8:55:35 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You're welcome.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
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.