# PreMarket Volume, High, Low Label
# TOS
# Mobius
input beginLabel = 0600;
input endLabel = 1030;
def LabelTime = if SecondsFromTime(beginLabel) > 0 and
SecondsTillTime(endLabel) >= 0
then 1
else 0;
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if isRollover and beforeStart
then volume
else if beforeStart
then vol[1] + volume
else Double.NaN;
def PreMarketVol = if IsNaN(vol)
then PreMarketVol[1]
else vol;
def PreMarketHigh = if isRollover and beforeStart
then High
else if beforeStart and high > PreMarketHigh[1]
then high
else PreMarketHigh[1];
def PreMarketLow = if isRollover and beforeStart
then Low
else if beforeStart and low < PreMarketLow[1]
then low
else PreMarketLow[1];
def r = PreMarketHigh - PreMarketLow;
def v = if secondsTillTime(0930) == 0 and
secondsFromTime(0930) == 0
then v[1] + preMarketVol
else v[1];
def t = if secondsTillTime(0000) == 0
then t[1] + 1
else t[1];
def AvgV = v / t;
AddLabel(LabelTime, "PreMarket Volume = " + PreMarketVol +
" Avg PreMarket over " + t + " days = " + Round(AvgV, 0) +
" PreMarket High = " + AsDollars(PreMarketHigh) +
" PreMarket Low = " + AsDollars(PreMarketLow) +
" Range = " + AsDollars(r), Color.WHITE);
# End Label PreMarket Volume, High, Low
# Premarket Scan
# Mobius
# Scan looks for premarket price to be above previous day close and premarket volume to be above 1000
def ExtHrs = getTime() >= RegularTradingEnd(getYYYYMMDD());
def c = if ExtHrs and !ExtHrs[1]
then close[1]
else c[1];
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if isRollover and beforeStart
then volume
else if beforeStart
then vol[1] + volume
else vol[1];
def PreMarketVol = if IsNaN(vol)
then PreMarketVol[1]
else vol;
plot scan = if between(c, 1, 100) and PreMarketVol > 1000 and close > c then 1 else 0;
# A version of the Squeeze Pro
declare lower;
input length = 20;
#Keltner Channels
def hb = 1.0;
def mb = 1.5;
def lb = 2.0;
def avg = Average(close, length);
def k1 = avg + (hb * Average(TrueRange(high, close, low), length));
def k2 = avg + (mb * Average(TrueRange(high, close, low), length));
def k3 = avg + (lb * Average(TrueRange(high, close, low), length));
#Bollinger Bands
def BB_offset = 2.0;
def sDev = stdev(close, length);
def mid = Average(close, length);
def bb = mid + BB_offset * sDev;
#Squeeze
def s0 = bb > k3;
def s1 = bb < k1;
def s2 = bb < k2;
def s3 = bb < k3;
plot squeeze = if s0 or s1 or s2 or s3 then 0 else double.nan;
squeeze.SetLineWeight(3);
squeeze.SetStyle(curve.POINTS);
squeeze.AssignValueColor(if s1 then color.orange
else if s2 then color.red
else if s3 then color.black
else color.green);
# Code taken from Momentum Squeeze by Mobius
# code is slightly modified to remove the squeeze portion
def c = close;
def h = high;
def l = low;
def K = (Highest(h, length) + Lowest(l, length)) /
2 + ExpAverage(c, length);
plot Momo = if isNaN(close)
then double.nan
else Inertia(c - K / 2, length);
Momo.setPaintingStrategy(PaintingStrategy.HISTOGRAM);
Momo.setLineWeight(5);
Momo.assignValueColor(if Momo > Momo[1] and Momo > 0
then Color.Cyan
else if Momo > 0 and Momo < Momo[1]
then Color.Blue
else if Momo < 0 and Momo < Momo[1]
then Color.Red
else Color.Yellow);
# End Code - Mobius' Momentum Squeeze
# end code
# Moving Averages with Cloud
input avg_1 = 5;
input avg_2 = 13;
input avg_type = AverageType.SIMPLE;
plot ma1 = MovingAverage(avg_type,close,avg_1);
ma1.SetDefaultColor(Color.cyan);
plot ma2 = MovingAverage(avg_type,close,avg_2);
ma2.SetDefaultColor(Color.magenta);
AddCloud(ma1,ma2,color.green,color.red);
# TheoTrade_Comparative_QuanTicks
# Mobius Dev
# Copyright TheoTrade LLC
# V03.25.2017
declare lower;
input closeTime = 1555;
input labelOffset = 5;
input showFloatingLabels = yes;
def openTime = 0930;
def rawTickData1 = hlc3("$TICK");
def rawTickData2 = hlc3("$TIKRL");
def rawTickData3 = hlc3("$TIKSP");
def rawTickData4 = hlc3("$TICK/Q");
def maxTick1 = close("$ADVN") + close("$DECN") + close("$UNCN");
def maxTick2 = close("$ADVRL") + close("$DECLRL") + close("$UNCHRL");
def maxTick3 = close("$ADVSP") + close("$DECLSP") + close("$UNCHSP");
def maxTick4 = close("$ADVN/Q") + close("$DECN/Q") + close("$UNCN/Q");
def TickData1 = rawTickData1 / maxTick1;
def TickData2 = rawTickData2 / maxTick2;
def TickData3 = rawTickData3 / maxTick3;
def TickData4 = rawTickData4 / maxTick4;
def CT1 = if GetDay() != GetDay()[1]
then 0
else if SecondsTillTime(openTime) <= 0 and
SecondsTillTime(closeTime) >= 0
then CT1[1] + TickData1
else 0;
plot cumulativeTick1 = if !IsNaN(TickData1) and
CT1 <> 0
then CT1
else Double.NaN;
def CT2 = if GetDay() != GetDay()[1]
then 0
else if SecondsTillTime(openTime) <= 0 and
SecondsTillTime(closeTime) >= 0
then CT2[1] + TickData2
else 0;
plot cumulativeTick2 = if !IsNaN(TickData2) and
CT2 <> 0
then CT2
else Double.NaN;
def CT3 = if GetDay() != GetDay()[1]
then 0
else if SecondsTillTime(openTime) <= 0 and
SecondsTillTime(closeTime) >= 0
then CT3[1] + TickData3
else 0;
plot cumulativeTick3 = if !IsNaN(TickData3) and
CT3 <> 0
then CT3
else Double.NaN;
def CT4 = if GetDay() != GetDay()[1]
then 0
else if SecondsTillTime(openTime) <= 0 and
SecondsTillTime(closeTime) >= 0
then CT4[1] + TickData4
else 0;
plot cumulativeTick4 = if !IsNaN(TickData4) and
CT4 <> 0
then CT4
else Double.NaN;
plot CT1DownTick = if cumulativeTick1 < cumulativeTick1[1]
then cumulativeTick1
else Double.NaN;
CT1DownTick.SetPaintingStrategy(PaintingStrategy.Points);
CT1DownTick.SetDefaultColor( color.white);
CT1DownTick.SetLineWeight(1);
CT1DownTick.HideBubble();
plot CT2DownTick = if cumulativeTick2 < cumulativeTick2[1]
then cumulativeTick2
else Double.NaN;
CT2DownTick.SetPaintingStrategy(PaintingStrategy.Points);
CT2DownTick.SetDefaultColor( color.white);
CT2DownTick.SetLineWeight(1);
CT2DownTick.HideBubble();
plot CT3DownTick = if cumulativeTick3 < cumulativeTick3[1]
then cumulativeTick3
else Double.NaN;
CT3DownTick.SetPaintingStrategy(PaintingStrategy.Points);
CT3DownTick.SetDefaultColor( color.white);
CT3DownTick.SetLineWeight(1);
CT3DownTick.HideBubble();
plot CT4DownTick = if cumulativeTick4 < cumulativeTick4[1]
then cumulativeTick4
else Double.NaN;
CT4DownTick.SetPaintingStrategy(PaintingStrategy.Points);
CT4DownTick.SetDefaultColor( color.white);
CT4DownTick.SetLineWeight(1);
CT4DownTick.HideBubble();
cumulativeTick1.SetDefaultColor(Color.MAGENTA);
cumulativeTick1.SetLineWeight(5);
cumulativeTick2.SetDefaultColor(Color.Dark_green);
cumulativeTick2.SetLineWeight(5);
cumulativeTick3.SetDefaultColor(Color.DARK_RED);
cumulativeTick3.SetLineWeight(5);
cumulativeTick4.SetDefaultColor(Color.BLUE);
cumulativeTick4.SetLineWeight(5);
cumulativeTick1.HideBubble();
cumulativeTick2.HideBubble();
cumulativeTick3.HideBubble();
cumulativeTick4.HideBubble();
plot allUp = if cumulativeTick1 > cumulativeTick1[1] and
cumulativeTick2 > cumulativeTick2[1] and
cumulativeTick3 > cumulativeTick3[1] and
cumulativeTick4 > cumulativeTick4[1]
then 0
else Double.NaN;
allUp.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES);
allUp.SetDefaultColor(Color.green);
allUp.setLineWeight(5);
allup.HideBubble();
plot allDown = if cumulativeTick1 < cumulativeTick1[1] and
cumulativeTick2 < cumulativeTick2[1] and
cumulativeTick3 < cumulativeTick3[1] and
cumulativeTick4 < cumulativeTick4[1]
then 0
else Double.NaN;
allDown.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
allDown.SetDefaultColor(Color.red);
allDown.SetLineWeight(5);
allDown.HideBubble();
plot zero = if isNaN(close) then double.nan else 0;
zero.SetDefaultColor(Color.WHITE);
zero.HideBubble();
zero.HideTitle();
AddVerticalLine(SecondsTillTime(openTime) == 0 or (GetDay() != GetDay()[1] and (SecondsTillTime(0000) > 0)), "", Color.GRAY, 1);
AddLabel(!showFloatingLabels, "NYSE", Color.MAGENTA);
AddLabel(!showFloatingLabels, "NASDAQ", Color.BLUE);
AddLabel(!showFloatingLabels, "SP500", Color.DARK_RED);
AddLabel(!showFloatingLabels, "R2000", Color.Dark_green);
AddChartBubble(IsNaN(close[labelOffset - 1]) and !IsNaN(close[labelOffset]) and showFloatingLabels, cumulativeTick1[labelOffset], "NYSE", Color.MAGENTA, yes);
AddChartBubble(IsNaN(close[labelOffset - 1]) and !IsNaN(close[labelOffset]) and showFloatingLabels, cumulativeTick4[labelOffset], "NASDAQ", Color.BLUE, yes);
AddChartBubble(IsNaN(close[labelOffset - 1]) and !IsNaN(close[labelOffset]) and showFloatingLabels, cumulativeTick3[labelOffset], "SP500", Color.DARK_RED, yes);
AddChartBubble(IsNaN(close[labelOffset - 1]) and !IsNaN(close[labelOffset]) and showFloatingLabels, cumulativeTick2[labelOffset], "R2000", Color.DARK_GREEN, yes);
# End Code TheoTrade QuanTicks
Tracks the price difference from afterhours volume relative to yesterday's close. This was created to visually confirm if certain stock prices were primarily driven from afterhours movements over longer periods of time.
# AfterHoursRelativePriceMovement tracks the price difference from afterhour volume relative to yesterday's close
# This was created so I could eyeball if certain stock prices were primarily driven from afterhour movements over longer periods of time
# Can be overlaid with AddMarketHoursUTC to visually see correlation from international market open/closes
# Inputting Market Hours is required due to thinkscript's date function limitations
input marketOpen = 0930;
input marketClose = 1600;
# AFAIK there is no better way to do this due to SecondsTillTime rolling over after midnight, lack of real date math, and the mish-mash of UTC/EST time handling from thinkscript
def isClosedMorning = if SecondsTillTime(marketOpen) > 0 then yes else no;
def isClosedNight = if SecondsTillTime(marketClose) < 0 then yes else no;
def change = if !isClosedMorning AND !isClosedNight then 0 else change[1] + (hl2 - hl2[1]);
plot yesterdayPrice = 0;
plot priceDifference = if change != 0 then change else Double.NaN;
priceDifference.AssignValueColor(if priceDifference > 0 then Color.UPTICK else if priceDifference < 0 then Color.DOWNTICK else Color.GRAY);
# This is to visually encapsulate a week because weekend price movements can be funky
def isStartOfWeek = if GetDayOfWeek(GetYYYYMMDD()) == 1 then yes else no;
def isEndOfWeek = if GetDayOfWeek(GetYYYYMMDD()) == 5 then yes else no;
AddVerticalLine(isStartOfWeek AND SecondsTillTime(marketOpen) == 0, "Monday Open", Color.GREEN);
AddVerticalLine(isEndOfWeek AND SecondsTillTime(marketClose) == 0, "Friday Close", Color.RED);
Here you goHi
Many discussions on Volume.
I have a specific labels I would like to have in my volume sub chart.
Has anyone ever seen a volume label that just adds up all the premarket volumes
1. label for the post market of the prior day
2. label for the premarket of that day only
3. Total of post and pre market volume also
If I go back to prior charts in the weeks then the calculation is only based on that days transactions.
Has anyone looked at this?
Thank you in advance.
Cheers
# Box Volume Stats
# Version 1.2
# Created by: Enigma
# Created: 05/18/17
# Modified by: Surya Kiran C ## Included rVolume label and Changed length as input. ## Additionally Pre-Market, 1Hr Volume, AfterHour Volume labels are added.
declare on_volume;
input length = 30;
input ShowDayAvg = yes;
input ShowTodayVolume = yes;
input ShowPercentOfDayAvg = yes;
input UnusualVolumePercent = 200;
input ShowBarAvg = yes;
input ShowCurrentBar = yes;
input PreMktVol = yes;
input RTH1HrVol = yes;
input PostMktVol = yes;
def VolDayAvg = (fold index = 1 to length + 1 with Avg = 0 do (Avg + volume(period = "DAY")[index])) / length;
def AvgBars = (fold index2 = 1 to length + 1 with Bar = 0 do (Bar + volume[index2])) / length;
def Today = volume(period = "DAY");
def PercentOfDayAvg = Round((Today / VolDayAvg) * 100, 0);
def CurVol = volume;
def offset = 1;
def ADV = Average(volume, length)[offset];
def rVol = volume / ADV;
# Labels
#if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if 1HrRTHVol then 1 else 0,
AddLabel(ShowDayAvg, length + "Day Avg: " + Round(VolDayAvg, 0) + " ", Color.LIGHT_GRAY);
AddLabel(ShowTodayVolume, "Today: " + Today + " ", (if PercentOfDayAvg >= UnusualVolumePercent then Color.GREEN else if PercentOfDayAvg >= 100 then Color.ORANGE else Color.LIGHT_GRAY));
AddLabel(ShowPercentOfDayAvg, PercentOfDayAvg + "%", (if PercentOfDayAvg >= UnusualVolumePercent then Color.GREEN else if PercentOfDayAvg >= 100 then Color.ORANGE else Color.WHITE) );
AddLabel(ShowBarAvg, "Avg" + length + "Bars: " + Round(AvgBars, 0) + " ", Color.LIGHT_GRAY);
AddLabel(ShowCurrentBar, "Cur Bar: " + CurVol + " ", (if CurVol >= AvgBars then Color.GREEN else Color.ORANGE));
AddLabel(yes, "rVol :" + Round(rVol, 2));
#AddLabel(yes, "ADV :" + ADV);
#AddLabel(yes, asPercent(rVol)); # remove "#" infront of Addlabels to select prefer choice
#AssignPriceColor(if rVol >= 1 then color.dark_red else if rVol <=.5 then Color.black else color.Gray);
#Pre, 1Hr RTH, AfterHours Volumes.
##if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if PreMktVol then 1 else 0
input PrestartTime = 0400;
input PreendTime = 0929;
def PreMkt = SecondsFromTime(PrestartTime) >= 0 and SecondsTillTime(PreendTime) >= 0;
def PreVolMins = if PreMkt and !PreMkt[1] then volume
else if PreMkt then PreVolMins[1] + volume
else PreVolMins[1];
AddLabel(if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if PreMktVol then 1 else 0, "PreMktVol = " + PreVolMins + " ", Color.Gray);
# End Volume PreMarket
input RTH1HrstartTime = 0930;
input RTH1HrendTime = 1029;
def RTH1Hr = SecondsFromTime(RTH1HrstartTime) >= 0 and SecondsTillTime(RTH1HrendTime) >= 0;
def RTH1HrMins = if RTH1Hr and !RTH1Hr[1] then volume
else if RTH1Hr then RTH1HrMins[1] + volume
else RTH1HrMins[1];
AddLabel(if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if RTH1HrVol then 1 else 0, "RTH1HrVol = " + RTH1HrMins + " ", Color.Gray);
#End Volume RTH First 60 Mins
input PoststartTime = 1600;
input PostendTime = 1959;
def PostMkt = SecondsFromTime(PoststartTime) >= 0 and SecondsTillTime(PostendTime) >= 0;
def PostVolMins = if PostMkt and !PostMkt[1] then volume
else if PostMkt then PostVolMins[1] + volume
else PostVolMins[1];
AddLabel(if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if PostMktVol then 1 else 0, "PostMktVol = " + PostVolMins + " ", Color.Gray);
# End Volume PostMarket
Hi
Thank you.
I have this working in TOS.
Just need clarification.
What does RTH1Hr stand for?
What settings would you use for
1. Pre start time - 400 - what does this do?
2. Pre end Time - 929 - what does this do?
3. rt h1 hrstart time - 930 - what does this do?
Checked AMC ( 5628566 Nasdaq site vs 4348959 ) and Tap (1067573 vs 855918 )Fridays PM volume and have differences with what NASDAQ reports on there site - do I need to change the settings ?
Cheers
I haven't found a 30 days of premarket volume study on this forumI am trying to get a "label" not a bubble I do not fully understand all of the terms yet. The most similar I have found on Thinkscript is from user name "Astroboy". The question was "% change in premarket volume from previous day". I have the code for premarket volume for the current day as posted above previously. The code was built upon in the "Astroboy" post to include the previous days premarket volume in a label next to the current days premarket volume label. My question is there any way to create 30 days of premarket average volume and put that in label form to include with the other labels on the chart. Think or swim has built in a 30 day average volume indicator but it is only for daily traded volume. It would be great to compare todays premarket volume with yesterdays premarket volume and a longer term 30 day average premarket volume along with them in label form. If any one has any ideas they are greatly appreciated thank you.
Your label image is very very small and impossible to read. Did you post your image following these directions? https://usethinkscript.com/threads/how-to-insert-image-in-a-post-thread.277/Does anyone have a script for this, and if possible, with the avg pre-market volume included?
I am collecting historical premarket volume data. is there a way to get this in label for YESTERDAY`S PREMARKET VOLUME LABLE?
I have premarket volume label as below but couldn`t figure out how to change it for YESTERDAY`S PREMARKET VOLUME...
input startTime = 400;
input endTime = 929;
def startCounter = SecondsFromTime(startTime);
def endCounter = SecondsTillTime(endTime);
def targetPeriod = if startCounter >= 0 and endCounter >= 0 then 1 else 0;
rec volumeTotal = if targetPeriod and !targetPeriod[1] then volume else if targetPeriod then volumeTotal[1] + volume else volumeTotal[1];
AddLabel(yes, Concat("Premarket: ", volumeTotal), Color.GRAY);
Please help
Ruby:input startTime = 400; input endTime = 929; def startCounter = SecondsFromTime(startTime); def endCounter = SecondsTillTime(endTime); def targetPeriod = if startCounter >= 0 and endCounter >= 0 then 1 else 0; rec volumeTotal = if targetPeriod and !targetPeriod[1] then volume else if targetPeriod then volumeTotal[1] + volume else volumeTotal[1]; AddLabel(yes, "Today's Premarket: " + volumeTotal, Color.GRAY); def Save = if targetPeriod == 1 and targetPeriod[-1] == 0 then volumeTotal else GetValue(Save, 1); def Save1 = if Save != Save[1] then Save[1] else GetValue(Save1, 1); AddLabel(1, "Yesterday's Premarket: " + Save1[1], Color.GRAY);
Please do post this. It would be helpful to know the average (30) of premarket volume on a TOS label.I have not either thank you for looking. I will keep at it online if I find anything I will post it