oyz79
Joined: 22 Mar 2009 Posts: 4
|
Posted: Fri Mar 12, 2010 7:28 pm Post subject: Help w/ RSI System |
|
|
I need help writing an RSI(2 system that searches for stocks that hit an RSI(2 <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(2 ", CLOSE_SERIES.RSI(2 );
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(), "" );
} |
|