Registered User Joined: 3/4/2005 Posts: 55
|
I have two conditions; one is created using importing Moving Averages(drag MA from Chart) to RealCode Editor and the second is created using RealCode Function Price.AVG. I would think both should yield the same Scan results of the same WatchList, but do not. The importing MA finds 48 stocks while the Function AVG finds 39 stocks.
My Condition in both scenarios is: find stocks that have 21Day MA crossing up thru the 50Day MA for Price.
Condition One:
'# MA21 = chart.MovingAverage.2
'# MA50 = chart.MovingAverage.4
If MA21.value(1) < MA50.value(1) And MA21.value >= MA50.value Then
Pass
End If
Condition Two:
If Price.AVG(21, 1) < Price.AVG(50, 1) And Price.AVG(21) >= Price.AVG(50) Then
Pass
End If
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Assuming the imported MA21 and MA50 indicators are in fact 21-period simple and 50-period simple moving averages of the close, then two conditions should match.
Please select Help | Send Layout so technical support can take a look. Please include a description of the issue you are experiencing when sending the Layout to technical support.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Registered User Joined: 3/4/2005 Posts: 55
|
Thanks Bruce,
I did verify that 21day and 50day MA's were Simple. I did as suggested and sent in a Layout to tech support.
Ed
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
The reason this is happening is because imported indicators in StockFinder are rounded to two significant digits past the decimal point when imported into RealCode while the Price.AVG() method uses a single data type with about seven significant digits of precision (no matter how many of those digits are before or after the decimal point).
This means you can have cases where MA21.value(1) and MA50.value(1) are equal when rounded to two digits past the decimal when the 21-period simple moving average is actually below the 50-period simple moving average 1 bar ago and cases where MA21.value and MA50.value are equal when rounded to two digits past the decimal when the 21-period simple moving average is actually above the 50-period simple moving average. Both instances would produce disagreement between condition one and condition two.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
Registered User Joined: 3/4/2005 Posts: 55
|
Thank you Bruce for answering why the descrepancy between the two methods. Makes sense after explaining... You always have an answer - thank goodness - help keep my sanity. :-)
Ed
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|