logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
eddie.m  
#1 Posted : Tuesday, February 26, 2013 5:59:42 PM(UTC)
eddie.m

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/20/2012(UTC)
Posts: 152

Was thanked: 1 time(s) in 1 post(s)

Hi Roy, [:)]

I have a big question for you which I am sure your expertise will turn into a short answer and easy code. [:D]

What value must the Close tomorrow be to make a rising 25-day EMA equal or lower than the EMA value today, and conversely, what value must the Close tomorrow be to make a falling 25-day EMA equal or higher than the EMA value today?

Thank you in advance.

mstt  
#2 Posted : Tuesday, February 26, 2013 8:15:19 PM(UTC)
mstt

Rank: Advanced Member

Groups ready for retrieval: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Hi Ed

There's a simple rule for determining where the price will touch or cross over any EMA. I'm not sure if the same rule applies to DEMA, TEMA and so on, but it definitely does apply to EMA and Wilders. The others too I think. The rule is that an EMA ALWAYS moves toward the price or data array being smoothed. This means that for the price to touch (equal) the EMA on the next bar it must move to the current value of the EMA. If the price crosses over an EMA the the EMA will reverse direction and move towards the new price. The only situation where the EMA will hold its value at the current level is when the new price equals the old EMA value.

The rule again... an EMA ALWAYS moves toward the price or data array being smoothed.

The reason for this is that an EMA is made up of two components, one including fragments of all past data (its PREV value), and the other based solely on the value of current data.

Here's the basic makeup of an EMA. For Wilders() the "Rate" is changed to "Pds" and the starting value after the lead-in N/A period is based on an SMA of the same length.

Code:


{Exponential Moving Average}
Pds:=Input("Periods",1,1000,25); 
Rate:=2 / (Pds+1); 
If(Cum(1)=1, C, C*Rate + PREV*(1-Rate));



"C*Rate + PREV*(1-Rate)" is where the appropriate proportions of previous and current values are added together to make up the composite EMA value.

Here's another formula you might like to experiment with. I don't know who the author is so can't attribute it to anyone in particular.

Code:


{EMA Lookahead}
A:=Input("EMA Target Value",0,20000,10);
D:=Input("Periods",2,200,10);
F:=2/(1+D);
 {Price required for given inputs}
(A-(1-F)*Mov(C,D,E))/F;



Roy

eddie.m  
#3 Posted : Wednesday, February 27, 2013 7:14:51 PM(UTC)
eddie.m

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/20/2012(UTC)
Posts: 152

Was thanked: 1 time(s) in 1 post(s)

Hello Roy, [:)]

Thank you for your clear explanation and formula. [:D] I did not know it's called 'lookahead'. [:O]

I searched for other lookahead formulas on yahoo.com and found you at http://trader-online.tk">http://trader-online.tk MACD 0 centerline.

I got the hang of your EMA LOOKAHEAD: prices going down give a rising EMA-L and vice-versa.

I have the Close at $42 and EMA-L at -137. A few weeks later, the Close is $48 and EMA-L is -158, all negative numbers.

I used your default settings for EMA-L: 10, 10.

I can’t figure it out: if the Close is at $42 must the Close tomorrow be at -137 for EMA-L to be equal or lower that today’s EMA-L? What is going on? [:S]

eddie.m  
#4 Posted : Friday, March 1, 2013 7:28:54 PM(UTC)
eddie.m

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/20/2012(UTC)
Posts: 152

Was thanked: 1 time(s) in 1 post(s)

Hello Roy, [:)]

For the past two days your Sphinx-like silence became suspect. I felt as if you wanted me to experiment more with EMA-L.

[:D] The genius in me finally made me understand the secret message of EMA-L: the exaggerated negative values do not matter.

All I needed to do is to look at the y-axis how far up or down EMA-L travels and see true values that do not go too far from the Closes. [:O]

In so doing, I noticed that what previously appeared to be -138 in the Data Window is in fact $52.25 on the chart's y-axis, meaning that the 10-day EMA when the Close today is $42 must be $52.25 for EMA-L to turn up tomorrow. Am I correct?

I came across such puzzles (-138 ???) 2-3 times in the past, years apart, but I did not bother to dig deep. It is amazing how many Indicators the Bar charts can produce! … [H]

Can you please elaborate: what would it take to have EMA-L show the real Close values, not artificial negative numbers? (Is ‘artificial’ the correct name?)

wabbit  
#5 Posted : Saturday, March 2, 2013 1:40:34 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
I'm sure Roy is just busy getting on with enjoying life.. You've broken one of he fundamental rules of public forums: you've addressed your topic to one particular person, when there are loads of people who could be addressing your issue. Our of respect for Roy though, we won't wade into the discussion unless invited. Next time, if you want to discuss issues with particular individuals, send them a PM. You'll have to wait for Roy to put down his beer.... wabbit [:D]
mstt  
#6 Posted : Saturday, March 2, 2013 12:23:46 PM(UTC)
mstt

Rank: Advanced Member

Groups ready for retrieval: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Hi Ed

Yes, it was my hope that you would work with the information I initially gave you. As I mentioned, the lookahead indicator was not created by me, and I should have added that it appears to give results that are way off (negative values for example). From memory, though, I believe it does do exactly what it is supposed to do.

Your additional questions will require a little more thought on my part, plus time testing my conclusions. As Wabbit has suggested I have a life outside of MetaStcok and the Equis Forum, so you might need to wait a little bit longer before I attempt to fill in the blanks.

If anyone else has any thoughts on Ed's questions please feel free to jump in - I will not be offended.

Roy
wabbit  
#7 Posted : Tuesday, March 5, 2013 6:20:43 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
eddie.m wrote:
I have the Close at $42 and EMA-L at -137. A few weeks later, the Close is $48 and EMA-L is -158, all negative numbers.

I used your default settings for EMA-L: 10, 10.

I can’t figure it out: if the Close is at $42 must the Close tomorrow be at -137 for EMA-L to be equal or lower that today’s EMA-L? What is going on?


If you read the code provided (the code is correct) the solution is simple : You have entered variable values such that the question you asking is, "What does the CLOSE price have to be on the next bar for the 10 period EMA of CLOSE prices to be $10?" That's why you're getting negative results. If your EMA was somewhere near the $42 mark and the next bar had a price of -$137, the 10 period EMA would be near $10.

If you want to know what the price has to be on the next bar such that there is no change in the value of the EMA, the answer is the same price as the EMA on the current bar. You can prove this mathematically.

If you want to know what the price has to be on the next bar for two EMAs to cross, you can easily work this out from first principles, resolving to find the required price and the value at which the cross will occur; it's simple algebra and the result can be programmed in MS.


wabbit [:D]

eddie.m  
#8 Posted : Wednesday, March 6, 2013 12:43:30 AM(UTC)
eddie.m

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/20/2012(UTC)
Posts: 152

Was thanked: 1 time(s) in 1 post(s)
Dr. Frankenstein is on the loose here. [6]
wabbit  
#9 Posted : Wednesday, March 6, 2013 2:29:25 AM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
What? You've asked a question and I've answered it. Please don't come back with comments which can be misinterpreted... either say, "thank you" or ask for more information.


wabbit [:D]

Users browsing this topic
Guest (Hidden)
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.