Rank: Newbie
Groups: Registered, Registered Users Joined: 4/6/2014(UTC) Posts: 2
|
Hello, I'm trying to write an indicator that will find a peak (call it "A"). Once it does, it should look for another peak (call it "B") within a certain time period before A occurred.
So far:
increasing:= REF(C,-2) - REF(C,-3) decreasing:= REF(C,-2) - REF(C,-1)
if( (increasing>0) AND (decreasing>0) A:=REF(C,-2) A:=0 {if the close 2 periods ago was greater than 3 periods ago, and also greater then the close 1 period ago, A is set to the close 2 periods ago}
After this how do I search for another peak within some time frame beforehand (call it N periods)?
my guess is:
increasing2:= REF(C, -2-N) - REF(C, -3-N) decreasing2:= REF(C, -2-N) - REF(C, -1-N)
if( (increasing2>0) AND (decreasing2>0) B:= REF(C,-2-N) B:=0
Any help would be appreciated Pat
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 10/29/2004(UTC) Posts: 1,394 Location: Glastonbury, CT
Was thanked: 3 time(s) in 3 post(s)
|
have a look at the following functions
Peakbars(Nth , data array , % minimum Change)
Peak( Nth ,Data Array , % Minimum Change)
BarsSince(Data Array)
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 4/6/2014(UTC) Posts: 2
|
Interesting, thank you!
I just started working on custom indicators, so I'm not entirely familiar with all the functions I can call.
|
|
|
|
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)
|
Using Alert() : Code:
lookback:=10;
pk:=Ref(C,-2)<Ref(C,-1) AND Ref(C,-1)>C;
{plot}
pk AND Ref(Alert(pk,lookback),-1);
or another way using BarsSince() : Code:
lookback:=10;
pk:=Ref(C,-2)<Ref(C,-1) AND Ref(C,-1)>C;
{plot}
pk AND Ref(BarsSince(pk),-1)<=lookback;
|
|
|
|
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.