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

Notification

Icon
Error

Options
Go to last post Go to first unread
slice40  
#1 Posted : Wednesday, July 9, 2008 5:33:32 PM(UTC)
slice40

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)
wabbit  
#2 Posted : Wednesday, July 9, 2008 6:33:52 PM(UTC)
wabbit

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]

slice40  
#3 Posted : Wednesday, July 9, 2008 8:06:51 PM(UTC)
slice40

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)
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.