0
votes

I've coded a simple Pine Script chart, which just mimics the chart I already use in TradingView.

However, when I overlay mine, I notice that the Pine Script SMAs are behaving differently to the same ones on the existing chart.

They are created the same:

Pine Script:

sma250 = sma(close,250)
plot(sma250, color=color.red)

TV chart: sma250 using a source of Close, and the timeframe is the same as the chart.

But when I overlay it, my SMA is in a completely different place and the angle is different to the existing SMA. They all appear to be more reactive. Am I missing something?

Thanks.

1

1 Answers

0
votes

Good Evening Mr Man,

Below is the Built-Ins Smooth Moving Average script and your line of code. As you can see they are different so the out put will be different. When adding a Built-Ins script to the right is a (?) which will explain that script further.

enter image description here

//@version=4
study(title="Smoothed Moving Average", shorttitle="SMMA", overlay=true, resolution="")

////Trading View In-Built code
len = input(250, minval=1, title="Length")
src = input(close, title="Source")
smma = 0.0
smma := na(smma[1]) ? sma(src, len) : (smma[1] * (len - 1) + src) / len
plot(smma, color=color.red)
//Link from Trading View Code -> The (?) to the right when you add the script to your chart
//https://uk.tradingview.com/chart/?solution=43000591343

///Your Code
sma250 = sma(close,250)
plot(sma250, color=color.blue)