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
|
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
|
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.
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|