Rank: Advanced Member
Groups: Registered, Registered Users Joined: 3/19/2005(UTC) Posts: 2,995
Was thanked: 14 time(s) in 10 post(s)
|
j.k., J! You're the man! I said "hunting..."
I like playing around with this stuff, but at the end of the day I can't say it's fruitful. There are too many things that I don't know. The code below is my first attempt at working with cycles. It's pretty useless without a date correlation (which I can't fathom yet). In the mean time, I moved on to developing a ZigZag indicator based on the Periodicity Marker code and that looks more promising.
[code:1:4155cac992]{ Adjustable Cycle Indicator }
plot:=
Input("Plot: (Wave=1, Pk/Tr=2, Both=3)",1,3,3);
freq:=
Input("Frequency",0.01,500,5);
amp:=
Input("Amplitude",1,10,1);
offset:=
-Input("Offset",-10,10,0);
pds:=
Input("Restrict signals to last x periods [0=show all]",0,2520,0);
{ output restriction }
pds:=
LastValue(If(pds=0,LastValue(Cum(1))-1,pds));
restrict:=
BarsSince(Cum(1)=LastValue(Cum(1))-pds)>-1;
{ cycle indicator }
cycle:=Sin(Cum(freq))*restrict*amp;
cycle:=Ref(cycle,offset);
{ peak and trough indicator }
pk:=cycle=LastValue(Highest(cycle))*amp;
tr:=cycle=LastValue(Lowest(cycle))*amp;
{ plot }
If(plot=1,cycle,If(plot=2,pk,pk));
If(plot=1,0,If(plot=2,-tr,-tr));
If(plot=3,cycle,0)[/code:1:4155cac992]
|