plot a moving average
talib.sma is the simple moving average. It takes the series to average and the length to average over, and gives back one value per
bar.overlay=true puts the line on the price bars instead of in a pane of its
own.give the length a name
let the chart user choose the length
Replace the number with The line is unchanged, because the control starts at 20. Open the script’s settings and change Length: the average is worked out at
the new length. The value is fixed for a run of the script; an input cannot change from bar to bar.The default must be a constant integer expression (
input.int. Its first argument is the value the control starts at, and its second is the title shown in the
settings.20, or 2 * 3). A value that changes per bar, such as close, is refused: Cannot call `input.int` with argument `defval`=`close`. An argument of `series float` type was used but a `const int` is expected. (series and const are qualifiers: see const, input, simple and series.)put bounds on the control
A length of zero makes no sense. The control now accepts only whole numbers from 1 to 200.
input.int takes minval and maxval.move the control in fives
step is the size of one increment. It may be written as a named argument like the others.What we built
A three-statement indicator with two settings. The numbers and the color that decide how it looks are no longer in the source.Next
Inputs
the other input functions and the arguments they share.
Plotting
the rest of what
plot accepts.