Study Not Drawing On Previous Sessions

Kliphten

New member
Hi all,

New here to the community but really liking thinkScript and trying to get a better understanding of it. I'm currently trying to write a study that draws the high/low of the highest volume candle so as the day progresses, it updates the drawing to the latest candle with the highest volume. Issue I'm having is on a multi-session chart (5-min, 5 days), I only see the drawing on the latest session because I'm using "HighestAll" to find the bar with the highest volume. This function looks at all candles in the entire chart rather than just the candles within the session. Does anyone have any advice as to how I'd accomplish what I've described above, having the high/low on each trading session rather than just the last session?

I'm using HighestAll(), but is there something like HighestAll() that only checks the candles for the session rather than all the candles in the entire chart?

Any help would be greatly appreciated!
 
Last edited by a moderator:

Kliphten

New member
Code:
declare once_per_bar;


# ===== DEFINITIONS

def bar = barNumber();
def secondsPassed = SecondsFromTime(0930); # 0 = 9:30a, 5400 = 11a, 16200 = 2p, 23400 = 4p


# ===== FIRST 90 MINUTES OF SESSION

def highestVolume = if secondsPassed < 0 then 0 else if secondsPassed > 5340 then Double.POSITIVE_INFINITY else if volume > highestVolume[1] then volume else highestVolume[1];
def highVolBar = if volume == highestVolume then bar else Double.NaN;
def highLevel = if !IsNaN(highVolBar) then high else highLevel[1];
def lowLevel = if !IsNaN(highVolBar) then low else lowLevel[1];

plot HighLine1 = if secondsPassed >= 0 and secondsPassed <= 23340 and bar >= HighestAll(highVolBar) then highLevel else Double.NaN;
plot LowLine1 = if secondsPassed >= 0 and secondsPassed <= 23340 and bar >= HighestAll(highVolBar) then lowLevel else Double.NaN;

HighLine.SetDefaultColor(CreateColor(246, 188, 179));
HighLine.SetLineWeight(1);
LowLine.SetDefaultColor(CreateColor(246, 188, 179));
LowLine.SetLineWeight(1);

AddCloud(HighLine, LowLine, CreateColor(246, 188, 179));

Here's what I have so far. The HighestAll() call prevents this from plotting on previous sessions. But I do want the cloud to start on the highest volume candle. So if there is a high volume bar at 9:35, the cloud will draw from 9:35, but then a new high volume candle forms at 9:45, I want it to plot from 9:45 and "remove" the cloud prior to that time.
 

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