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 |

Importing Simple Moving Average VS. Function .AVG Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
egorth
Posted : Saturday, January 11, 2014 3:26:08 PM
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
 
Bruce_L
Posted : Monday, January 13, 2014 1:24:27 PM


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
egorth
Posted : Tuesday, January 14, 2014 5:01:24 PM
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

Bruce_L
Posted : Wednesday, January 15, 2014 12:48:26 PM


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
egorth
Posted : Friday, January 17, 2014 12:03:57 AM
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

 

Bruce_L
Posted : Friday, January 17, 2014 9:56:06 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.