Using the highest high

Cribbage

Member
This is confusing me more than it feels like it should, from the accumulationdistribution study on ToS:

length = 4
def range = Highest(high, length) - Lowest(low, length);
plot RangeRatio = range / range[length];

To me this is saying "highest high of the last 4 - lowest low of the last 4" is being divided by the same thing, meaning the outcome would always be 1. Where am I misunderstanding this?

Which brings me to another point: Is there a glossary of commands on this site? I would love it if there were a glossary section where different ThinkScript could be explained more thoroughly in plainspeak. I found the TOS learning center to be more confusing than helpful on the "Highest()" command.
 
Solution
@MerryDay
@Cribbage
i agree, most of the time, TD's code examples left me more confused.

here is my version of using bubbles to display values. i use \n to force the following text, on a new line.

Code:
AddChartBubble(AccDist crosses above SlowD, close, "RangeRatio: " +
RangeRatio + "\n" +"Range: " + Range + 
"\n" +"range[length]: " + range[length] , Color.violet, no);
@Cribbage We don't necessarily "need" a Glossary because we have the Thinkscript Learning Center for that... No need reinventing the wheel here...

As for the code you posted...

Ruby:
length = 4
def range = Highest(high, length) - Lowest(low, length);
plot RangeRatio = range / range[length];

First, notice how I used code tags which you could enter manually, or use the </> icon to post a block of Thinkscript code for better presentation... Most members use the Ruby syntax style works best for Thinkscript...

What the code does is to find the highest high and lowest low values within length bars, 4 in this case, and then divides that result, range, by by the range length bars ago... So it takes the highest high within the last 4 bars and subtracts the lowest low within the last 4 bars and then divides that by what the range value was 4 bars ago... That's what it does and that's how it reads...

Remember, Thinkscript is considered a self-documenting scripting language, meaning that it explains itself and thus requiring less documentation... And that is why it is better to use fully descriptive variable names rather than short cryptic variable names... That is why you see the variable "range" instead of "r", "RangeRatio" instead of "RR", "length" instead of "l", etc...

I hope this helps answer your question...
 
@Cribbage I asked myself many of the same questions. Like you, I delved into many of the TOS indicators and almost all the custom studies on this forum in order to understand ThinkScript. And sometimes it left me confused.
What helped me was the AddChartBubble. This allows the display of the values of variables by candle. By seeing the results of the calculations, I could get an understanding of what the functions were doing. Sometimes I had to do MANY chart bubbles in MANY studies to internalize the knowledge. However, it does get easier. TOS is standardized in its methodology. So learning subsequent functions becomes progressively easier.
nBHT2zN.png

A sample syntax for AddChartBubble is at the bottom of this script:
Ruby:
def data = if close > close[1] then close - Min(close[1], low) else if close < close[1] then close - Max(close[1], high) else 0;

def AD = TotalSum(data);
def AccDist = (AD - lowestall(AD)) /(highestall(AD) - lowestall(AD));
def stoch = StochasticSlow("over bought" = 100, "over sold" = 0, "k period" = 14, "d period" = 1).SlowD;
def SlowD =  (stoch - lowestall(stoch)) /(highestall(stoch) - lowestall(stoch));

input length = 4;
def range = Highest(high, length) - Lowest(low, length);
plot RangeRatio = range / range[length];

AddChartBubble(AccDist crosses above SlowD, close, "RangeRatio: " +RangeRatio +" | " +"Range: " +Range +" | " +"range[length]: " +range[length] , Color.violet, no);
To learn more about AddChartBubble:
https://usethinkscript.com/resources/thinkscript-addchartbubble-add-and-customize-chart-bubbles.13/
HTH
 
Awesome, thanks for the advice everyone. On the basis of the glossary, I know about the Learning Center on TOS, my point is look at the example they used for highest high (below). Rad's explanation was a dozen times easier to understand, and now if anyone else has a question about using the command its listed here. In any case - Thank you for the explanations - Appreciate it.

Example
Code:
input length = 20;

plot LowerBand = Lowest(low[1], length);
plot UpperBand = Highest(high[1], length);
plot MiddleBand = (LowerBand + UpperBand) / 2;

The plots in the example illustrate the Donchian Channels system where the Lower Band and the Upper Band are calculated as the minimum low and maximum high for the previous length bars. Note that the low and high for the current bar are left out of account. In order to implement this approach the [1] index is applied to the corresponding parameters.
 
Just coming to correct myself, reading through MerryDay's post - The link to the Code Reference center is what I was referring to in my request, I was just calling it a glossary. This is awesome. Thanks again!
 
@MerryDay
@Cribbage
i agree, most of the time, TD's code examples left me more confused.

here is my version of using bubbles to display values. i use \n to force the following text, on a new line.

Code:
AddChartBubble(AccDist crosses above SlowD, close, "RangeRatio: " +
RangeRatio + "\n" +"Range: " + Range + 
"\n" +"range[length]: " + range[length] , Color.violet, no);
 
Last edited:
Solution

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
337 Online
Create Post

Similar threads

Similar threads

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