Discussions
»
Product and Service Development
»
Formula Assistance
»
Need formula assistance for Expert advisor involving moving averages
Rank: Member
Groups: Registered, Registered Users Joined: 2/24/2010(UTC) Posts: 16
|
Hi can anyone help? i am trying to create an Expert Advisor that tells me that its bullish when the 50 day exp MA is rising for 3 days or more and that its bearish when the 50 day exp MA is falling for 3 days or more.
what is the formula involved?
thanks
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
In the Bullish window put...
Sum(C>Mov(C,50,E),3)=3;
and in the Bearish window put...
Sum(C<Mov(C,50,E),3)=3;
Roy
|
|
|
|
Rank: Member
Groups: Registered, Registered Users Joined: 2/24/2010(UTC) Posts: 16
|
Hi mstt, I was thinking of the 50D moving average line itself moving up 3 days and above as bullish and 3 days moving down as bearish. I do not intend to use the close of price above and below the moving averages.
Thus the formula you suggested may not apply?
kindly help
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi J
Perhaps if you'd tried my sugestion you would have found that it does work. How do I know this? Two reasons. Not only did I try it to see that it was correct, but I also have the advantage of knowing that an EMA ALWAYS moves toward the price. Therefore, if the price is above the EMA for three consecutive bars it follows that the EMA is moving up for three consecutive bars. Which is what you asked for isn't it?
Your suspicions about my solution would have been well founded if you'd asked about any other type of MA but you were specific about it being an exponential MA. Wilders (being exponential in nature) also follows this rule (always moving toward the price), and I see no reason to think that DEMA, TEMA or any other exponential MA variation would behave any differently.
Here's how you can simulate a standard exponential moving average function with MFL code. Essentially the value of "Rate" sets the proportion of old data (as calculated on the previous bar) to new data when calculating the new EMA value. If you think about it you'll realize that in this example there's an automatic bias of any new EMA value towards the data array being smoothed - and this is irrespective of the number of periods used. I hope this helps but don't just take my word for it - check it out for yourself.
{Exponential Moving Average} Pds:=Input("Periods",1,1000,10); Rate:=2 / (Pds+1); If(Cum(1)=1, C, PREV*(1-Rate) + C*Rate );
Roy
|
|
|
|
Rank: Member
Groups: Registered, Registered Users Joined: 2/24/2010(UTC) Posts: 16
|
Hmm this is something I could ponder about:)
anyway thanks for the insight. I will work on it.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi J
If you still need convincing that my suggested method offers a genuine solution to your problem then create an indicator with the following code and drop it onto any chart. Look for any differences in the results - there won't be any unless the MA method is changed.
{Compare 3 methods} M:=Mov(C,50,E); {1} Sum(C>M,3)=3; {2} Sum(M>Ref(M,-1),3)=3; {3} M>Ref(M,-1) AND Ref(M,-1)>Ref(M,-2) AND Ref(M,-2)>Ref(M,-3);
Roy
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Discussions
»
Product and Service Development
»
Formula Assistance
»
Need formula assistance for Expert advisor involving moving averages
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.