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

Notification

Icon
Error

Options
Go to last post Go to first unread
james  
#1 Posted : Saturday, February 18, 2006 12:10:52 PM(UTC)
james

Rank: Newbie

Groups: Registered, Registered Users
Joined: 2/18/2006(UTC)
Posts: 5

[size=9:b9afbc29d7]I'm a newbie and I have read the documentation related to formulas.[/size:b9afbc29d7] I'm looking for a way to find the value of the last peak of a function (like moving average or else). My objective is to be able to say: sell if the moving average is down more than 2% since last peak. The last peak is visually easy to identify but I don't kow how to write this. A peak is a value of the moving average surrounded by to lower values of the moving average. The problem is that I don't know when the peak has occured. Could be last week, last month, last year... Does anyone know who to do this?
Jose  
#2 Posted : Saturday, February 18, 2006 2:01:40 PM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
James, try adapting this MS indicator code to your needs: [code:1:689363cda4] ============================ Indicator Peak/Trough values ============================ ---8<--------------------------- { http://www.metastocktools.com } { User inputs } pds:=Input("Indicator periods",1,2600,21); val:=Input("Indicator peak/trough [1~100] value",1,100,1); plot:=Input("[1]Peak/Trough signals, [2]Values, [3]SMA, [4]2+3",1,4,4); { Indicator example - Simple Moving Average } x:=Mov(C,pds,S); { Indicator simple peak/trough } pk:=Ref(x,-1)>x AND Ref(x,-1)>Ref(x,-2); tr:=Ref(x,-1)<x AND Ref(x,-1)<Ref(x,-2); { Indicator peak/trough values } pkVal:=ValueWhen(val,pk,Ref(x,-1)); trVal:=ValueWhen(val,tr,Ref(x,-1)); { Select plot } pkPlot:=If(plot=1,pk,If(plot=2,pkVal,x)); trPlot:=If(plot=1,-tr,If(plot=2,trVal,x)); { Plot on price chart } If(plot=4,x,trPlot); { Green } If(plot=4,trVal,trPlot); { Red } If(plot=4,pkVal,pkPlot) { Blue } ---8<--------------------------- [/code:1:689363cda4] You could then reference the above values for your exit signal: [code:1:689363cda4] { User input } pr:=Input("Sell if x% down from last peak", 0,100,2)/100; { Reference indicator & peak values } indikator:=FmlVar("Indicator Peak/Trough values","X"); pkVal:=FmlVar("Indicator Peak/Trough values","PKVAL"); { Sell signal } sell:=indikator<pkVal*(1-pr); { Plot in own window } sell [/code:1:689363cda4] jose '-)
james  
#3 Posted : Sunday, February 19, 2006 11:24:18 AM(UTC)
james

Rank: Newbie

Groups: Registered, Registered Users
Joined: 2/18/2006(UTC)
Posts: 5

Thank you for your help. Unfortunaltely I don't manage to get what I'm looking for. I would like to see a buy/sell signals (using the expert advisor) when I'm 1% away from the peak/tough of the MA. With yout formula I see more or less how to do the peak/tough and witht the expert advisor I too many signals. I don't see successive buy and sell signals ( buy then sell then buy ...) but I rather see: sell sell sell sell sellsell sell sell buy sell buy buy buy buy buy sell buy ... no sense stuff.
StorkBite  
#4 Posted : Sunday, February 19, 2006 6:14:58 PM(UTC)
StorkBite

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/19/2005(UTC)
Posts: 2,995

Was thanked: 14 time(s) in 10 post(s)
Hi James- I noticed that there are 2 accounts using your IP address. Are you also known as 'teofilocubilla'? We just want to keep it straight. There are numerous posts on the forum about filtering redundant signals; I'd definitely start with that. Here's an example that I use: [code:1:656c86d3d8]buy:= c> mov(c,10,e); sell:= c< mov(c,10,e); buy and barssince(ref(buy, -1)) > barssince(ref(sell, -1))[/code:1:656c86d3d8] You will also want to check out the FAQ; and, the latch function video. Ultimately, whatever signals are produced (by any system) will have to be interpreted by you. There are no perfect indicators. IMO, trying to achieve a +/- 1% accuracy with any technical indicator seems a bit overzealous. Still, in your snapshot above, it appears that your indicator is already very close to the MA peaks and troughs. If you are having trouble with the syntax of your Expert, post what you have already, and we'll help you tweak it... the user's manual has an entire chapter on Experts. http://forum.equis.com/viewtopic.php?t=928
sportrider  
#5 Posted : Sunday, February 19, 2006 8:24:41 PM(UTC)
sportrider

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/12/2005(UTC)
Posts: 141
Location: Brooklyn,NY

Thanks to the both of you .Patrick for putting it together and you G-stockman for pointing me to the tutorial I found it enlightning.
james  
#6 Posted : Monday, February 20, 2006 6:24:07 AM(UTC)
james

Rank: Newbie

Groups: Registered, Registered Users
Joined: 2/18/2006(UTC)
Posts: 5

> Are you also known as 'teofilocubilla'? No. I just have one user. You know, 'teofilocubilla' and me might have the same IP if we're behind the same proxy. In fact millions of users could appear to have the same IP for your web site. I'm looking at the links you provided. Thank you.
StorkBite  
#7 Posted : Monday, February 20, 2006 8:15:40 AM(UTC)
StorkBite

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/19/2005(UTC)
Posts: 2,995

Was thanked: 14 time(s) in 10 post(s)
Quote:
You know, 'teofilocubilla' and me might have the same IP if we're behind the same proxy. In fact millions of users could appear to have the same IP for your web site.
I hope one day we might have a million Equis users. Anyway, I was just curious... always glad to have another active member! :ok:
james  
#8 Posted : Monday, February 20, 2006 8:56:36 AM(UTC)
james

Rank: Newbie

Groups: Registered, Registered Users
Joined: 2/18/2006(UTC)
Posts: 5

I've made some progress towards the solution I'm looking for. I'm not there yet but I think I can make it (remember I'm a newbie!). If/when I make it I'll post what I've done here (probably) towmorrow ... I have to do other thinks now :bye:
james  
#9 Posted : Monday, February 20, 2006 9:24:11 PM(UTC)
james

Rank: Newbie

Groups: Registered, Registered Users
Joined: 2/18/2006(UTC)
Posts: 5

Here is what I have done. I've acheived the result that I wanted. This is not a great indicator as is. It must be complemented with other indicator/information. This is what I've done: Indicators on the charts: EMA(10) (in blue) 3 Top ( in red)
[code:1:54bdcaa7c7]pds:=10; val:=1; x:=Mov(C,pds,E); pk:=Ref(x,-1)>x AND Ref(x,-1)>Ref(x,-2); pkVal:=ValueWhen(val,pk,Ref(x,-1)); pkVal;[/code:1:54bdcaa7c7] 2 Bottom ( in green)
[code:1:54bdcaa7c7]pds:=10; val:=1; x:=Mov(C,pds,E); tr:=Ref(x,-1)<x AND Ref(x,-1)<Ref(x,-2); trVal:=ValueWhen(val,tr,Ref(x,-1)); trVal; [/code:1:54bdcaa7c7] In the Expert advisor: Symbol buy (green arrow)
[code:1:54bdcaa7c7]pr:=0.01; pds:=10; x:=Mov(C,pds,E); trVal:=FmlVar("2 Bottom","TRVAL"); buy:=trVal*(1+pr)<x; pkVal:=FmlVar("3 Top","PKVAL"); sell:=pkVal*(1-pr)>x; buy AND BarsSince(Ref(buy, -1)) > BarsSince(Ref(sell, -1))[/code:1:54bdcaa7c7] Symbol sell (red arrow)
[code:1:54bdcaa7c7]pr:=0.01; pds:=10; x:=Mov(C,pds,E); trVal:=FmlVar("2 Bottom","TRVAL"); buy:=trVal*(1+pr)<x; pkVal:=FmlVar("3 Top","PKVAL"); sell:=pkVal*(1-pr)>x; sell AND BarsSince(Ref(sell, -1)) > BarsSince(Ref(buy, -1))[/code:1:54bdcaa7c7] Thanks again for your help.
StorkBite  
#10 Posted : Monday, February 20, 2006 9:43:03 PM(UTC)
StorkBite

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/19/2005(UTC)
Posts: 2,995

Was thanked: 14 time(s) in 10 post(s)
Nice! Thanks for sharing!
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.