Tradery Forum Index Tradery
Trading tools and community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help w/ RSI System

 
Post new topic   Reply to topic    Tradery Forum Index -> Trading systems
View previous topic :: View next topic  
Author Message
oyz79



Joined: 22 Mar 2009
Posts: 4

PostPosted: Fri Mar 12, 2010 7:28 pm    Post subject: Help w/ RSI System Reply with quote

I need help writing an RSI(2Cool system that searches for stocks that hit an RSI(2Cool<20 and then enter a long position for 20 days and exit at the end of the 20th day. Here's what I have and it clearly is not correct:

Series rsi;
unsigned int rsiperiod;

bool init()
{
// Add Default Chart
Pane defPane = getDefaultPane();
defPane.drawSeries( "SMA(20)", CLOSE_SERIES.SMA(20) );
// Add RSI Pane
Pane rsiPane = createPane( "RSI" );
rsiPane.drawSeries( "RSI(2Cool", CLOSE_SERIES.RSI(2Cool );

rsiperiod = 28;
rsi = CLOSE_SERIES.RSI(rsiperiod);
return true;
}

void run()
{
// If the RSI value for a stock reaches greater to or equal to
// 70. Print the Date, Symbol, RSI Value to the output screen
Index lastBar = barsCount() - 1;
if( rsi[ barsCount() - 1 ] <= 20 )
buyAtMarket ( lastBar - 20, 1000, "" );
sellAtClose( lastBar, getLastOpenPosition(), "" );
}
Back to top
View user's profile Send private message
vovay45



Joined: 09 Jan 2008
Posts: 356
Location: San Francisco

PostPosted: Sat Mar 13, 2010 3:00 am    Post subject: Reply with quote

My implementation of yours idea

Code:
//RSI-2-20-20
void run()
{
 Series rsi2 = closeSeries().RSI( 2 );
 Pane rsipane = createPane( "RSI 2" );
 rsipane.drawSeries( "rsi2", rsi2 );
 installTimeBasedExitAtClose( 20 );

    for( Index bar = 1; bar < size(); bar++ )
    {
        applyAutoStops( bar );
 
        if( !hasOpenPositions() && rsi2[ bar] <= 20 )   
   
            buyAtMarket( bar+1 , 10000, "Buy " );
    }
}


http://www.tradery.com/session?&cs=3447&i=100000&m=0&z=2&sh=100&v=10000&pe=12.5&pc=25&l=0&pv=0.5&a=10000&p=.2&c=5&t=Now&f=1 Year&ch=1&st=1&eq=1&tr=1&si=1&ou=1&de=2&b=969&r=1

VY
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Tradery Forum Index -> Trading systems All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group