Keeping the angle measurement the same for holding position

I tried and it didn't work, too! You can see, this is graph I got for the angle measured by the accelerometer. In the holding part, it returns to zero and does not keep its position at -40 degrees (and sometimes provides more angle that the actual angle). Accelerometer uses this equation to measure the angle:

angleAccX =   atan2(sgZ*accY, sqrt(accZ*accZ + accX*accX)) * RAD_2_DEG; // [-180,+180] deg

question to arduino forum