Well, I had some time this morning and came up with this affront to sensibility:
Code:
# FT Percent of Day Volume by Time
# As adapted by Mashume
# for the Use ThinkScript Community
# 2022-07-13
declare lower;
def minutes = if secondsFromTime(0930) >= 0 AND SecondsTillTime(1600) >= 0 then (secondsFromTime(0930) / (60)) else double.nan;
def hours = minutes / 60;
def y =
(-0.77245125* Power(hours, 6))
+ (13.13890801* (Power(hours, 5)))
+ (-76.64813184* (Power(hours, 4)))
+ (166.14466219* (Power(hours, 3)))
+ (-16.25423826* (Power(hours, 2)))
+ (-348.62204262* hours)
+ (465.46746546)
;
def v = volume;
def sum_v = if secondsFromTime(0930) >= 0 AND SecondsTillTime(1600) >= 0 then sum_v[1] + v else 0;
def sum_y = if secondsFromTime(0930) >= 0 AND SecondsTillTime(1600) >= 0 then sum_y[1] + (y / 10000) else 0;
plot indicator = if sum_y != 0 then sum_v / sum_y[-1] else double.nan;
input lock_time = 30;
def lock = if minutes[1] < lock_time and minutes >= lock_time then 1 else 0;
addVerticalLine(lock, color = Color.gray);
def prediction = if minutes < lock_time then double.nan else if minutes[1] < lock_time and minutes >= lock_time then indicator else prediction[1];
plot volume_prediction = prediction;
volume_prediction.SetDefaultColor(color.gray);
AddLabel(yes, "Prediction at t: " + lock_time + " : " + volume_prediction, color = Color.gray);
AddLabel(yes, "Current Pace: " + asPercent(indicator / volume_prediction), color = Color.gray);
You can set the time you wish to 'lock in' the volume prediction for the day. That's the only adjustable parameter. I think it's pretty cool, though it doesn't seem to track properly for all of the instruments I looked at. It's a bit jumpy at the start of the day, as is to be expected, but it seems to be pretty close at predicting the total volume for the day. YMMV, of course.
interesting idea, math, and a fun coding challenge whether you find use in it or not.
Happy Trading,
-mashume
For those wondering why the value for y is 10000 times what it should be, it's because I had to get coefficients for the function that were in reasonable ranges for ToS to be able to calculate nicely. It was easier to do it this way.