Label Not Displaying on Correct TimeFrame

DoQtorNo

Member
Howdy and good am,

I have a script that I would like to place the indicies labels on a chart and do the following:
a.) Display the index: DJIA: 8888.88 (- 340.00 pts %23)

I would like for the DJIA to display the running stock price throughout the day. As you can see from the code below I am attempting to use the aggregation period to show the proper timeframe. i have deleted the code that wasn't pertinent to my inquiry.

I would like for the indicies numbers to stay the same regardless of which timeframe I am looking at.

Code:
#*************************************************
# Dow Jones Aggregate Period and Last Price    *
#*************************************************
def DoWLowPeriod = low(symbol = "$DJI", period = AggregationPeriod.DAY);
def DoWHighPeriod = high(symbol = "$DJI", period = AggregationPeriod.DAY);
def DoWClosePeriod = close(symbol = "$DJI", period = AggregationPeriod.DAY);

#Dow Open Close & Last Price
def DoW_LastPrice = close(symbol = "$DJI", period = AggregationPeriod.FIVE_MIN);
def Dow_ClosePrice = close(symbol = "$DJI", period = AggregationPeriod.DAY);
def Dow_OpenPrice = open(symbol = "$DJI", period = AggregationPeriod.DAY);
def Dow_Points = Dow_OpenPrice - DoW_LastPrice;
def Dow_Percentage = (Dow_Points / Dow_OpenPrice) * 100;

def Dow_Close = close (symbol = "$DJI");

#labels
AddLabel(yes, "DJIA: " + AsText(Dow_Close)+ "  ( " + AsText(Dow_Points) + " ) ", (if DjiDMP > DjiDMM then Color.DARK_GREEN else Color.dark_RED));
 
I am attempting to place labels on my charts that give the status of indicies similar to tickers on cnbc etc. (i.e. close, points up/down, percentage). When I go through different timeframes, I would like to still see that same data and not pull the symbol timeframe based data (i.e. 1 hour, 4 hour vversus DAY); Always show the day statistics, regardless of timeframe. Does it matter if the market is open or close. Data should show correct?

Problem: When i adjust to a different timeframe, it does not show the daily stats, it currently has N/A verbiage and teh colors are changed to black background. Here is a snippet of the code I am using for teh Dow. All others are teh same just changing the symbols to protect the innocent, lol...

Code:
def Post = secondsFromTime(1600);
def Pre = secondsTillTime(930);
def Closed  = Post >=0 or Pre>=0;
def DayClose = if (Post>=0,close(period = "Day"),close(period = "Day")[1]);

#*************************************************
# Dow Jones Aggregate Period and Last Price    *
#*************************************************
def DoWLowPeriod = low(symbol = "$DJI", period = AggregationPeriod.DAY);
def DoWHighPeriod = high(symbol = "$DJI", period = AggregationPeriod.DAY);
def DoWClosePeriod = close(symbol = "$DJI", period = AggregationPeriod.DAY);

#Dow Open Close & Last Price
def DoW_LastPrice = close(symbol = "$DJI", period = AggregationPeriod.FIVE_MIN);
def Dow_ClosePrice = close(symbol = "$DJI", period = AggregationPeriod.DAY)[1];
def Dow_OpenPrice = open(symbol = "$DJI", period = AggregationPeriod.DAY);

def Dow_Close = if (Post>=0, close(symbol = "$DJI", period = AggregationPeriod.DAY),close(symbol = "$DJI", period = AggregationPeriod.DAY)[1] );
def dow_change = (dow_close / dow_closeprice - 1);
def dow_value_change = dow_close - dow_closeprice ;
def dow_percent_change = dow_change * 100 ;
## End of Dow Jones Section
 

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