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 |

Calculate next bar's close to close at a MA Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
pthegreat
Posted : Monday, July 11, 2011 5:32:18 PM

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.
jmeisen
Posted : Monday, July 11, 2011 10:22:05 PM
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
Bruce_L
Posted : Tuesday, July 12, 2011 9:59:15 AM


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
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.