Lowest and Highest functions in Thinkscript

I

imnobody

Member
I'm trying to figure out what Thinkscript is referencing when it uses these 'Lowest' and 'Highest' functions?
Is this the lowest low at that close? is it the highest high since whatever that length is(so say 14, the highest high in the last 14 periods?) etc

plot LowerBand = Lowest(low, length);

plot UpperBand = Highest(high, length);

llow = Lowest(low, perioda)

hhigh = Highest(high, perioda)
 
H

horserider

Well-known member
VIP
Warehouse
Highest
Highest (IDataHolder data, int length);

Default values: length: 12
Description
Returns the highest value of data for the last length bars.

Input parameters
ParameterDefault valueDescription
data-Defines data for which the highest value is found.
length12Defines period on which the highest value is found.
 
Last edited by a moderator:
H

horserider

Well-known member
VIP
Warehouse
input length = 10;

def HH = Highest(high, length);
def LL = Lowest(low, length);

plot "Williams %R" = if HH == LL then -100 else (HH - close) / (HH - LL) * (-100);
The example shows the Williams %R calculation. In particular, it is required to define the minimum low for the last length bars including the current bar. Therefore, to define the minimum, the example uses the Lowest function.
 
H

horserider

Well-known member
VIP
Warehouse
Hover over "Education" Click "Learning Center" then Search.
 
T

tomsk

Well-known member
VIP
Warehouse
I'm trying to figure out what Thinkscript is referencing when it uses these 'Lowest' and 'Highest' functions?
Is this the lowest low at that close? is it the highest high since whatever that length is(so say 14, the highest high in the last 14 periods?) etc

plot LowerBand = Lowest(low, length);
plot UpperBand = Highest(high, length);

llow = Lowest(low, perioda)
hhigh = Highest(high, perioda)
@imnobody I took a look at your short code segment above and noted a couple of things to highlight
Please note that all statements should end with a ";" otherwise the code editor will flag an error
You have also used two variables called llow and hhigh without using the "def" statement.
Here then is the corrected sequence of statements to make it pass through the code editor

Code:
input length = 14;
input perioda = 21;
plot LowerBand = Lowest(low, length);
plot UpperBand = Highest(high, length);
def llow = Lowest(low, perioda);
def hhigh = Highest(high, perioda);
That said, consider the following statement, I have assigned an arbitrary length of 21.

def llow = Lowest(low, length);

All this does is to determine the low for the last 21 bars, and assign that value to the variable llow;
Now if you wish to plot these values on your chart, you'll need to use the plot statement like so:

plot llow = Lowest(low, length);

Hope this helps
 

Top