Skip to content

Instantly share code, notes, and snippets.

@denistex
Created June 4, 2020 09:53
Show Gist options
  • Save denistex/6d5fff014026cbef587932fa1940498d to your computer and use it in GitHub Desktop.
Save denistex/6d5fff014026cbef587932fa1940498d to your computer and use it in GitHub Desktop.
Custom SMA that duplicates the last bar
//@version=4
study("Custom SMA")
CustomSma(source, length) =>
sum = source
for i = 0 to length - 2
sum := sum + source[i]
sum / length
plot(sma(close, 14))
SMA = CustomSma(close, 14)
plot(barstate.islast ? SMA : na, color=color.red, offset=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment