Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 6/15/2008 Posts: 1,356
|
Challenge for the mathematicians :
suppose 5 bars closing prices as follows :
7,8,6,9,10
a 5bar MA would be 8
How do you calculate what the next bars close has to be in order to close at the 5MA?
I think it would be cool to have an indicator that will plot what the next bar's close has to be in order to close at, for example the 50MA.
Today's SPY action gave me that idea, since it made quite a move from Friday, to close near the 50DMA today.
|
|
Registered User Joined: 6/5/2010 Posts: 27
|
PT:
This might work:
(8 + 6 + 9 + 10 + x)/ 5 = x, where what number in our calculation will equal the MA itself
33 + x = 5x, adding up the 4 remaining terms, and multiplying both sides by 5;
33 = 4x; subtracting x from both sides
8.25 = x
So,
for a given MA, say period P,
Then take the last P-1 terms, and divide by P-1, to solve for x.
Yes? Does this work?
jm
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Yes, that would seem to work.
'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Next Close at SMA
'|******************************************************************
'# Period = UserInput.Integer = 5
Static Sum As Single
If isFirstBar Then
Sum = 0
End If
Sum += Price.Last
If CurrentIndex >= Period - 1 Then
Sum -= (Price.Last(Period - 1))
End If
If CurrentIndex >= Period - 2 Then
Plot = Sum / (Period - 1)
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |