Discussions
»
Product and Service Development
»
Formula Assistance
»
Determining If A Moving Average Has Turned Up Within 'X' Number of Days
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 11/9/2005(UTC) Posts: 2
|
Long time lurker... first time poster.
I'm working on creating an exploration and one of the tests is determing if a MA has turned up within the last 60 days and I can't quite wrap my hands around the logic. I've tried (or think I've tried) counting the bars since turning up and conversely tried the alternate route which is trying an alert if the moving average is equal or lower within the last 60 days. Neither one seems to trigger correctly. If someone with more experience than I could point me down the right road I would be most grateful. Thanks! ScottE
If(BarsSince(Mov(C,20,S) > Ref(Mov(C,20,S),-1) < 60),1,0)
Or
20DaySame:=(Mov(C,20,S) = Ref(Mov(C,20,S),-1)); 20DayLower:=(Mov(C,20,S) < Ref(Mov(C,20,S),-1));
Alert(20DaySame OR 20DayLower,60)
|
|
|
|
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)
|
Hi Scott, I guess I am not fully understanding the problem? If you are looking to find when a condition is true in the most recent x-bars, use the Alert() function. The use of variables will also make your code easier to maintain and faster to execute: Code:
prd:=60;
ma:=mov(c,20,s);
condition:=roc(ma,1,%)>0;
alert(condition, prd);
will return a true value from an exploration if at any time in the last 60 bars of data, the one period ROC of the MA is positive. Is this what you are looking for? wabbit [:D]
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 11/9/2005(UTC) Posts: 2
|
Hi Wabbit,
I think that will work.... I didn't consider approaching it from a ROC perspective off of the MA.
The test in the exploration is to make sure that the trend hasn't been in place for so long as to make it ripe for reversal. I'll plug that into my exploration and give it a whirl.
Thanks again! ScottE
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Discussions
»
Product and Service Development
»
Formula Assistance
»
Determining If A Moving Average Has Turned Up Within 'X' Number of Days
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.