High and Low of a Range

oskartinksw88

New member
Hello,

I borrowed some of this code:
https://usethinkscript.com/threads/intraday-hod-lod-for-thinkorswim.6365/#post-61699
for a study I am working on, in which I am trying to return the values for the HOD and LOD from a specific period (1800 to 0900). That is over two days (start of the Asian session and 30 minutes prior to the start of the NY session.

So basically, I am trying to trap time for the entire day. For example, if you were log into your account on Thursday at 11 a.m. and ran the study it would return the same value as if you log into your account 9 a.m. on Thursday. The value would not change until Friday.

Please find an attachment, where the study was added to the chart.

The study returns a value of "15,721.125"({HOD + LOD}/2) which is wrong based on what I desire. It uses the high, "15,895.75) from the 11:55 a.m. candle which is outside my range (the accurate high should be "15,750" established on the 8:30 a.m. candle).

The low, "15,546.50" was established at 12:15 a.m. candle, within the range I desire.

So the correct figure would be "15,648.25" (15,750 + 15,546.5)/2.

I would like the figure to be the static regardless of what timeframe you're trading on. Is that possible?

I'm new to learning ThinkScript.
Please find below what I have so far.

Thanks in advance for any assistance you can provide. Much appreciated.

declare hide_on_daily;
input OpenTime = 1800;
input EntTime = 0900;
input DurationMinutes = 15;

input showLabels = yes;

def durationSec = DurationMinutes * 15 * 60;
def secondsPassed = SecondsFromTime(OpenTime);

def HOD = HighestAll(if IsNaN(close[-1])
then high(period = "Day")
else Double.NaN);

def LOD = LowestAll(if IsNaN(close[-1])
then low (period = "Day")
else Double.NaN);


input length = 5;

def mid = (hod + lod)/2;

AddLabel(yes, "MP " + mid, Color.YELLOW);

plot MP = if secondsPassed >= 0 and secondsPassed <= durationSec then mid else double.NaN;

mp.SetDefaultColor(Color.YEllOW);
mp.HideBubble();
 
Last edited by a moderator:
Solution
Hello,

I borrowed some of this code:
https://usethinkscript.com/threads/intraday-hod-lod-for-thinkorswim.6365/#post-61699
for a study I am working on, in which I am trying to return the values for the HOD and LOD from a specific period (1800 to 0900). That is over two days (start of the Asian session and 30 minutes prior to the start of the NY session.

So basically, I am trying to trap time for the entire day. For example, if you were log into your account on Thursday at 11 a.m. and ran the study it would return the same value as if you log into your account 9 a.m. on Thursday. The value would not change until Friday.

Please find an attachment, where the study was added to the chart.

The study returns a value of...
Hello,

I borrowed some of this code:
https://usethinkscript.com/threads/intraday-hod-lod-for-thinkorswim.6365/#post-61699
for a study I am working on, in which I am trying to return the values for the HOD and LOD from a specific period (1800 to 0900). That is over two days (start of the Asian session and 30 minutes prior to the start of the NY session.

So basically, I am trying to trap time for the entire day. For example, if you were log into your account on Thursday at 11 a.m. and ran the study it would return the same value as if you log into your account 9 a.m. on Thursday. The value would not change until Friday.

Please find an attachment, where the study was added to the chart.

The study returns a value of "15,721.125"({HOD + LOD}/2) which is wrong based on what I desire. It uses the high, "15,895.75) from the 11:55 a.m. candle which is outside my range (the accurate high should be "15,750" established on the 8:30 a.m. candle).

The low, "15,546.50" was established at 12:15 a.m. candle, within the range I desire.

So the correct figure would be "15,648.25" (15,750 + 15,546.5)/2.

I would like the figure to be the static regardless of what timeframe you're trading on. Is that possible?

I'm new to learning ThinkScript.
Please find below what I have so far.

Thanks in advance for any assistance you can provide. Much appreciated.

declare hide_on_daily;
input OpenTime = 1800;
input EntTime = 0900;
input DurationMinutes = 15;

input showLabels = yes;

def durationSec = DurationMinutes * 15 * 60;
def secondsPassed = SecondsFromTime(OpenTime);

def HOD = HighestAll(if IsNaN(close[-1])
then high(period = "Day")
else Double.NaN);

def LOD = LowestAll(if IsNaN(close[-1])
then low (period = "Day")
else Double.NaN);


input length = 5;

def mid = (hod + lod)/2;

AddLabel(yes, "MP " + mid, Color.YELLOW);

plot MP = if secondsPassed >= 0 and secondsPassed <= durationSec then mid else double.NaN;

mp.SetDefaultColor(Color.YEllOW);
mp.HideBubble();

maybe this will work for you or give you some ideas.
this will find the high and low, of a time period, that can span over midnight.

https://usethinkscript.com/threads/average-daily-range-indicator-for-thinkorswim.244/#post-66296
 
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
229 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