Study Not Drawing On Previous Sessions

K

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:
K

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

Top