Coding strategy based on P/E for .SPX
Author: WEALTHPRO25
Creation Date: 6/15/2015 2:02 PM
profile picture

WEALTHPRO25

#1
can you please help me code a simple strategy based on p/e for s&p p/e for .spx
profile picture

Eugene

#2
What would its rules be?
profile picture

WEALTHPRO25

#3
ok,

plot s&p 500 p/e ratio, than use 200 period sma, and period day sma on the p/e chart. when the 200 crosses the 400 from below buy
.dji and when 200 crosses 400 from top sell .dji, thanks
profile picture

Eugene

#4
I don't work with WLP and have no access to Fidelity data so bear with me if any error. My understanding is that P/E is price to earnings and S&P 500 is ".SPX". Try this on .DJI:

CODE:
Please log in to see this code.
profile picture

Cone

#5
That's not going to work. Indices and ETFs do not have associated fundamental data.

One way to do it with Fidelity-only data is to create an average p/e based on all the constituents in the index... processing intensive. Or, more straightforwardly divide the index value by the sum of the eps of the constituents. Likewise, an Index Definition could potentially be created for this, but in all cases historical significance would be lost due to the many changes of the S&P 500 over the years.
profile picture

Eugene

#6
Good point Robert. No need in an IndexDefinition as S&P 500 P/E is calculated by YCharts economic data provider directly:

* YCharts, item "[yc] sp_500_pe_ratio"

It's a drop-in replacement, right?

CODE:
Please log in to see this code.


And it can also be constructed from Multpl data and .SPX price:

* Multpl, item name "[mu] s-p-500-earnings"

CODE:
Please log in to see this code.


P.S. An important thing to remember about economic (non-symbol) data providers is an open issue preventing them from properly appearing on the chart

* (182124) Drag and drop doesn't function for non-symbol fundamental items (affects all Wealth-Lab versions from 6.7 and higher)
** Workaround: click "Push all indicators and fundamental items into the Strategy code"
profile picture

Cone

#7
That's the only realistic way to test a series like that one - use a provider that calculates it daily to account for all the replacements over time.
profile picture

Eugene

#8
Re: post #6. Update:

QUOTE:
* YCharts, item "[yc] sp_500_pe_ratio"


Since then (2015) we removed this and some other items from YCharts provider as consuming too much quota. So YCharts isn't applicable for this task.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).