int CMOBV::GetSignal( int nIndex, UINT * pnCode ) { if( pnCode ) *pnCode = ITSC_NOTHING; if( !m_pKData || nIndex < 0 || nIndex >= m_pKData->GetSize() ) return ITS_NOTHING; PrepareCache( 0, -1, FALSE ); int nMaxDays = max( m_nDays1 , m_nDays2 ); double dLiminalLow = 0, dLiminalHigh = 0; if( !IntensityPreparePrice( nIndex, pnCode, nMaxDays, ITS_GETMINMAXDAYRANGE, &dLiminalLow, &dLiminalHigh, 0.5, 0.5 ) ) return ITS_NOTHING; double dPriceNow = m_pKData->MaindataAt(nIndex); if( dPriceNow < dLiminalLow && ( IsGoldenFork( nIndex, m_pdCache1, m_pdCache2 ) || IsGoldenFork( nIndex, m_pdCache2, m_pdCache3 ) ) ) { // 低位金叉 if( pnCode ) *pnCode = ITSC_GOLDENFORK; return m_itsGoldenFork; } if( dPriceNow > dLiminalHigh && ( IsDeadFork( nIndex, m_pdCache1, m_pdCache2 ) || IsDeadFork( nIndex, m_pdCache2, m_pdCache3 ) ) ) { // 高位死叉 if( pnCode ) *pnCode = ITSC_DEADFORK; return m_itsDeadFork; } return ITS_NOTHING; }
int CBBI::GetSignal( int nIndex, UINT * pnCode ) { if( pnCode ) *pnCode = ITSC_NOTHING; if( nIndex <= 0 ) return ITS_NOTHING; double dLiminalLow = 0, dLiminalHigh = 0; if( !IntensityPreparePrice( nIndex, pnCode, 0, ITS_GETMINMAXDAYRANGE, &dLiminalLow, &dLiminalHigh, 0.4, 0.6 ) ) return ITS_NOTHING; double dBBINow = 0, dBBILast = 0; if( !Calculate( &dBBILast, nIndex-1, FALSE ) || !Calculate( &dBBINow, nIndex, FALSE ) ) return ITS_NOTHING; double dNowHigh = m_pKData->ElementAt(nIndex).m_fHigh; double dNowLow = m_pKData->ElementAt(nIndex).m_fLow; double dNowClose = m_pKData->ElementAt(nIndex).m_fClose; double dLastHigh = m_pKData->ElementAt(nIndex-1).m_fHigh; double dLastLow = m_pKData->ElementAt(nIndex-1).m_fLow; double dLastClose = m_pKData->ElementAt(nIndex-1).m_fClose; if( dNowClose < dLiminalLow && dLastLow < dBBILast && dNowLow > dBBINow ) { // 低位趋势向上 if( pnCode ) *pnCode = ITSC_GOLDENFORK; return m_itsGoldenFork; } if( dNowClose > dLiminalHigh && dLastHigh > dBBILast && dNowHigh < dBBINow ) { // 高位趋势向下 if( pnCode ) *pnCode = ITSC_DEADFORK; return m_itsDeadFork; } return ITS_NOTHING; }