Results 1 to 7 of 7

Thread: Trying to 'reverse' a formula....

  1. #1
    Newbie
    Joined
    May 2013
    From
    Oxford
    Posts
    4

    Trying to 'reverse' a formula....

    I am trying work out a formula based on the information below that will help me to answer the question... "What PRICE is required today that will make the difference between two exponential moving averages the same value as yesterday?" I can work out the formula 'forwards' as I've shown below with my calculations, but I am trying to create a formula where TODAYS PRICE is the unknown variable. Any help would be most appreciated, Thank you.

    YP = Yesterday price (=4.29)
    YEMA1 = yesterdays 3 day exponential moving average (=4.28)
    YEMA2 = yesterdays 5 day exponential moving average (=4.20)
    YDiff = YEMA1/YEMA2 (=1.01905)

    TP = Todays price (=4.29)
    TEMA1 = Today's 3 day exponential moving average =2/4*(TP-YEMA1)+YEMA1 (=4.285)
    TEMA2 = Today's 5 day exponential moving average =2/6*(TP-YEMA2)+YEMA2 (=4.23)
    TDiff = TEMA1/TEMA2 (=1.013002)

    So, just to clarify, I am trying to find out what 'TP' should be that will make 'Tdiff' equal 'Ydiff'.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    MHF Contributor ebaines's Avatar
    Joined
    Jun 2008
    From
    Illinois
    Posts
    1,389
    Thanks
    420

    Re: Trying to 'reverse' a formula....

    For simplicity I'm going to call YEMEA1 = Y_1, YEMEA2=Y_2, Ydif = Yd, TEMA1 = T_1, TEMA2 = T_2, Tdiff = Td

    The formula for T1 that you have can be simplified to $\displaystyle T_1 = \frac {T_p} 2 +\frac {Y_1} 2$, and $\displaystyle T_2 = \frac {T_p} 3 + \frac {2Y_2} 3$.

    If $\displaystyle Y_d = T_d$, then $\displaystyle Y_d = \frac {T_1}{T_2} = \frac {\frac {T_p} 2 +\frac {Y_1} 2}{\frac {T_p} 3+\frac {2Y_2}{3}}$

    Multiply numerator and denominator of the the left hand side by 6, and rearrange:

    $\displaystyle Y_d(2T_p+ 4 Y_2) = 3T_p + 3 Y_1$

    $\displaystyle T_p(2Y_d-3) = 3Y_1 - 4 Y_dY_2$

    Note that Yd times Y_2 = Y_1, so:

    $\displaystyle T_p = \frac {3Y_1 - 4 Y_1}{2Y_d-3}$

    $\displaystyle T_p = \frac {-Y_1} {2Y_d -3 }$

    $\displaystyle T_p = \frac {Y_1}{3-2 Y_d}$

    Using your numbers above, where Y_1 = 4.28 and Y_d = 1.01905, you get Tp = 4.4495, T1 = 4.364752, T2 = 4.283168, and Td = 1.019048 (same as Yd).
    Last edited by ebaines; May 20th 2013 at 08:17 AM.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    May 2013
    From
    Oxford
    Posts
    4

    Re: Trying to 'reverse' a formula....

    Excellent! Thank you very much.. you've made my day.. I'd already spent quite some time trying to figure this out!
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    May 2013
    From
    Oxford
    Posts
    4

    Re: Trying to 'reverse' a formula....

    I've just been trying to test myself to make sure I understand how you derived at the formula... and so I have decided to use a different example using a 5 day EMA and an 8 day EMA.... (and applying a multiplier of 40 ).. but where I am really stuck is the process you went through to rearrange the formula after multiplying the numerator and denominator... could you break it down into smaller steps.. or point me in the direction of somewhere to go where I can learn how to do this? Thanks again.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    MHF Contributor ebaines's Avatar
    Joined
    Jun 2008
    From
    Illinois
    Posts
    1,389
    Thanks
    420

    Re: Trying to 'reverse' a formula....

    OK. Staruing from:

    $\displaystyle Y_d = \frac {\frac {T_p}2 +\frac {Y_1} 2}{\frac {T_p} 3 + \frac 2 Y_2} 3}$

    Multiply through by $\displaystyle \frac 6 6$:

    $\displaystyle Y_d = \frac {6 (\frac {T_p}2 +\frac {Y_1} 2)}{6(\frac {T_p} 3 + \frac 2 Y_2} 3)} = \frac {3T_p +3Y_1)}{2T_p + 4 Y_2} $

    Now multiply through by the denominator on the right hand side:

    $\displaystyle Y_d (2T_p + 4 Y_2) = 3T_p+3Y_1 $

    Regroup to bring the T_p terms to the left hand side and everything else on the right:

    $\displaystyle Y_d(2 T_p) - 3T_p = 3Y_1 -4 Y_dY_2$

    $\displaystyle T_p(2Y_d-3) = 3Y_1 - 4Y_dY_p $

    Sub $\displaystyle Y_1= Y_dY_p$:

    $\displaystyle T_p(2Y_d-3) = 3Y_1 - 4Y_1 = -Y_1$

    Divide both sides by p$\displaystyle 2Y_d-3$:

    $\displaystyle T_p = \frac {-Y_1}{2Y_d -3} $

    Multiply right hand side by $\displaystyle \frac {-1}{-1}$:

    $\displaystyle T_p = ( \frac {-1}{-1}) \frac {-Y_1}{2Y_d -3} = \frac {Y_1}{3 - 2 Y_d} $

    Hope this helps.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    MHF Contributor ebaines's Avatar
    Joined
    Jun 2008
    From
    Illinois
    Posts
    1,389
    Thanks
    420

    Re: Trying to 'reverse' a formula....

    There is an error in my previous post but i am unable to edit it.

    Quote Originally Posted by ebaines View Post
    OK. Staruing from:

    $\displaystyle Y_d = \frac {\frac {T_p}2 +\frac {Y_1} 2}{\frac {T_p} 3 + \frac 2 Y_2} 3}$

    Multiply through by $\displaystyle \frac 6 6$:

    $\displaystyle Y_d = \frac {6 (\frac {T_p}2 +\frac {Y_1} 2)}{6(\frac {T_p} 3 + \frac 2 Y_2} 3)} = \frac {3T_p +3Y_1)}{2T_p + 4 Y_2} $
    Should be:

    Starting from:

    $\displaystyle Y_d = \frac {\frac {T_p}2 +\frac {Y_1} 2}{\frac {T_p} 3 + \frac {2 Y_2} 3}}$

    Multiply through by $\displaystyle \frac 6 6$:

    $\displaystyle Y_d = \frac {6 (\frac {T_p}2 +\frac {Y_1} 2)}{6(\frac {T_p} 3 + \frac {2 Y_2} 3)}} = \frac {3T_p +3Y_1}{2T_p + 4 Y_2} $

    The remainder of the post is OK as is.
    Last edited by ebaines; May 21st 2013 at 08:09 AM.
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    May 2013
    From
    Oxford
    Posts
    4

    Re: Trying to 'reverse' a formula....

    Ah that's great - just what I needed - thank you!
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. How to reverse log
    Posted in the New Users Forum
    Replies: 1
    Last Post: Jun 30th 2012, 03:38 AM
  2. Reverse Formula like ohms law
    Posted in the Algebra Forum
    Replies: 2
    Last Post: Feb 18th 2010, 08:50 AM
  3. Reverse Derivatives?
    Posted in the Calculus Forum
    Replies: 0
    Last Post: Feb 5th 2009, 08:16 PM
  4. reverse solving of formula
    Posted in the Pre-Calculus Forum
    Replies: 4
    Last Post: Jan 6th 2009, 07:05 AM
  5. reverse
    Posted in the Discrete Math Forum
    Replies: 1
    Last Post: Aug 3rd 2007, 06:33 AM

Search Tags


/mathhelpforum @mathhelpforum