Stoynks
Member
I am trying to find the highest volume in the premarket and then plotting a horizontal line.
I change "def time = if GetLastDay() == GetDay() and SecondsFromTime(0430) >= 0 and SecondsTillTime(0929) >= 0 then 1 else 0;" that way it only reads from premarket. but one problem is, when I change "input barsago", it's a a little wonky because on some charts the horizontal line is there sometimes it isn't at 1 min aggregation period.
Then I started digging even more so instead of using "input barsago" to find the highest volume bar. I use this code.
https://usethinkscript.com/threads/volume-greater-than-prior-5-days.3569/post-33107
and then made some changes.
Good news. From trading hours, it was able to calculate the highest volume from that day using "Highestall(v), and then plotting only the highest volume. But when I change it to premarket, it disappeared. I am trying to combine the 2nd code to find the highest volume in premarket and then add in the 1st first code to plot the horizontal line.
Thank you for your talents and I hope you guys' have a wonderful weekend.
Code:
# Plots High/Low Price at Highest Volume
# tomsk
# 12.4.2019
input barsago = 4;
#
def time = if GetLastDay() == GetDay() and SecondsFromTime(0430) >= 0 and SecondsTillTime(0929) >= 0 then 1 else 0;
def bar = BarNumber();
def HighVolBar = if time and ((volume - Lowest(volume, barsago)) /
(Highest(volume, barsago) - Lowest(volume, barsago))) >= 1
then bar
else Double.NaN;
def VolHighLevel = if!IsNaN(HighVolBar) then high else VolHighLevel[1];
def VolLowLevel = if !IsNaN(HighVolBar) then low else VolLowLevel[1];
plot HighLine = if bar >= HighestAll(HighVolBar) then VolHighLevel else Double.NaN;
plot LowLine = if bar >= HighestAll(HighVolBar) then VolLowLevel else Double.NaN;
HighLine.SetDefaultColor(Color.CYAN);
HighLine.SetLineWeight(3);
LowLine.SetDefaultColor(Color.YELLOW);
LowLine.SetLineWeight(3);
# End Plots High/Low Price at Highest Volume
I change "def time = if GetLastDay() == GetDay() and SecondsFromTime(0430) >= 0 and SecondsTillTime(0929) >= 0 then 1 else 0;" that way it only reads from premarket. but one problem is, when I change "input barsago", it's a a little wonky because on some charts the horizontal line is there sometimes it isn't at 1 min aggregation period.
Then I started digging even more so instead of using "input barsago" to find the highest volume bar. I use this code.
https://usethinkscript.com/threads/volume-greater-than-prior-5-days.3569/post-33107
Code:
declare on_volume;
def NA = Double.NaN;
input length = 5;
def aggcheck = GetAggregationPeriod() == AggregationPeriod.DAY;
def v = volume;
def vt = v == Highest(v,length);
plot Vtest = if aggcheck and vt then v else NA;
vtest.SetDefaultColor(CreateColor(0,100,200));
vtest.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
and then made some changes.
Code:
declare on_volume;
def NA = Double.NaN;
def aggcheck = GetLastDay() == GetDay()and SecondsFromTime(0931) >= 0 and SecondsTillTime(1600) >= 0;
def v = volume;
def vt = v == Highestall(v);
plot Vtest = if aggcheck then vt and v else NA;
vtest.SetDefaultColor(CreateColor(0,100,200));
vtest.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
Good news. From trading hours, it was able to calculate the highest volume from that day using "Highestall(v), and then plotting only the highest volume. But when I change it to premarket, it disappeared. I am trying to combine the 2nd code to find the highest volume in premarket and then add in the 1st first code to plot the horizontal line.
Thank you for your talents and I hope you guys' have a wonderful weekend.