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

Notification

Icon
Error

Options
Go to last post Go to first unread
kotatrader  
#1 Posted : Wednesday, April 27, 2011 5:10:00 PM(UTC)
kotatrader

Rank: Newbie

Groups: Registered, Registered Users
Joined: 3/27/2011(UTC)
Posts: 2

Hi there

I am trying to code an indicator to tell me (give me 1) when RSI(2) crosses above its simple moving average of 13 periods

I am trying

cross(rsi(2),mov(rsi(2),13,s)

The problem is that I am having several "false" triggers, i.e., I am getting 1 on my custom indicator when the RSI moving average is above the RSI, but not crossing it...

When there is a crossing I also get the correct result, i.e., 1 on the indicator.

I hope this is clear and appreciate any help...

It is indeed strange...

Thank you
wabbit  
#2 Posted : Thursday, April 28, 2011 1:59:07 AM(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)
Is the problem with only one particular symbol? If so, what symbol? Can you post a chart so we can see for ourselves?

There are some issues with some of the functions built-in to MS, which is why some people prefer to recode them, to "take positive charge" of them; I rarely use the built-in Cross() function.

There are a number of different ways to deal with crossing situations, each has their own advantages and disadvantages. One situation we want to try and avoid is the prevalence of N/A bars, so we look for indicators which respond fast to the new data. Below is an example of different methods to reproduce crossing events; the number in the curly braces indicates the bar on which the variable is first defined.

Code:

ind:=RSI(2); {2}
ma:=Mov(ind,13,S); {14}

test:=ind>ma; {14}

x0:=Cross(ind,ma); {15}
x1:=test AND Ref(test,-1)=0; {15}
x2:=test AND Alert(test=0,2); {14}
x3:=test AND ValueWhen(2,1,test)=0; {14}

{plot/return x0,x1,x2 or x3 here}


Notice the indicator is first defined on bar 2, its SMA is first defined on bar 14 but the Cross() function and the Ref() function methods take an extra bar to be defined, unlike the Alert() and Valuewhen() methods which start returning values as soon as the required test variable is defined.


wabbit [:D]

kotatrader  
#3 Posted : Saturday, April 30, 2011 7:10:34 AM(UTC)
kotatrader

Rank: Newbie

Groups: Registered, Registered Users
Joined: 3/27/2011(UTC)
Posts: 2

Thank you!
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.