I'm studying overreactions in the BVSP index and I need to check if after these reactions the return (R) reverts to the mean and in how many days. I started now, but I didn't find practical material regarding mean reversion. Can anyone help me with any tips?

Command used to capture and calculate exaggerated reactions signaled by dummy:

clear
getsymbols ^BVSP, fy(1993) freq(d) yahoo clear price (adjclose)
rename period refdate
rename r__BVSP R
sort refdate
gen R_1 = R[_n-1]
gen R_2 = R[_n-2]
gen R_3 = R[_n-3]
gen R_4 = R[_n-4]
gen R_5 = R[_n-5]
egen R_avg5 = rowmean (R_1 R_2 R_3 R_4 R_5)
egen R_sd5 = rowsd(R_1 R_2 R_3 R_4 R_5)
gen avg_sd2_5 = R_avg5 + (2 * R_sd5)
gen R_abs = .
gen R_n = R
drop R
replace R_abs = abs(R_n)
rename R_abs R
gen d_R_5 = 1 if R > avg_sd2_5
replace d_R_5 = 0 if R < avg_sd2_5
drop R
rename R_n R

Greetings