PureBytes Links
Trading Reference Links
|
Easier said than done.
Difficulties involved:
1) Restrict peaks/troughs lookback to last 6 calendar months;
2) Find highest / 2nd highest / third highest/lowest peaks/troughs;
3) Get it coded into MetaStock without using the professional services
of a competent programmer. ;)
Try this:
====================
Peak/Trough averages
====================
---8<---------------------
{ Average of three highest peaks / lowest
troughs in an oscillator over last 6 months }
{ ©Copyright 2005 Jose Silva
For personal use only
http://www.metastocktools.com }
{ Oscillator/Indicator }
x:=MACD();
{ User input }
lbMth:=Input("Lookback months",1,12,6);
{ Restrict search to lookback period }
StMnth:=LastValue(Month())-lbMth;
StYear:=If(StMnth<1,
LastValue(Year())-1,LastValue(Year()));
StMnth:=If(StMnth<1,StMnth+12,StMnth);
lookback:=Year()>StYear
OR (Year()=StYear AND (Month()>StMnth
OR Month()=StMnth
AND DayOfMonth()>=LastValue(DayOfMonth())));
{ Highest/2nd/3rd peak values }
pk:=If(lookback,Peak(1,x,.001),Lowest(x));
pk1:=LastValue(Highest(pk));
pk2:=LastValue(Highest(If(pk=pk1,0,pk)));
pk3:=LastValue(Highest(
If(pk=pk1 OR pk=pk2,0,pk)));
{ Lowest/2nd/3rd trough values }
tr:=If(lookback,Trough(1,x,.001),Highest(x));
tr1:=LastValue(Lowest(tr));
tr2:=LastValue(Lowest(If(tr=tr1,0,tr)));
tr3:=LastValue(
Lowest(If(tr=tr1 OR tr=tr2,0,tr)));
{ Average of last 3 peak/trough values }
avgPk:=(pk1+pk2+pk3)/3;
avgTr:=(tr1+tr2+tr3)/3;
{ Plot in own window }
x;avgPk;avgTr
---8<---------------------
jose '-)
http://www.metastocktools.com
--- In equismetastock@xxxxxxxxxxxxxxx, "Andrew Tomlinson"
<andrew_tomlinson@xxxx> wrote:
> That was too easy. How about this one - I want to take the average
> of the three highest peaks in an unbounded oscillator over the last
> 6 months (also the three lowest, but I'm assuming that will flow
> from the first answer).
>
> Any takers?
>
> Best
> Andrew
>
>
>
>
> -----Original Message-----
> From: Roy Larsen [mailto:rlarsen@x...]
> Sent: Thursday, March 10, 2005 6:18 PM
> To: equismetastock@xxxxxxxxxxxxxxx
> Subject: Re: [EquisMetaStock Group] How to count the number of
> occurences ?
>
>
> Hi Marco
>
> Is this what you mean?
>
> R:=RSI(C,14);
> Cum(R<10);
> Cum(R<20 and R>=10);
> Cum(R<30 and R>=20);
> Cum(R<40 and R>=30);
> Cum(R<50 and R>=40);
> Cum(R<60 and R>=50);
> Cum(R<70 and R>=60);
> Cum(R<80 and R>=70);
> Cum(R<90 and R>=80);
> Cum(R>=90);
>
>
> Kind regards
>
> Roy
> www.metastocktips.co.nz
>
>
>
> ----- Original Message -----
> From: "khamsina11" <Khamsina11@xxxx>
> To: <equismetastock@xxxxxxxxxxxxxxx>
> Sent: Friday, March 11, 2005 10:48 AM
> Subject: [EquisMetaStock Group] How to count the number of
> occurences ?
>
>
> Hi,
>
> I would like to know (for all the data available) the number of
> times an indicator has been within an interval.
>
> For example, with a RSI : 0-9, 10-19, 20-29..... until 100.
>
> Thanks for your help,
>
> Marco
------------------------ Yahoo! Groups Sponsor --------------------~-->
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/BefplB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/equismetastock/
<*> To unsubscribe from this group, send an email to:
equismetastock-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|