usual things within a script { }
1 or more inputs,
some formulas,
1 or more plots,
think of the script function, as creating your own custum function/study.
when you use a built in study, like
MovAvgExponential, there are 4 input parameters that can be entered.
price
length
displace
show breakout signals
to use it , you could supply all 4 parameters,
def k = MovAvgExponential( close, 22, 0, yes);
then it calculates a number and assigns to k.
there are 3 outputs, plots, from this study. the default output value is the first plot.
an example script,
script stuff {
input a = 0;
input z = 0;
def b = a*5+z;
plot c = b+3;
plot d = b/3;
}
to use a script, use its name, and some parameters,
def g = stuff( 4, 5 );
the parameter(s) used within ( ) , will each be assigned to an input variable, in the script.
input a , will become equal to 4
input z , will become equal to 5
g will be equal to the first plot, c.
this could also be written as,
def g = stuff( 4, 5).c;
not all parameters need to be used, but you have to start with the left ( first). if you want to use the 2nd.
plot is used to send a number out of the script. the first plot is the default output.
to read the 2nd output plot, add d to the end.
def u = stuff( 4,5 ).d;
although plot is used to generate output, a script only produces a number. it can't draw anything.
https://tlc.thinkorswim.com/center/reference/thinkScript/Reserved-Words/script
https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/M-N/MovAvgExponential