Hi,
I am trying to see if anyone can help me with this script. It shows 8 different stocks of your choice and if they they are up and down for the day/week. I was wondering if it would be possible to have this script convert this into 5 min, 2 min, 1 min and shows the trend based on 9, 20 and 50 EMA. I am not the owner of this script hence got it from someone.
I am trying to see if anyone can help me with this script. It shows 8 different stocks of your choice and if they they are up and down for the day/week. I was wondering if it would be possible to have this script convert this into 5 min, 2 min, 1 min and shows the trend based on 9, 20 and 50 EMA. I am not the owner of this script hence got it from someone.
Code:
declare upper;
input Stock = "AAPL";
input Stock2 = "MSFT";
input Stock3 = "AMZN";
input Stock4 = "GOOGL";
input Stock5 = "TSLA";
input Stock6 = "NVDA";
input Stock7 = "META";
input Stock8 = "USO";
input Period = {default Day, Week, Month, Quarter, Year};
def aggregations;
switch (Period) {
case Day:
aggregations = AggregationPeriod.FOUR_HOURS;
case Week:
aggregations = AggregationPeriod.WEEK;
case Month:
aggregations = AggregationPeriod.MONTH;
case Quarter:
aggregations = AggregationPeriod.QUARTER;
case Year:
aggregations = AggregationPeriod.YEAR;
}
#def aggregationPeriod = AggregationPeriod.DAY;
def aggregationPeriod = Period;
def Stockopen = open(Stock, aggregationPeriod);
def Stockclose = close(Stock);
def Stockdiff = close (Stock) - open(Stock, period = aggregationPeriod);
def Stock_d_pct = 100 * Stockdiff / Stockopen;
AddLabel(yes, Stock + " " + Stock_d_pct + "%" + " " + AsDollars(Stockclose), if Stockdiff > 0 then Color.GREEN else if Stockdiff < 0 then Color.RED else Color.GRAY);
def Stock2open = open(Stock2, aggregationPeriod);
def Stock2close = close(Stock2);
def Stock2diff = close (Stock2) - open(Stock2, period = aggregationPeriod);
def Stock2_d_pct = 100 * Stock2diff / Stock2open;
AddLabel(yes, Stock2 + " " + Stock2_d_pct + "%" + " " + AsDollars(Stock2close), if Stock2diff > 0 then Color.GREEN else if Stock2diff < 0 then Color.RED else Color.GRAY);
def Stock3open = open(Stock3, aggregationPeriod);
def Stock3close = close(Stock3);
def Stock3diff = close (Stock3) - open(Stock3, period = aggregationPeriod);
def Stock3_d_pct = 100 * Stock3diff / Stock3open;
AddLabel(yes, Stock3 + " " + Stock3_d_pct + "%" + " " + AsDollars(Stock3close), if Stock3diff > 0 then Color.GREEN else if Stock3diff < 0 then Color.RED else Color.GRAY);
def Stock4open = open(Stock4, aggregationPeriod);
def Stock4close = close(Stock4);
def Stock4diff = close (Stock4) - open(Stock4, period = aggregationPeriod);
def Stock4_d_pct = 100 * Stock4diff / Stock4open;
AddLabel(yes, Stock4 + " " + Stock4_d_pct + "%" + " " + AsDollars(Stock4close), if Stock4diff > 0 then Color.GREEN else if Stock4diff < 0 then Color.RED else Color.GRAY);
def Stock5open = open(Stock5, aggregationPeriod);
def Stock5close = close(Stock5);
def Stock5diff = close (Stock5) - open(Stock5, period = aggregationPeriod);
def Stock5_d_pct = 100 * Stock5diff / Stock5open;
AddLabel(yes, Stock5 + " " + Stock5_d_pct + "%" + " " + AsDollars(Stock5close), if Stock5diff > 0 then Color.GREEN else if Stock5diff < 0 then Color.RED else Color.GRAY);
def Stock6open = open(Stock6, aggregationPeriod);
Last edited by a moderator: