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
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
303 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

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?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top