Page 1 of 1

RSI Identificator

Posted: 26 Jul 2019, 16:32
by ABC
Welche Methode wird für RSI Berechnung benutzt? SMA? Verstehe nicht wocher der Unterschied kommt....

Re: RSI Identificator

Posted: 27 Jul 2019, 22:01
by Christian
Hier der Code

Code: Select all

void CRelativeStrengthIndex::OnBarUpdate()
{
	float fRSI, fSumUp, fSumDown;

	DWORD dwBarIdx = m_pModule->BarIndex();

	if (m_pModule->BarIndex() > m_wPeriods) {
		
		fSumUp = fSumDown = 0.0f;
		for (WORD i = 0; i < m_wPeriods; ++i) {
			fSumUp += max(0.0f, Close(i) - Close(i+1));
			fSumDown += -(min(0.0f, Close(i) - Close(i+1)));
		}
		fSumUp = fSumUp / m_wPeriods;
		fSumDown = fSumDown / m_wPeriods;
		if(fSumUp + fSumDown == 0) {
			fRSI = 0;
		}
		else {
			fRSI = (fSumUp / (fSumUp + fSumDown) * 100);
		}

		m_Series[dwBarIdx] = fRSI;
	}
}