JOUR=0
MM7=average[7](Close[JOUR])
MM20=average[20](Close[JOUR])
MM50=average[50](Close[JOUR])
criterebreakMM7=close[JOUR]>MM7 and close[JOUR+1]<MM7[1]
criterecap=(volume[JOUR]*close[JOUR]>100000) and (volume[JOUR]>5000) and (close[JOUR]>0.1)
x1 = barindex[JOUR]
x2=square(x1)
y=MM20
length = 20
S11 = summation[length](x2) - square(summation[length](x1))/length
S12 = summation[length](x1*x2) - (summation[length](x1) * summation[length](x2))/length
S22 = summation[length](square(x2)) - square(summation[length](x2))/length
Sy1 = summation[length](y*x1) - (summation[length](y)*summation[length](x1))/length
Sy2 = summation[length](y*x2) - (summation[length](y)*summation[length](x2))/length
//max1 = average[length](x1)
//max2 = average[length](x2)
//may = average[length](y)
//b2 = ((Sy1 * S22) - (Sy2*S12))/(S22*S11 - square(S12))
b3 = ((Sy2 * S11) - (Sy1 * S12))/(S22 * S11 - square(S12))
//b1 = may - b2*max1 - b3*max2
//qr = b1 + b2*x1 + b3*x2
criteremath=b3>0
critereMM50=MM50>MM50[1]
ACHAT=criterecap and criterebreakMM7 and criteremath and critereMM50
SCREENER [ACHAT]