# Can anybody help to explain these scripts?

#### firefox

##### New member
Hi,

I am a newbie and having difficulty in understanding these TOS lines to determine the peaks. Would appreciate if anybody can help to explain what these lines do and is h1 refers to previous peak and h2 refers to current peak?

def h1 = Highest(high, 20)[15];
def h2 = Highest(high, 15);
def os1=GetMaxValueOffset(high, 20)[15];
def os2=GetMaxValueOffset(high, 15);

Maybe this will help.

The indexing operator [] is used to access the previous or future data in an array of data. The square brackets indicate the shift against the current moment. The positive values of the shift represent the values in the past, the negative shift values represent the values in the future. The indexing operator can be applied to fundamental data, function outputs, indicator outputs, variables, etc.

Example 1
input price = close;
input shift = 5;
plot PastPrice = price[shift];
plot FuturePrice = price[-shift];

Draws shifted price plots.

Example 2
plot PastMACD = MACD().Avg[10];

Shows the smoothed MACD value 10 bars ago.

Last edited by a moderator:
Thank you @horserider for your quick reply. So does it mean :

def h1 = Highest(high, 20)[15];
Is referring to the highest price 15 bare ago for the last 20 bars

and

def h2 = Highest(high, 15);
refers to the current highest price for the last 15 bars.

Is my understanding correct?

Last edited by a moderator:
Highest high of past 20 bars shifted 15 bars

Confusing unless you are a math wizard. Plot h1 and h2 and look at what it does.
plot h1 = Highest(high, 20)[15];
plot h2 = Highest(high, 15);

Highest high of past 20 bars shifted 15 bars

Confusing unless you are a math wizard. Plot h1 and h2 and look at what it does.
plot h1 = Highest(high, 20)[15];
plot h2 = Highest(high, 15);

Thank you so much. You gave me a great idea to use plot function to View what it does. I will go and try it. Thanks again for solving my problem.

### Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
379 Online

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