Well the math formula looks like this:
100 x (current close / previous close - 1)
The code to perform that math calculation looks like this:
100 * (close / close[1] - 1)
You posted this question under the “Chart Studies” topic. So there is no perceived purpose for adding an input for x percentage. Had you posted this under “Thinkorswim Scans” or “Alerts and Notifications”, we would have a purpose for that input.
So since we are working out a solution for a Chart Study, about all we can do here is plot the percentage value on a lower subgraph:
declare lower;
def percentChange = 100 * (close / close[1] - 1);
plot data = percentChange;