int CMA::GetSignal( int nIndex, UINT * pnCode ) { // 金叉或者死叉 int nSignal = GetForkSignal( nIndex, m_adwMADays, m_itsGoldenFork, m_itsDeadFork, pnCode ); if( ITS_ISBUY(nSignal) || ITS_ISSELL(nSignal) ) return nSignal; // 趋势 return GetTrendIntensity( nIndex, m_adwMADays, m_itsLong, m_itsShort, pnCode ); }
// 得到趋势信号 int CTechnique::GetTrendIntensity(int nIndex, CSPDWordArray & adwDays, UINT itsLong, UINT itsShort, UINT * pnCode ) { if( pnCode ) *pnCode = ITSC_NOTHING; if( nIndex <= 0 ) return ITS_NOTHING; int nRet = ITS_NOTHING; for( int k=1; k<adwDays.GetSize(); k++ ) { double dMALast1, dMALast2, dMANow1, dMANow2; if( !Calculate( &dMALast1, nIndex-1, min(adwDays[k-1],adwDays[k]), FALSE ) || !Calculate( &dMALast2, nIndex-1, max(adwDays[k-1],adwDays[k]), FALSE ) || !Calculate( &dMANow1, nIndex, min(adwDays[k-1],adwDays[k]), FALSE ) || !Calculate( &dMANow2, nIndex, max(adwDays[k-1],adwDays[k]), FALSE ) ) return ITS_NOTHING; if( dMANow1 >= dMALast1 && dMANow2 >= dMALast2 && dMANow1 > dMANow2 && (dMANow1-dMANow2)>=(dMALast1-dMALast2) && (ITS_ISBUY(nRet) || 1==k) ) { if( pnCode ) *pnCode = ITSC_LONG; nRet = itsLong; } else if( dMANow1 <= dMALast1 && dMANow2 <= dMALast2 && dMANow1 < dMANow2 && (dMANow1-dMANow2)<=(dMALast1-dMALast2) && (ITS_ISSELL(nRet) || 1==k) ) { if( pnCode ) *pnCode = ITSC_SHORT; nRet = itsShort; } else { if( pnCode ) *pnCode = ITSC_NOTHING; return ITS_NOTHING; } } return nRet; }