RSI的买卖条件共三个:
// buy at the end of OverSold // sell at the end of OverBought // sell at the end of bullish bool RsiTrade::buy(int i) const
{
if (!macd.bullish(i+N+T-1)) {
return false;
}
if (isOverSold(i-1) && !isOverSold(i)) {
return true; // buy at the end of OverSold
}
return false;
}
bool RsiTrade::sell(int i) const
{
if (m_trade.buy.empty()) {
return false;
}
if (isOverBought(i-1) && !isOverBought(i)) {
return true; // sell at the end of OverBought
}
if (!macd.bullish(i+N+T-1)) {
return true; // sell at the end of bullish
}
return false;
}
|