I see the idea you are summing the dd over the defined range, but since for already has a range 😄, the idea is to count all the small variations, I have reinvented the sma