Last February, @mashume was kind enough to write a program that let me do averaging of RSI's. I was trying to use that as a template and do the same thing with MACD's. I don't code , so it's cut and paste and I have not been able to get it to work. Any help is appreciated.
Here is the original from Mashume.
Here's the code I'm having trouble with:
Here is the original from Mashume.
Code:
# AVERAGE of RSIs FOR GROUP OF STOCKS
#
# useThinkScript
# 2020-02-26
# [USER=153]@mashume[/USER]
declare lower;
input RSI_TYPE = {default WILDERS, SIMPLE, EXPONENTIAL};
input RSI_LENGTH = 14;
input OS = 40;
input OB = 60;
input ticker_1 = "SBUX";
input ticker_2 = "MSFT";
input ticker_3 = "AMZN";
input ticker_4 = "COST";
input ticker_5 = "FFIV";
input ticker_6 = "DAIO";
input ticker_7 = "MRNA";
def RSI_1 = RSI(price = close(ticker_1), "average type" = RSI_TYPE, length = RSI_LENGTH);
def RSI_2 = RSI(price = close(ticker_2), "average type" = RSI_TYPE, length = RSI_LENGTH);
def RSI_3 = RSI(price = close(ticker_3), "average type" = RSI_TYPE, length = RSI_LENGTH);
def RSI_4 = RSI(price = close(ticker_4), "average type" = RSI_TYPE, length = RSI_LENGTH);
def RSI_5 = RSI(price = close(ticker_5), "average type" = RSI_TYPE, length = RSI_LENGTH);
def RSI_6 = RSI(price = close(ticker_6), "average type" = RSI_TYPE, length = RSI_LENGTH);
def RSI_7 = RSI(price = close(ticker_7), "average type" = RSI_TYPE, length = RSI_LENGTH);
plot data = (RSI_1 + RSI_2 + RSI_3 + RSI_4 + RSI_5 + RSI_6 + RSI_7) / 7;
plot midline = 50;
midline.SetDefaultColor(Color.GRAY);
# plot rsi = rsi(price = data);
data.SetDefaultColor(Color.CYAN);
data.SetLineWeight(2);
plot oversold = OS;
oversold.SetDefaultColor(Color.RED);
plot overbought = OB;
overbought.SetDefaultColor(Color.GREEN);
Here's the code I'm having trouble with:
Code:
declare lower;
input AverageType = {default WILDERS, SIMPLE, EXPONENTIAL, WEIGHTED};
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input ticker_1 = "COMP";
input ticker_2 = "$DJI";
input ticker_3 = "AAPL";
input ticker_4 = "FB";
input ticker_5 = "MSFT";
input ticker_6 = "NVDA";
input ticker_7 = "NFLX";
input ticker_8 = "ZM";
input ticker_9 = "TSLA";
input ticker_10 = "SQ";
def MACD_1 = MACD(Value = close(ticker_1), fastLength, slowLength, MACDLength, averageType);
def MACD_2 = MACD(fastLength, slowLength, MACDLength, averageType);
def MACD_3 = MACD(fastLength, slowLength, MACDLength, averageType);
def MACD_4 = MACD(fastLength, slowLength, MACDLength, averageType);
def MACD_5 = MACD(fastLength, slowLength, MACDLength, averageType);
def MACD_6 = MACD(fastLength, slowLength, MACDLength, averageType);
def MACD_7 = MACD(fastLength, slowLength, MACDLength, averageType);
def MACD_8 = MACD(fastLength, slowLength, MACDLength, averageType);
def MACD_9 = MACD(fastLength, slowLength, MACDLength, averageType);
def MACD_10 = MACD(fastLength, slowLength, MACDLength, averageType);
plot value = (MACD_1 + MACD_2 + MACD_3 + MACD_4 + MACD_5 + MACD_6 + MACD_7 + MACD_8 + MACD_9 + MACD_10) / 10;