This is a variation of an exponential moving average which follows the price pretty smoothly. Feel free to change the factor to adjust how closely it follows the price. I set the default to 0.2
Let me know if you want me to write code for any other indicators!