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

Notification

Icon
Error

Options
Go to last post Go to first unread
krunch  
#1 Posted : Wednesday, November 6, 2013 9:24:06 AM(UTC)
krunch

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 11/6/2013(UTC)
Posts: 1

Hi, I'm trying to build a code which gives a buy signal when the RSI is oversold, and the closing price crosses over the MA, however it will only give the signal if they are both true at the same time... i would like to modify it so that the RSI can be in the oversold position even a month before, and still give a buy signal when the close crosses the MA, even if the RSI was not oversold still!

here is the formula so far.

Cross(RSI(14),30) AND
Cross(CLOSE,Mov(C,20,S))

Thanks for the help
henry1224  
#2 Posted : Wednesday, November 6, 2013 12:37:46 PM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)
have a look at the Alert() function
wladirlima  
#3 Posted : Wednesday, February 4, 2015 6:40:33 PM(UTC)
wladirlima

Rank: Newbie

Groups: Registered Users, Subscribers, Unverified Users
Joined: 1/15/2015(UTC)
Posts: 5

Was thanked: 1 time(s) in 1 post(s)
Originally Posted by: krunch Go to Quoted Post
Hi, I'm trying to build a code which gives a buy signal when the RSI is oversold, and the closing price crosses over the MA, however it will only give the signal if they are both true at the same time... i would like to modify it so that the RSI can be in the oversold position even a month before, and still give a buy signal when the close crosses the MA, even if the RSI was not oversold still!

here is the formula so far.

Cross(RSI(14),30) AND
Cross(CLOSE,Mov(C,20,S))

Thanks for the help

 

you should try...

RSI(14)<30 AND C>MOV(C,20,S)

MS Support  
#4 Posted : Wednesday, February 4, 2015 9:27:06 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,960

Thanks: 92 times
Was thanked: 155 time(s) in 150 post(s)
wladirlima, This is a fairly old post, however the issue in your formula is that "Greater Than" and "Less Than" do not identify the point of crossing over. Both the Close Price and the RSI could have 'crossed over' months ago and Greater Than / Less Than would not be able to tell the difference. This is where the "Cross" function becomes useful, although having 2 conditions cross at the exact same point in time can oftentimes be a fairly rare occurrence. As henry1224 mentioned, the Alert function is useful for 'extending' a True / False condition to look back in time. So a simple example of this would be: Cross(C,Mov(C,20,S)) AND Alert(Cross(30,RSI(14)),30) What this formula would effectively do is look for the crossing of the Close and the Moving Average right now, but it would look for the Crossing of the RSI into oversold territory at any point in the last 30 periods meaning they do not need to be occurring at the same time in order for the overall condition to still be considered "True".
wladirlima  
#5 Posted : Thursday, February 5, 2015 11:34:17 AM(UTC)
wladirlima

Rank: Newbie

Groups: Registered Users, Subscribers, Unverified Users
Joined: 1/15/2015(UTC)
Posts: 5

Was thanked: 1 time(s) in 1 post(s)

you're right. the alert function makes more sense.

henry1224  
#6 Posted : Thursday, February 5, 2015 1:54:23 PM(UTC)
henry1224

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/29/2004(UTC)
Posts: 1,394
Location: Glastonbury, CT

Was thanked: 2 time(s) in 2 post(s)

Here are 2 systems Double Stoch Mo and Double RSI

*code* 

SM1:=100*(Mov(Mov(C-(.5*(HHV(H,5)+LLV(L,5))),3,E),3,E)/
(.5*Mov(Mov(HHV(H,5)-LLV(L,5),3,E),3,E)));
SM2:=100*(Mov(Mov(C-(.5*(HHV(H,20)+LLV(L,20))),3,E),3,E)/
(.5*Mov(Mov(HHV(H,20)-LLV(L,20),3,E),3,E)));
bc1:=Cross(SM2>65 AND C>Mov(C,40,S),0.5);
bc2:=Cross(SM1 >65 AND C>Mov(C,10,S),0.5);
sc1:=Cross(SM2<-65 AND C<Mov(C,40,S),0.5);
sc2:=Cross(SM1 <-65 AND C<Mov(C,10,S),0.5);
trade1:=If(bc1,1,If(sc1,0,ValueWhen(1,bc1+sc1,bc1 OR sc1=0)));
trade2:=If(bc2,1,If(sc2,0,ValueWhen(1,bc2+sc2,bc2 OR sc2=0)));
trade3:=If(sc1,1,If(bc1,0,ValueWhen(1,bc1+sc1,sc1 OR bc1=0)));
trade4:=If(sc2,1,If(bc2,0,ValueWhen(1,bc2+sc2,sc2 OR bc2=0)));

A:=Cross(trade1=0,0.5) OR (trade1=0 AND Cross(trade2=0,0.5));
B:=Cross(trade3=0,0.5) OR (trade3=0 AND Cross(trade4=0,0.5));
Signal2:=2*If(BarsSince(A)<BarsSince(B),-1,If(BarsSince(B)<BarsSince(A),1,0));

bc1:=Cross(RSI(17)>60 AND C>Mov(C,40,S),0.5);
bc2:=Cross(RSI(5) >60 AND C>Mov(C,10,S),0.5);
sc1:=Cross(RSI(17)<40 AND C<Mov(C,40,S),0.5);
sc2:=Cross(RSI(5) <40 AND C<Mov(C,10,S),0.5);
trade1:=If(bc1,1,If(sc1,0,ValueWhen(1,bc1+sc1,bc1 OR sc1=0)));
trade2:=If(bc2,1,If(sc2,0,ValueWhen(1,bc2+sc2,bc2 OR sc2=0)));
trade3:=If(sc1,1,If(bc1,0,ValueWhen(1,bc1+sc1,sc1 OR bc1=0)));
trade4:=If(sc2,1,If(bc2,0,ValueWhen(1,bc2+sc2,sc2 OR bc2=0)));
A:=Cross(trade1=0,0.5) OR (trade1=0 AND Cross(trade2=0,0.5));
B:=Cross(trade3=0,0.5) OR (trade3=0 AND Cross(trade4=0,0.5));
Signal:=If(BarsSince(A)<BarsSince(B),-1,If(BarsSince(B)<BarsSince(A),1,0));
0;Signal2;Signal; 

*/code*

when plotted as an indicator the Double Stoch Mo will be +2 or -2

The Double RSI code will be +1 or -1

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.