Intraday HOD & LOD for ThinkorSwim

@XeoNoX thank you for your thorough response! I get the idea now for what I want I'd want the -1.00. So last question if I wanted this for the 1 DAY 1 Min chart what would I need to tweak to get it to work? Or is that even possible?
 

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

This is not meant for the chat, it a scanner and a built for a data point. there is no 1minute for high of DAY, its either the high of the day or its not. your not scanning for high of the minute, atleast i assume your not. however you can use the minutes chart to look for the high of the day. The end goal is for high of the day, how you deiced to view it is up to you. To put it in perspective.... you can count to 100 by 1s or by 2s, or by 5s, the end goal is for you get to get to 100, how you get there is up to you. Take a few seconds of our time and Load the high/low graph column into thinkorswim and you will hopefully understand how it works.

keep in mind TOS scanners only scan once every few minutes, as mentioned before thats why its better to relax the highlowdegree threshold a bit.
 
Last edited:
Hi, all -

I'm looking for the thinkscript logic to add code to any lower study such that it plots an arrow whenever the lower study makes a new high AND the current bar close is not making a new high over the last 'x' number of bars. Any guidance? Much appreciated...

Added an example below where I've marked the spot where I'd love to have an arrow appear.

aapl.jpg
 
@malone1020 I don't know if this is what you want, I don't know where I found it, I scanned D and 5 minute and it scans for high of day, it works for that , at least after hours, have not tried during market hours.

Code:
input marketOpen = 930;
input marketClose = 1600;
input intraDaySpan = {Default "SameDay" , "OverNight"};
input numberOfDays = 1;
input numberOfYears = 0;
def okToPlot = GetLastDay() - numberOfDays <= GetDay() and GetLastYear() - numberOfYears <= GetYear() ;
def OpenCounter = SecondsFromTime(marketOpen);
def CloseCounter = SecondsTillTime(marketClose);
def MarketHours = if OpenCounter >= 0 and CloseCounter >= 0 then 1 else 0;
def beforeMidnight = OpenCounter >= 0 and CloseCounter <= 0;
def afterMidnight = OpenCounter <= 0 and CloseCounter >= 0 ;
def Today ;
def hideChartBubbles ;
rec DailyHigh ;
rec DailyLow ;
switch (intraDaySpan) {
case "SameDay":
Today = if GetDay() != GetDay()[1] then 1 else 0;
DailyHigh = if MarketHours then if high > DailyHigh[1] then high else DailyHigh[1] else high;
DailyLow = if Today then low else if MarketHours then if low < DailyLow[1] then low else DailyLow[1] else low; hideChartBubbles = MarketHours;
case "OverNight": Today = 0;
DailyHigh = if beforeMidnight or afterMidnight then if high > DailyHigh[1] then high else DailyHigh[1] else high;
DailyLow = if beforeMidnight or afterMidnight then if low < DailyLow[1] then low else DailyLow[1] else low;
hideChartBubbles = beforeMidnight or afterMidnight;
};
def TodaysHigh = if okToPlot and hideChartBubbles then DailyHigh else Double.NaN;
def TodaysLow = if okToPlot and hideChartBubbles then DailyLow else Double.NaN;
#Alert(DailyHigh > DailyHigh[1] and hideChartBubbles, "New High", Alert.BAR, Sound.RING);
#Alert(DailyLow < DailyLow[1] and hideChartBubbles, "New Low", Alert.BAR, Sound.RING);
# use this to scan for new intraday highs
plot scan = DailyHigh > DailyHigh[1] and hideChartBubbles;
# use this to scan for new intraday lows
#plot scan = DailyLow < DailyLow[1] and hideChartBubbles;
 
Thanks, post. How might I apply this to a lower study to flag when the indicator makes a new high and the price does not?
 
@malone1020 I'm sorry, not a coder, I use it for scanning. HWCC and SCYX are two that came on daily scan, it's very obvious they are highs. By the way this scan works for price making high not an indicator!
 
yeah I'm still looking for the code logic to flag a lower study making a new high where price does not. If anyone can help here, would be greatly appreciated!
 
yeah I'm still looking for the code logic to flag a lower study making a new high where price does not. If anyone can help here, would be greatly appreciated!
you stated:
" lower study making a new high where price does not. "
"newer high where price does not"

you cant have a newer high price when the price does not go high, thats not possible.
And if you mean when the candle made a new high but the price is not at the high, then that can be simplified by price is not at the high.
 
Hi there. I'm looking to get the the trading day's (08:30CT to 14:00CT) low, high and close (3 values per day) for a number of Futures contracts as well as selected stocks. Right now, i'm having to do it manually. Is there an easier way to do this on ToS? I can go to the daily chart and get the low, high and close but it appears to include the extended trading timeframe (before 08:30CT and after 14:00CT.) Grateful for your advise/knowhow on this one. Thanks!
 
you stated:
" lower study making a new high where price does not. "
"newer high where price does not"

you cant have a newer high price when the price does not go high, thats not possible.
And if you mean when the candle made a new high but the price is not at the high, then that can be simplified by price is not at the high.
Thanks for the response, XeoNoX. Unfortunately, you misread what I wrote. I was looking for logic where the lower study makes a new high and the price on the upper chart closes at a price that is NOT the high over the last 'x' bars. A kind of divergence, if you will. Looking for a lower study to potentially show a move up before the price indicates as such.
 
Thanks for the response, XeoNoX. Unfortunately, you misread what I wrote. I was looking for logic where the lower study makes a new high and the price on the upper chart closes at a price that is NOT the high over the last 'x' bars. A kind of divergence, if you will. Looking for a lower study to potentially show a move up before the price indicates as such.
since you didnt define lower study, here is the general way you would code it.

Code:
def study1 = close is less than high within 8 bars;
def study2 = lower studymakes new high;
plot scan = study1 and study2 is true;
 
Hi there. I'm looking to get the the trading day's (08:30CT to 14:00CT) low, high and close (3 values per day) for a number of Futures contracts as well as selected stocks. Right now, i'm having to do it manually. Is there an easier way to do this on ToS? I can go to the daily chart and get the low, high and close but it appears to include the extended trading timeframe (before 08:30CT and after 14:00CT.) Grateful for your advise/knowhow on this one. Thanks!
i posted a code somewhere on the forums that you can set the time and it would grab the high, low, open. It may had been labeled premarket or aftermarket high low close, but you could change the time frame.
you also didn't specify if you were trying to use a label or draw lines... it sounds like you just want a label with the current day high, current day low, and current day close ?
 
Last edited:
since you didnt define lower study, here is the general way you would code it.

Code:
def study1 = close is less than high within 8 bars;
def study2 = lower studymakes new high;
plot scan = study1 and study2 is true;
I'm looking for the standard Relative Strength line lower study to make a new high where price does not, but I want to code in an arrow to show where this occurs on the lower study. Any idea what that might look like?

Also, when trying to scan, that 2nd line says it's an invalid statement:

def study2 = RelativeStrength makes new high;

Any ideas? Thanks again, XeoNox!
 
I'm looking for the standard Relative Strength line lower study to make a new high where price does not, but I want to code in an arrow to show where this occurs on the lower study. Any idea what that might look like?

Also, when trying to scan, that 2nd line says it's an invalid statement:

def study2 = RelativeStrength makes new high;

Any ideas? Thanks again, XeoNox!

you didnt specify when relative volume makes a new high, so i assumed you meant in the same day.
the code below rarely triggers, so i left out the first study of new high but price does not. if you want to include the first study simply change
plot greenArrow = hhBar;
to
plot greenArrow = hhBar and study1;

Code:
declare lower;
input Opentime1 = 0930;
input Endtime1 = 1600;
def ActiveTime = if GetLastDay() == GetDay() and SecondsFromTime(Opentime1) >= 0 and SecondsFromTime(Endtime1) < 0 then 1 else 0;
input length = 60;
input numDev = 2.0;
input allowNegativeValues = no;
def rawRelVol = (volume - Average(volume, length)) / StDev(volume, length);
plot RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
def study1 = close is less than high within 8 bars;
plot highestrelvolofday  = highestall(if GetLastDay() == GetDay() and highestall(relvol) then (relvol) else double.nan);
def hhBar = if relvol==highestrelvolofday then BarNumber() else hhBar[1];
plot scan = hhbar;
RelVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
RelVol.SetLineWeight(3);
RelVol.DefineColor("Above", GetColor(0));
RelVol.DefineColor("Below", GetColor(2));
RelVol.AssignValueColor(if RelVol >= numDev then RelVol.Color("Above") else RelVol.Color("Below"));
plot greenArrow = hhBar;
greenArrow.SetDefaultColor(Color.GREEN);
greenArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
 
i posted a code somewhere on the forums that you can set the time and it would grab the high, low, open. It may had been labeled premarket or aftermarket high low close, but you could change the time frame.
you also didn't specify if you were trying to use a label or draw lines... it sounds like you just want a label with the current day high, current day low, and current day close ?
label or lines is fine, i can work with either. is the code you mention the one below from 10:11pm?
 
you didnt specify when relative volume makes a new high, so i assumed you meant in the same day.
the code below rarely triggers, so i left out the first study of new high but price does not. if you want to include the first study simply change
plot greenArrow = hhBar;
to
plot greenArrow = hhBar and study1;

Code:
declare lower;
input Opentime1 = 0930;
input Endtime1 = 1600;
def ActiveTime = if GetLastDay() == GetDay() and SecondsFromTime(Opentime1) >= 0 and SecondsFromTime(Endtime1) < 0 then 1 else 0;
input length = 60;
input numDev = 2.0;
input allowNegativeValues = no;
def rawRelVol = (volume - Average(volume, length)) / StDev(volume, length);
plot RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
def study1 = close is less than high within 8 bars;
plot highestrelvolofday  = highestall(if GetLastDay() == GetDay() and highestall(relvol) then (relvol) else double.nan);
def hhBar = if relvol==highestrelvolofday then BarNumber() else hhBar[1];
plot scan = hhbar;
RelVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
RelVol.SetLineWeight(3);
RelVol.DefineColor("Above", GetColor(0));
RelVol.DefineColor("Below", GetColor(2));
RelVol.AssignValueColor(if RelVol >= numDev then RelVol.Color("Above") else RelVol.Color("Below"));
plot greenArrow = hhBar;
greenArrow.SetDefaultColor(Color.GREEN);
greenArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
Ha, appreciate the response, but you read Relative Volume where I wrote Relative Strength. Any chance you would be able to take a shot at this? As always, very much appreciated.
 
"Relative Strength line lower study to make a new high where price does not,"
new high as defined would mean the Relative strength would never go down and would only record higher numbers (new highs) meaning it would only go up to infinite, therefore your scan theory although possible would never trigger unless it a newly listed asset.
 
"Relative Strength line lower study to make a new high where price does not,"
new high as defined would mean the Relative strength would never go down and would only record higher numbers (new highs) meaning it would only go up to infinite, therefore your scan theory although possible would never trigger unless it a newly listed asset.
There are many stocks that exhibit new RS line highs where price is consolidating (i.e., "not making a new high"), and some do multiple times a year. It's a leading indicator for a stock to make a move up in the near-term. Anyway, I hope you grasp that and don't mind providing the code logic for it! Your willingness to help UTS members ver and over is incredibly admirable...thank you.
 
I'm looking for the standard Relative Strength line lower study to make a new high where price does not, but I want to code in an arrow to show where this occurs on the lower study. Any idea what that might look like?

Also, when trying to scan, that 2nd line says it's an invalid statement:

def study2 = RelativeStrength makes new high;

Any ideas? Thanks again, XeoNox!

here is what you wanted.

Relative Strength makes a new high and price less than the high

Code:
close is less than high within 8 bars and RelativeStrength()."RS" is greater than RelativeStrength()."RS" from 1 bars ago
 
I would like to plot retail hours high/low horizontal lines on the 1H chart. Here is what I have but doesn't seem to work properly. Please help! Thank you in advance!

Code:
def RH = SecondsFromTime(0900) >= 0 && SecondsTillTime(1600) > 0;
def h = if RH then highest(high) else h[1];
def l = if RH then lowest(low) else l[1];

plot hi = h;
hi.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot lo = l;
lo.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

Another code

Code:
def RH = SecondsFromTime(0900) >= 0 && SecondsTillTime(1600) > 0;
def h = if RH then high(period = "Day") else double.nan;
def l = if RH then low(period = "Day") else double.nan;

plot hi = h;
hi.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);

plot lo = l;
lo.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);


Edit: Thanks for moving my question here. The response from inthefutures plots the high/low of the whole day, not during retail hours.
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
305 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