tradeking313
Member
Hello. I was wondering if there was a way we can have a MACD watchlist column when the value is greater than the average it turn green and vice versa red...thanks!!!
Hoe do you adjust the time for 2mint chart?.@Bill1000 You need to adjust the watchlist to the timeframe you want. By default, it is set to Daily (D).
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input showBreakoutSignals = yes;
input ma_length = 21; #Length(180-200 for floating S/R , 55 for swing entry)
# Four Pole Filter
script g {
input length = 4;
input betaDev = 2;
input price = OHLC4;
def c;
def w;
def beta;
def alpha;
def G;
c = price;
w = (2 * Double.Pi / length);
beta = (1 - Cos(w)) / (Power(1.414, 2.0 / betaDev) - 1 );
alpha = (-beta + Sqrt(beta * beta + 2 * beta));
G = Power(alpha, 4) * c +
4 * (1 – alpha) * G[1] – 6 * Power( 1 - alpha, 2 ) * G[2] +
4 * Power( 1 - alpha, 3 ) * G[3] - Power( 1 - alpha, 4 ) * G[4];
plot Line = G;
}
# Modified MACD
plot MACD_Value = g(length = fastLength) - g(length = slowLength);
MACD_Value.Hide();
plot MACD_Avg = g(price = MACD_Value, length = MACDLength);
MACD_Avg.Hide();
addCloud(MACD_Value, MACD_Avg, Color.GREEN, Color.RED);
plot Diff = MACD_Value - MACD_Avg;
plot ZeroLine = 0;
MACD_Value.SetDefaultColor(GetColor(1));
MACD_Avg.SetDefaultColor(GetColor(8));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.Color("Positive and Up") else Diff.Color("Positive and Down") else if Diff < Diff[1] then Diff.Color("Negative and Down") else Diff.Color("Negative and Up"));
ZeroLine.SetDefaultColor(GetColor(4));
ZeroLine.HideTitle();
plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;
UpSignal.SetHiding(!showBreakoutSignals);
Upsignal.SetLineWeight(3);
DownSignal.SetHiding(!showBreakoutSignals);
Downsignal.SetLineWeight(3);
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSignal.HideTitle();
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownSignal.HideTitle();
# Forward / Reverse EMA
# (c) 2017 John F. Ehlers
# Ported to TOS 07.16.2017
# Mobius
# Inputs:
input AA = .1;
# Vars:
def CC;
def RE1;
def RE2;
def RE3;
def RE4;
def RE5;
def RE6;
def RE7;
def RE8;
def EMA;
plot EMA_Signal;
plot plot0;
CC = if CC[1] == 0 then .9 else 1 – AA;
EMA = AA * close + CC * EMA[1];
RE1 = CC * EMA + EMA[1];
RE2 = Power(CC, 2) * RE1 + RE1[1];
RE3 = Power(CC, 4) * RE2 + RE2[1];
RE4 = Power(CC, 8) * RE3 + RE3[1];
RE5 = Power(CC, 16) * RE4 + RE4[1];
RE6 = Power(CC, 32) * RE5 + RE5[1];
RE7 = Power(CC, 64) * RE6 + RE6[1];
RE8 = Power(CC, 128) * RE7 + RE7[1];
EMA_Signal = EMA – AA * RE8;
EMA_Signal.AssignValueColor(if EMA_Signal > EMA_Signal[1]
then Color.GREEN
else Color.RED);
EMA_Signal.SetLineWeight(3);
plot0 = if IsNaN(close) then Double.NaN else 0;
plot0.SetDefaultColor(Color.GRAY);
plot0.HideTitle();
# Multi-moving average Component
#input length = 14; #hint Length: Number of periods to average the data.
input movingAverageType = {default "Simple MA", "Exponential MA", "Wilders Smoothing", "Weighted MA", "Hull MA", "Adaptive MA", "Triangular MA", "Variable MA", "Dema MA", "Tema MA", "EHMA", "THMA"};
input displace = 0;
def avg_MACD_Value = ExpAverage(2 * ExpAverage(MACD_Value, ma_length / 2) - ExpAverage(MACD_Value, ma_length), Round(Sqrt(ma_length)));
def avg_MACD_Avg = ExpAverage(2 * ExpAverage(MACD_Avg, ma_length / 2) - ExpAverage(MACD_Avg, ma_length), Round(Sqrt(ma_length)));
plot X;
X.SetDefaultColor(CreateColor(0, 102, 204));
X.SetLineWeight(3);
plot Y;
Y.SetDefaultColor(Color.WHITE);
Y.SetLineWeight(3);
switch (movingAverageType) {
case "Simple MA":
X = Average(MACD_Value, ma_length);
Y = Average(MACD_Avg, ma_length);
case "Exponential MA":
X = ExpAverage(MACD_Value, ma_length);
Y = ExpAverage(MACD_Avg, ma_length);
case "Wilders Smoothing":
X = WildersAverage(MACD_Value, ma_length);
Y = WildersAverage(MACD_Avg, ma_length);
case "Weighted MA":
X = wma(MACD_Value, ma_length);
Y = wma(MACD_Avg, ma_length);
case "Hull MA":
X = HullMovingAvg(MACD_Value, ma_length);
Y = HullMovingAvg(MACD_Avg, ma_length);
case "Adaptive MA":
X = MovAvgAdaptive(MACD_Value, ma_length);
Y = MovAvgAdaptive(MACD_Avg, ma_length);
case "Triangular MA":
X = MovAvgTriangular(MACD_Value, ma_length);
Y = MovAvgTriangular(MACD_Avg, ma_length);
case "Variable MA":
X = VariableMA(MACD_Value, ma_length);
Y = VariableMA(MACD_Avg, ma_length);
case "Dema MA":
X = DEMA(MACD_Value, ma_length);
Y = DEMA(MACD_Avg, ma_length);
case "Tema MA":
X = TEMA(MACD_Value, ma_length);
Y = TEMA(MACD_Avg, ma_length);
case EHMA:
X = ExpAverage(2 * ExpAverage(MACD_Value, ma_length / 2) - ExpAverage(MACD_Value, ma_length), Round(Sqrt(ma_length)));
Y = ExpAverage(2 * ExpAverage(MACD_Avg, ma_length / 2) - ExpAverage(MACD_Avg, ma_length), Round(Sqrt(ma_length)));
case THMA:
X = WMA(WMA(MACD_Value, (ma_length / 2) / 3) * 3 - WMA(MACD_Value, (ma_length / 2) / 2) - WMA(MACD_Value, (ma_length / 2)), (ma_length / 2));
Y = WMA(WMA(MACD_Avg, (ma_length / 2) / 3) * 3 - WMA(MACD_Avg, (ma_length / 2) / 2) - WMA(MACD_Avg, (ma_length / 2)), (ma_length / 2));
}
;
# Double MACD Signals
# Assembled by BenTen at useThinkScript.com
# Based on the request of 9ramone7
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input fastLength2 = 3;
input slowLength2 = 10;
input MACDLength2 = 16;
input averageType = AverageType.EXPONENTIAL;
def Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
def Avg = MovingAverage(averageType, Value, MACDLength);
def Value2 = MovingAverage(averageType, close, fastLength2) - MovingAverage(averageType, close, slowLength2);
def Avg2 = MovingAverage(averageType, Value, MACDLength2);
def Diff = Value - Avg;
def Diff2 = Value2 - Avg2;
def ZeroLine = 0;
def UpSignal1 = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
def DownSignal1 = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;
def UpSignal2 = if Diff2 crosses above ZeroLine then ZeroLine else Double.NaN;
def DownSignal2 = if Diff2 crosses below ZeroLine then ZeroLine else Double.NaN;
plot UpSignal = UpSignal1 and UpSignal2;
plot DownSignal = DownSignal1 and DownSignal2;
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
input fastLength = 3;
input slowLength = 6;
input MACDLength = 8;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = yes;
plot Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot Avg = MovingAverage(averageType, Value, MACDLength);
plot Diff = Value - Avg;
plot ZeroLine = 0;
plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;
UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
Value.SetDefaultColor(GetColor(1));
Avg.SetDefaultColor(GetColor(8));
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
ZeroLine.SetDefaultColor(GetColor(0));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
Alert(Diff crosses above ZeroLine, "Diff Above ZeroLine", Alert.ONCE, Sound.Ding);
Alert(Diff crosses below ZeroLine, "Diff Below ZeroLine", Alert.ONCE, Sound.Ding);
You are missing the alert text... I don't think it can be omitted...here is what i got but the word alert is red
Alert (Diff > ZeroLine, Alert.BAR, Sound.RING);
Alert (Diff > ZeroLine, "Something or Anything Here, or just empty quotes", Alert.BAR, Sound.RING);
You're very welcome... Glad to help...That worked! Thanks
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
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.
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.