This is a script I created to scan for a 30-minute timeframe. However, when this script is modified to display in a watchlist, it doesn't work. The reason might be that the watchlist defaults to a 1-day timeframe. Does anyone know how to set up a shorter timeframe in a watchlist? Please advise.
In watchList i only view the Avg
def Avg = Round((todaysFirst30MVolume / AvgFirst30MVolume) * 100, 0);
by AddLabel. But it doesn't work
In watchList i only view the Avg
def Avg = Round((todaysFirst30MVolume / AvgFirst30MVolume) * 100, 0);
by AddLabel. But it doesn't work
Code:
# 5-day Average First 30-Minute Volume
declare upper;
########## Scripts
script BarsPerPeriod {
input barCount = 13; #hint barCount: the number of 30 minute candles in a full trading day
input length = 1; #hint length: the number of premarket candles to count
plot cumulativeVolume = (fold i = 0 to length with o = 0 do o + GetValue(volume, (barCount - i), 0));
}
script First30MVolume {
# code for today's first 30-minute volume
def st = 0930; # today's premarket start time
def et = 0959; # today's premarket end time
def Active = SecondsFromTime(st) >= 0 and SecondsTillTime(et) >= 0;
def tPV = if Active and !Active[1] then volume
else if Active then (tPV[1] + volume)
else tPV[1];
plot TodaysFirst30MVolume = tPV;
# code for prior days' first 30-minute volume
input barCount = 13; #hint barCount: the number of 30 minute candles in a full trading day
def pst = 0930; # prior days' premarket start time
def pet = 0959; # prior days' premarket end time
def pActive = SecondsFromTime(pst) >= 0 and SecondsTillTime(pet) >= 0;
def pPV = if pActive and !pActive[1] then BarsPerPeriod(barCount).cumulativeVolume
else if pActive Then pPV[1] + BarsPerPeriod(barCount).cumulativeVolume
else pPV[1];
plot First30MVolume = pPV;
}
########## /Scripts
input showLabels = yes;
def day1 = First30MVolume(13).First30MVolume;
def day2 = First30MVolume(26).First30MVolume;
def day3 = First30MVolume(39).First30MVolume;
def day4 = First30MVolume(52).First30MVolume;
def day5 = First30MVolume(65).First30MVolume;
def AvgFirst30MVolume = Round((day1 + day2 + day3 + day4 + day5) / 5, 0); # tried to implement as a fold function but couldn't get it to work
def todaysFirst30MVolume = First30MVolume(0).TodaysFirst30MVolume;
def Avg = Round((todaysFirst30MVolume / AvgFirst30MVolume) * 100, 0);
AddLabel(showLabels, "A30: " + AvgFirst30MVolume, if todaysFirst30MVolume <= AvgFirst30MVolume then Color.GREEN else Color.RED);
AddLabel(showLabels,day5, Color.Light_Gray);
AddLabel(showLabels,day4, Color.Light_Gray);
AddLabel(showLabels,day3, Color.Light_Gray);
AddLabel(showLabels,day2, Color.Light_Gray);
AddLabel(showLabels,day1, if todaysFirst30MVolume <= day1 then Color.GREEN else Color.RED);
AddLabel(showLabels, "T: " + todaysFirst30MVolume + " | " + AsPercent(Avg / 100), if todaysFirst30MVolume >= day1 and todaysFirst30MVolume >= AvgFirst30MVolume then Color.GREEN else if todaysFirst30MVolume >= day1 then Color.YELLOW else Color.RED);