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

DoQtorNo

Member
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
 

Similar threads

Top