custom watchList

vantduong

Member
VIP
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

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);
 
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

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);


To change the timeframe in your watchlist script.
1. double-click on your script
2 then change the timeframe at the top of the script.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
190 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top