% change label, help needed

perroveloz

New member
hi, I have a label with a % cahnge on my Days grid but it only works when market is open and i need it to work in pre market to have the gap, i need help to have the close (in minutes)
this is the code that I have

input period = AggregationPeriod.DAY;

def changeC = ((close(period = period)[0]-close (period = period)[1])/close(period=period)[1])*100;

AddLabel (yes, "%Chg: " + Round(changeC, 2) + "%", COLOR.GRAY);

thanks in advance
 
hi, I have a label with a % cahnge on my Days grid but it only works when market is open and i need it to work in pre market to have the gap, i need help to have the close (in minutes)
this is the code that I have

input period = AggregationPeriod.DAY;

def changeC = ((close(period = period)[0]-close (period = period)[1])/close(period=period)[1])*100;

AddLabel (yes, "%Chg: " + Round(changeC, 2) + "%", COLOR.GRAY);

thanks in advance

by your formula, it looks like you want to compare todays close to yesterdays close.
if that is what you want, why worry about premarket?
what is 'the gap' you are looking for?

i think using aggregation of day will only read normal trading hours data, not premarket.

here is a search for several pages of studies, dealing with previous day close. maybe one of these will work?
https://usethinkscript.com/search/1115084/?q=previous+day+close&o=date

or elaborate on what you really want and maybe someone can help.
 
hi, I have a label with a % cahnge on my Days grid but it only works when market is open and i need it to work in pre market to have the gap, i need help to have the close (in minutes)
this is the code that I have

input period = AggregationPeriod.DAY;

def changeC = ((close(period = period)[0]-close (period = period)[1])/close(period=period)[1])*100;

AddLabel (yes, "%Chg: " + Round(changeC, 2) + "%", COLOR.GRAY);

thanks in advance
Code:
# Percent Change Label (from Yesterday's Close)
# tomsk
# 1.9.2020

# V1.0 - 01.08.2020 - tomsk - Initial release of Percent Change Label, to be used for daily aggregation
# V1.1 - 01.09.2020 - tomsk - Updated to work on intraday aggregation as well as daily

def PC = close(period = AggregationPeriod.DAY)[1];
def PctChange = (close - PC) / PC;
AddLabel(1, "Change = " + AsPercent(PctChange), if PctChange > 0 then Createcolor(100,200,100) else if PctChange < 0 then Color.Light_Red else Color.Gray);

# End Percent Change Label (from Yesterday's Close)
 

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
560 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