Difference between moving average and price labels

I am looking for a label script for the following:

Different between Current Price and the 200 day Simple Moving Average
100 divided by (the above number plus 15%) = What I am looking to be displayed.

I am sure this is simple, but I am struggling. Thanks for the help! I also would like this in a watch list column
Last edited:
Here's what I got without luck...

plot simpleMovingAvg200 = simpleMovingAvg(close, 200);
AddLabel(1, "SMA Price Difference: " + Round(simpleMovingAvg200-priceType.LAST, 2), color.RED);


Well-known member
2019 Donor

Here you go - hope this works for you.

Thanks for reply. This is close, I think the way I wrote out the data I was looking for wasn't clear. Here is an example:

These are made up numbers/Stock ABC

Current Price: $120
200 SMA: $119
Difference between the two: $1
Difference + 15% = $1.15
100 divided by 1.15 = 87 (rounded)

87 formula is the # I would like displayed in a chart label


New member

I'm really new to thinkOrSwim and ThinkScript.
I would like to create a a custom script to add a column in my SP500 watch list that indicates the SYMB whos current price is between SMA20 and SMA40 (timeframe would be in the hourly format). Any recommendation on good tutorials on how I can accomplish this task would be greatly appreciated




New member
Hello everyone,

I'm wondering if someone can help me with the code for 2 TOS watchlist column that do the following:

1. Column that shows the % difference between the Last candle closing price and the 4 EMA.

2. Column that shows the % difference between Mark and the 4 EMA.

Thank you in advance!


Staff member
@gbears96 This should give you the difference between the closing price and the 4 EMA:

# Display % difference between close and exponentialDeviationBands moving average

input length = 4;
def ema = ExpAverage(close, length);
def diff = absValue(close - ema) * 100 / close;
plot value = diff;

Similar threads