Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

//@version=4

//
// Pine Script v4
//

// study(title, shorttitle, overlay, format, precision)


// https://www.tradingview.com/pine-script-
docs/en/v4/annotations/study_annotation.html
study(shorttitle = "SMAB_%", title="Simple Moving Average", overlay=true)

// MAPeriod is a variable used to store the indicator lookback period. In this


case, from the input.
// input - https://www.tradingview.com/pine-script-
docs/en/v4/annotations/Script_inputs.html
MAPeriod = input(17, title="MA Period")

// MA is a variable used to store the actual moving average value. In this case,
from the sma() built-in function
// sma - https://www.tradingview.com/pine-script-reference/v4/#fun_sma
MA = sma(close, MAPeriod)

// plot - This will draw the information on the chart


// plot - https://www.tradingview.com/pine-script-
docs/en/v4/annotations/plot_annotation.html
//plot(MA*1.03, color=color.red, linewidth=2)
plot(MA, color=color.blue, linewidth=2)
plot(MA*0.97, color=color.red, linewidth=2)
plot((close-MA*0.97)*100/close,color=color.orange,linewidth=2,transp=100)
//SM=(close-MA*0.97)*100/close

You might also like