# Learning: how to get the High and Low price of a specific bar?

I am teaching myself how to code indicators.
How do I get values from a specific bar? For example, if I want the high price of the 5th bar back from the current bar, how would I do that? How can I choose that specific bar? How can I find the high price?
Thanks for helping me.

It really depends on what you’re trying to accomplish. Below are two different scenarios.

You can add something like this to your map{} and remember to add It to the return{}:

map{}

``````        const high5CandlesAgo = history.get(i - 5).high();
const low5CandlesAgo = history.get(i - 5).low();
``````

return{}

``````            high5CandlesAgo: high5CandlesAgo,
low5CandlesAgo: low5CandlesAgo
``````

and if you want too calculate a level of the current candle relative to the previous candles high or low etc…add it to the return and you can do something like this:

return{}

``````            high: d.high(),
open: d.open(),
close: d.close(),
low: d.low(),
``````
``````function trendPlotter
``````
``````   if (next !== null) {
// Calculate the center point between the prior high and the next candle's open
const centerPoint = (prior.high + next.open) / 2;
``````

hope that gives you some ideas…

Thankyou !

I will work on this soon

Relatively new user. No real computer coding skills but can hack

Quick Question.

Example where do I start to copy and paste code in order to build an indicator.

I can do this on ThinkorSwim all the time, but for some reason I am not immediately

Grasping the steps to place a new custom indicator on my platform

Are you able to quickly give me a 1,2,3 example? If so , I would greatly appreciate it.

Best wishes.

Fred

7/12/2023 11:58 PM