# Plot Lowest and Highest using IDataHolder()

#### 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

Code:
``````plot LowerBand = Lowest(low, length);
plot UpperBand = Highest(high, length);
llow = Lowest(low, perioda)
hhigh = Highest(high, perioda)``````

Highest (IDataHolder data, int length);
Default values: length: 12
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.

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.

Code:
``````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);``````

Last edited by a moderator:
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.

Code:
``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:

Code:
``plot llow = Lowest(low, length);``

Hope this helps

When using GetValue (IDataHolder data, IDataHolder dynamic offset, int max offset) and setting synamicoffset > 5 and max offset to a value > 0, with chart aggregationperiod set to minute, the function seems to fail to deliver a result. Simply changing the max offset to 0 fixes my issue.

Hello,

I am trying to find the highest of several values for a scanner I am working on. I want to do something like
Code:
``plot highestHigh = Highest(high, 100);``
Which works fine until I come across stock that are recently IPO'd and do not have 100 days of data yet. In this case Highest returns N/A. If there a way to work around this. I tried to calculate the number of bars available however it doesn't seem like a variable number can be passed to the Highest function.

Any help would be greatly appreciated.

Thanks,
Nathan

HI Guys, how can i do the math as a indicator on
current price / lowest in past 20 days (by percenentage)

Any help is appreciated!

HI Guys, how can i do the math as a indicator on
current price / lowest in past 20 days (by percenentage)

Any help is appreciated!
I moved your post to this thread. There are several examples of lowest and explanations.

87k+ Posts
211 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?