MACD Format, Triggers, Scan, Label, Watchlist For ThinkOrSwim

I've looked at many months of charts MACD crossover. In general the higher probability trade is to take the crossover heading away from the zero line. For the MACD crossover that is heading towards the zero line from afar, those are a crap shoot, sometimes they work great and sometimes they make you lose money. Are there any clues to which MACD crossover heading towards the zero line are higher probability trades?
 
@petech
5wjbEOh.png

https://www.investopedia.com/ask/an...used,help identify potential market reversals.
 
Hello,

I was wondering if there was a way to script into the code of MACD to show a crossover of the value (blue line) over the avg (yellow line) but only the blue line is a certain amount above the yellow line as to not alert for small crossovers that don't really mean anything. Those two lines do have values, I just don't know how you would tell the script to say that you want the values to be a certain distance away from each other after a crossover to alert you. any help would be appreciated!
 
Hi everyone. Been learning so much from this community and tried to take a stab at coding a tweak to MACD. I ran into a wall and was looking for some assistance. Im trying to show buy or sell vertical lines when value and signals lines cross when they are above or below the zero line only. I was able to add the vertical lines, but they show buy or sell when every time they cross. Im just looking for a buy vertical line when both value and signal are below zero line and they cross up. Sell vertical line when theyre above zero and cross down. Any assistance would be greatly appreciated. Thank you in advance.
Ruby:
declare lower;

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;

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

def BUYsignal1 = value crosses above avg;
#def BUYsignal2 = value < zeroline;
#def BUYsignal3 = Buysignal1 + Buysignal2;
def SELLsignal1 = value crosses below avg;
#def SELLsignal2 = value > zeroline;

AddVerticalLine(Buysignal1 , "Buy", Color.GREEN, Curve.FIRM);
AddVerticalLine(SELLsignal1, "Sell", Color.RED, Curve.FIRM);
 
Last edited by a moderator:
Hello all, I am looking for someone that help me with the MACD crossover. I am looking for an indicator code that will look for the fast line crossing over the slow line WITHOUT taking into consideration the zero line. In reverse, I'm looking for the fast line crossing below the slow line again without consideration of the zero line. In the end, I don't care where the cross took place in reference to the zero line, just that there was a crossover within 1 day. Can someone help? Thanks, Bob
 
@Ictheeuss Did you try this?
Ruby:
def BUYsignal1  = value < zeroline and value crosses above avg;
def SELLsignal1 = value > zeroline and value crosses below avg;
 
Hi everyone,

Can anyone can help for setting up scan for Macd Histogram with NEGATIVE AND UP signal in thinkorswim?
I have tried multiple time but did not sucessful.
Thank you guys.
 
The simplest way to do that is to use the built-in MACDHistogramCrossover study.

Click + Add Filter and select Study
Click where it says ADXCrossover and then select Crossovers -> MACDHistogramCrossover

If you want one scan that finds both crossing above zero and crossing below zero then it has a couple more steps. Don't add it as I said above and if you already did then delete it.

Click Add condition group and select Any of the following.

In the new, bottom section it created:
Click + Add Filter and select Study
Click where it says ADXCrossover and then select Crossovers -> MACDHistogramCrossover
It defaults positive to negative.

Click + Add Filter and select Study again.
Click where it says ADXCrossover and then select Crossovers -> MACDHistogramCrossover
Change this one to negative to positive.
 
Last edited:
Hey just looking for some assistance. As title states just seeing if possible for anyone to make a script with a simple indication of MACD crossover on a different timeframe. For instance, I trade the daily, and having a red down or green up arrow on the daily MACD when the weekly MACD has a bullish/bearish cross. Having the option to choose timeframes would be best (i.e. could switch to see hourly MACD cross on the daily as well.
 
Hey just looking for some assistance. As title states just seeing if possible for anyone to make a script with a simple indication of MACD crossover on a different timeframe. For instance, I trade the daily, and having a red down or green up arrow on the daily MACD when the weekly MACD has a bullish/bearish cross. Having the option to choose timeframes would be best (i.e. could switch to see hourly MACD cross on the daily as well.

Lower timeframe, no. TOS doesn't allow us to access lower timeframes.

Higher timeframe, yes. Grab the Moxie indicator upper study here:
https://usethinkscript.com/threads/moxie-indicator-for-thinkorswim.369/page-8#post-53789

It draws arrows where a higher timeframe MACD crossed above or below zero. The timeframes are all laid out in the code and can easily be changed. For instance, on the daily chart it uses the weekly MACD.
 
Awesome thank you. Won’t have access to my desktop until tomorrow to play around with it. Looking at the code and comment it marks a cross of zero line correct? Would there be a way to mark a weekly macd cross of the weekly signal on the daily MACD? Also disappointed ToS doesn’t allow access to lower frames. Could give an early indication of momo 😢
 
Looking at the code and comment it marks a cross of zero line correct?
Would there be a way to mark a weekly macd cross of the weekly signal on the daily MACD?
Yes, on the daily chart it'll mark the 5 candles of the week that crosses above/below zero.

Yes, that could be done. You should give it a try. You have the proper calculation from the higher timeframe in that Moxie study.

I'd recommend copying the default MACD study to a new study and then pasting in the code from that Moxie study. At that point it'll work but the arrows are drawn at price levels that may be far from the MACD values. You'll see why that's problematic. But, you can change that to have them plot at zero instead.

At that point, you might want to change the PaintingStrategy to use dots or squares instead of the arrows so they don't block your view of your MACD so much. Then you'd have just small green or red symbols appear on MACD's zero line where the weekly cross happened.
 
Last edited:
I’m pretty code dumb. Like extremely. Why I was asking lol But I’ll play around with editing the code see if I can figure it out
 
If your looking for the EMA12 crossing ema26 otherwise what you are asking is not MACD. MACD has a Value line and Average line, there is no fast vs slow. If you want to compute the where the MACD crosses the average MACD then
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
plot Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot Avg = MovingAverage(averageType, Value, MACDLength);
def signal1 = Value[0] crosses above Avg[0];
def exit1 = Value[0] crosses below Avg[0];
 
Hi, I am trying to get a custom label created for Thinkorswim. The MacD indicator, has a value and average, i want the difference to show in label for the charts. Also can you create a scan for this for a watchlist?

When the value is greater than the average it creates a positive momentum trend. And when the value is less than the average is creates a negative momentum trend.
 
Last edited:
MACD Label & WatchList
@Baller4lfe When the value is greater than average AND is trending up it creates a positive momentum.
Instead of just above avg and below avg... Included is:

MACD TrendingMACD Watch ItMACD FallingMACD Rising
Value > Avg
Value is trending up
Value > Avg
Value is trending down
Value < Avg
Value is trending down
Value < Avg
Value is trending up
color greencolor dark graycolor redcolor dark green
The number in the label is the difference between value and average.

Upper Study Label and Lower Study Indicator
Shared Chart Link: http://tos.mx/6v2K0kT Click here for --> Easiest way to load shared links
Screenshot (33).png

WatchList
Screenshot (30).png



Upper Chart Study
Ruby:
# ########################################################
# MACD with a more Normal Distribution by Mobius V01.09.2015
#Hint: Plots a Gaussian distribution. If Normal Distribution is met, then at minimum, 68.2% of the close values should be inside a One Standard Deviation Envelope and 95.4% of the close values should be inside a 2 Standard Deviation Envelope.

input fastLength = 8 ; # short 6, 13, 6 BB length 5
input slowLength = 17; # default 8 17 9
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;
}

#My Standard Chart Colors
# Modified MACD
def MACD_Value = g(length = fastLength) - g(length = slowLength);
def MACD_Avg = g(price = MACD_Value, length = MACDLength);
def Diff = MACD_Value - MACD_Avg;

def PositiveUp   = MACD_Value > MACD_Value[1] and MACD_Value > MACD_Avg ;
def NegativeUp   = MACD_Value < MACD_Value[1] and MACD_Value > MACD_Avg ;
def NegativeDown = MACD_Value < MACD_Value[1] and MACD_Value < MACD_Avg ;
def PostiveDown  = MACD_Value > MACD_Value[1] and MACD_Value < MACD_Avg ;

plot Buy_scan = MACD_value < 0 and MACD_value >= MACD_value[1] and MACD_Value crosses above MACD_Avg ;
plot Sell_scan =  MACD_value < MACD_avg and MACD_value < MACD_value[1] ;
Buy_scan.Hide();
Sell_scan.Hide();
plot Buy_signal = if Buy_scan and !Buy_scan[1] then MACD_value else double.NaN  ;
Buy_signal.SetPaintingStrategy(PaintingStrategy.LINE_Vs_poINTS);
Buy_signal.SetDefaultColor(color.cyan) ;
Buy_signal.SetLineWeight(5);
plot sell_signal = if sell_scan and !sell_scan[1] then MACD_value else double.NaN  ;
sell_signal.SetPaintingStrategy(PaintingStrategy.LINE_Vs_poINTS);
sell_signal.SetDefaultColor(color.magenta) ;
sell_signal.SetLineWeight(5);

# ########################################################
# Charting and Formatting
DefineGlobalColor("Pre_Cyan", CreateColor(50, 200, 255)) ;
DefineGlobalColor("LabelGreen",  CreateColor(0, 165, 0)) ;

input ShowLabels = yes ;
AddLabel(ShowLabels,
if buy_scan then "MACD Trend Begin" else
if sell_scan and !sell_scan[1] then "MACD Trend End" else
if PositiveUp then "MACD Trending " + Round(Diff, 1) else
if PostiveDown then "MACD Rising " + Round(Diff, 1) else
if NegativeUp then "MACD Watch It " + Round(Diff, 1) else
if NegativeDown then "MACD Falling " + Round(Diff, 1) else "MACD Wait ",
if buy_scan then GlobalColor("Pre_Cyan") else
if sell_scan and !sell_scan[1] then color.magenta else
if PositiveUp then GlobalColor("LabelGreen") else
if PostiveDown then color.dark_green else
if NegativeUp then Color.DARK_gray else
if NegativeDown then Color.RED else
 Color.GRAY);

Lower Study Indicator
Ruby:
declare lower;
# ########################################################
# MACD with a more Normal Distribution by Mobius V01.09.2015
#Hint: Plots a Gaussian distribution. If Normal Distribution is met, then at minimum, 68.2% of the close values should be inside a One Standard Deviation Envelope and 95.4% of the close values should be inside a 2 Standard Deviation Envelope.

input fastLength = 8 ; # short 6, 13, 6 BB length 5
input slowLength = 17; # default 8 17 9
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;
}

plot zeroline = 0 ;
zeroline.SetDefaultColor(Color.GRAY);

# Modified MACD
def MACD_Value = g(length = fastLength) - g(length = slowLength);
plot MACD_Avg = g(price = MACD_Value, length = MACDLength);
def Diff = MACD_Value - MACD_Avg;
AddCloud(MACD_Value, MACD_Avg, Color.GREEN, Color.RED);

def PositiveUp   = MACD_Value > MACD_Value[1] and MACD_Value > MACD_Avg ;
def NegativeUp   = MACD_Value < MACD_Value[1] and MACD_Value > MACD_Avg ;
def NegativeDown = MACD_Value < MACD_Value[1] and MACD_Value < MACD_Avg ;
def PostiveDown  = MACD_Value > MACD_Value[1] and MACD_Value < MACD_Avg ;
# ########################################################
# Charting and Formatting
DefineGlobalColor("Pre_Cyan", CreateColor(50, 200, 255)) ;
DefineGlobalColor("LabelGreen",  CreateColor(0, 165, 0)) ;

plot Buy_scan = MACD_value < 0 and MACD_value >= MACD_value[1] and MACD_Value crosses above MACD_Avg ;
plot Sell_scan =  MACD_value < MACD_avg and MACD_value < MACD_value[1] ;
Buy_scan.Hide();
Sell_scan.Hide();
plot Buy_signal = if Buy_scan and !Buy_scan[1] then MACD_value else double.NaN  ;
Buy_signal.SetPaintingStrategy(PaintingStrategy.LINE_Vs_poINTS);
Buy_signal.SetDefaultColor(color.cyan) ;
Buy_signal.SetLineWeight(5);
plot sell_signal = if sell_scan and !sell_scan[1] then MACD_value else double.NaN  ;
sell_signal.SetPaintingStrategy(PaintingStrategy.LINE_Vs_poINTS);
sell_signal.SetDefaultColor(color.magenta) ;
sell_signal.SetLineWeight(5);
# ########################################################
plot MACD_dots = MACD_Value ;
MACD_dots.AssignValueColor(
if buy_scan then GlobalColor("Pre_Cyan") else
if sell_scan and !sell_scan[1] then color.magenta else
if PositiveUp then GlobalColor("LabelGreen") else
if PostiveDown then color.dark_green else
if NegativeUp then Color.DARK_gray else
if NegativeDown then Color.RED else
 Color.GRAY);
MACD_dots.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
MACD_dots.SetLineWeight(1);
# ########################################################
input ShowLabels = yes ;
AddLabel(ShowLabels,
if buy_scan then "MACD Trend Begin" else
if sell_scan and !sell_scan[1] then "MACD Trend End" else
if PositiveUp then "MACD Trending " + Round(Diff, 1) else
if PostiveDown then "MACD Rising " + Round(Diff, 1) else
if NegativeUp then "MACD Watch It " + Round(Diff, 1) else
if NegativeDown then "MACD Falling " + Round(Diff, 1) else "MACD Wait ",
if buy_scan then GlobalColor("Pre_Cyan") else
if sell_scan and !sell_scan[1] then color.magenta else
if PositiveUp then GlobalColor("LabelGreen") else
if PostiveDown then color.dark_green else
if NegativeUp then Color.DARK_gray else
if NegativeDown then Color.RED else
 Color.GRAY);

WatchList
Ruby:
# ########################################################
# MACD with a more Normal Distribution by Mobius V01.09.2015
#Hint: Plots a Gaussian distribution. If Normal Distribution is met, then at minimum, 68.2% of the close values should be inside a One Standard Deviation Envelope and 95.4% of the close values should be inside a 2 Standard Deviation Envelope.

input fastLength = 8 ; # short 6, 13, 6 BB length 5
input slowLength = 17; # default 8 17 9
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;
}

#My Standard Chart Colors
# Modified MACD
def MACD_Value = g(length = fastLength) - g(length = slowLength);
def MACD_Avg = g(price = MACD_Value, length = MACDLength);
def Diff = MACD_Value - MACD_Avg;

def PositiveUp   = MACD_Value > MACD_Value[1] and MACD_Value > MACD_Avg ;
def NegativeUp   = MACD_Value < MACD_Value[1] and MACD_Value > MACD_Avg ;
def NegativeDown = MACD_Value < MACD_Value[1] and MACD_Value < MACD_Avg ;
def PostiveDown  = MACD_Value > MACD_Value[1] and MACD_Value < MACD_Avg ;

plot Buy_scan = MACD_value < 0 and MACD_value >= MACD_value[1] and MACD_Value crosses above MACD_Avg ;
plot Sell_scan =  MACD_value < MACD_avg and MACD_value < MACD_value[1] ;
Buy_scan.Hide();
Sell_scan.Hide();
plot Buy_signal = if Buy_scan and !Buy_scan[1] then MACD_value else double.NaN  ;
Buy_signal.SetPaintingStrategy(PaintingStrategy.LINE_Vs_poINTS);
Buy_signal.SetDefaultColor(color.cyan) ;
Buy_signal.SetLineWeight(5);
plot sell_signal = if sell_scan and !sell_scan[1] then MACD_value else double.NaN  ;
sell_signal.SetPaintingStrategy(PaintingStrategy.LINE_Vs_poINTS);
sell_signal.SetDefaultColor(color.magenta) ;
sell_signal.SetLineWeight(5);

# ########################################################
# Charting and Formatting
DefineGlobalColor("Pre_Cyan", CreateColor(50, 200, 255)) ;
DefineGlobalColor("LabelGreen",  CreateColor(0, 165, 0)) ;

input ShowLabels = yes ;
AddLabel(ShowLabels,
if buy_scan then "Begin" else
if sell_scan and !sell_scan[1] then "End" else
if PositiveUp then "👍 " + Round(Diff, 1) else
if PostiveDown then "👍 " + Round(Diff, 1) else
if NegativeUp then "Chg'g " + Round(Diff, 1) else
if NegativeDown then "👎 " + Round(Diff, 1) else " ");
AssignBackgroundColor(
if buy_scan then color.cyan else
if sell_scan and !sell_scan[1] then color.magenta else
if PositiveUp then CreateColor(50, 200, 255) else
if PostiveDown then CreateColor(0, 165, 0) else
if NegativeUp then Color.gray else
if NegativeDown then Color.RED else
 Color.GRAY);
 
Last edited:
MACD Label & WatchList
@Baller4lfe When the value is greater than average AND is trending up it creates a positive momentum.
Instead of just above avg and below avg... Included is:

MACD TrendingMACD Watch ItMACD FallingMACD Rising
Value > Avg
Value is trending up
Value > Avg
Value is trending down
Value < Avg
Value is trending down
Value < Avg
Value is trending up
color greencolor dark graycolor redcolor dark green
The number in the label is the difference between value and average.

Upper Study Label and Lower Study Indicator
Shared Chart Link: http://tos.mx/6v2K0kT Click here for --> Easiest way to load shared links
View attachment 854
WatchList
View attachment 859


Upper Chart Study
Ruby:
# ########################################################
# MACD with a more Normal Distribution by Mobius V01.09.2015
#Hint: Plots a Gaussian distribution. If Normal Distribution is met, then at minimum, 68.2% of the close values should be inside a One Standard Deviation Envelope and 95.4% of the close values should be inside a 2 Standard Deviation Envelope.

input fastLength = 8 ; # short 6, 13, 6 BB length 5
input slowLength = 17; # default 8 17 9
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;
}

#My Standard Chart Colors
# Modified MACD
def MACD_Value = g(length = fastLength) - g(length = slowLength);
def MACD_Avg = g(price = MACD_Value, length = MACDLength);
def Diff = MACD_Value - MACD_Avg;

def PositiveUp   = MACD_Value > MACD_Value[1] and MACD_Value > MACD_Avg ;
def NegativeUp   = MACD_Value < MACD_Value[1] and MACD_Value > MACD_Avg ;
def NegativeDown = MACD_Value < MACD_Value[1] and MACD_Value < MACD_Avg ;
def PostiveDown  = MACD_Value > MACD_Value[1] and MACD_Value < MACD_Avg ;

plot Buy_scan = MACD_value < 0 and MACD_value >= MACD_value[1] and MACD_Value crosses above MACD_Avg ;
plot Sell_scan =  MACD_value < MACD_avg and MACD_value < MACD_value[1] ;
Buy_scan.Hide();
Sell_scan.Hide();
plot Buy_signal = if Buy_scan and !Buy_scan[1] then MACD_value else double.NaN  ;
Buy_signal.SetPaintingStrategy(PaintingStrategy.LINE_Vs_poINTS);
Buy_signal.SetDefaultColor(color.cyan) ;
Buy_signal.SetLineWeight(5);
plot sell_signal = if sell_scan and !sell_scan[1] then MACD_value else double.NaN  ;
sell_signal.SetPaintingStrategy(PaintingStrategy.LINE_Vs_poINTS);
sell_signal.SetDefaultColor(color.magenta) ;
sell_signal.SetLineWeight(5);

# ########################################################
# Charting and Formatting
DefineGlobalColor("Pre_Cyan", CreateColor(50, 200, 255)) ;
DefineGlobalColor("LabelGreen",  CreateColor(0, 165, 0)) ;

input ShowLabels = yes ;
AddLabel(ShowLabels,
if buy_scan then "MACD Trend Begin" else
if sell_scan and !sell_scan[1] then "MACD Trend End" else
if PositiveUp then "MACD Trending " + Round(Diff, 1) else
if PostiveDown then "MACD Rising " + Round(Diff, 1) else
if NegativeUp then "MACD Watch It " + Round(Diff, 1) else
if NegativeDown then "MACD Falling " + Round(Diff, 1) else "MACD Wait ",
if buy_scan then GlobalColor("Pre_Cyan") else
if sell_scan and !sell_scan[1] then color.magenta else
if PositiveUp then GlobalColor("LabelGreen") else
if PostiveDown then color.dark_green else
if NegativeUp then Color.DARK_gray else
if NegativeDown then Color.RED else
 Color.GRAY);

Lower Study Indicator
Ruby:
declare lower;
# ########################################################
# MACD with a more Normal Distribution by Mobius V01.09.2015
#Hint: Plots a Gaussian distribution. If Normal Distribution is met, then at minimum, 68.2% of the close values should be inside a One Standard Deviation Envelope and 95.4% of the close values should be inside a 2 Standard Deviation Envelope.

input fastLength = 8 ; # short 6, 13, 6 BB length 5
input slowLength = 17; # default 8 17 9
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;
}

plot zeroline = 0 ;
zeroline.SetDefaultColor(Color.GRAY);

# Modified MACD
def MACD_Value = g(length = fastLength) - g(length = slowLength);
plot MACD_Avg = g(price = MACD_Value, length = MACDLength);
def Diff = MACD_Value - MACD_Avg;
AddCloud(MACD_Value, MACD_Avg, Color.GREEN, Color.RED);

def PositiveUp   = MACD_Value > MACD_Value[1] and MACD_Value > MACD_Avg ;
def NegativeUp   = MACD_Value < MACD_Value[1] and MACD_Value > MACD_Avg ;
def NegativeDown = MACD_Value < MACD_Value[1] and MACD_Value < MACD_Avg ;
def PostiveDown  = MACD_Value > MACD_Value[1] and MACD_Value < MACD_Avg ;
# ########################################################
# Charting and Formatting
DefineGlobalColor("Pre_Cyan", CreateColor(50, 200, 255)) ;
DefineGlobalColor("LabelGreen",  CreateColor(0, 165, 0)) ;

plot Buy_scan = MACD_value < 0 and MACD_value >= MACD_value[1] and MACD_Value crosses above MACD_Avg ;
plot Sell_scan =  MACD_value < MACD_avg and MACD_value < MACD_value[1] ;
Buy_scan.Hide();
Sell_scan.Hide();
plot Buy_signal = if Buy_scan and !Buy_scan[1] then MACD_value else double.NaN  ;
Buy_signal.SetPaintingStrategy(PaintingStrategy.LINE_Vs_poINTS);
Buy_signal.SetDefaultColor(color.cyan) ;
Buy_signal.SetLineWeight(5);
plot sell_signal = if sell_scan and !sell_scan[1] then MACD_value else double.NaN  ;
sell_signal.SetPaintingStrategy(PaintingStrategy.LINE_Vs_poINTS);
sell_signal.SetDefaultColor(color.magenta) ;
sell_signal.SetLineWeight(5);
# ########################################################
plot MACD_dots = MACD_Value ;
MACD_dots.AssignValueColor(
if buy_scan then GlobalColor("Pre_Cyan") else
if sell_scan and !sell_scan[1] then color.magenta else
if PositiveUp then GlobalColor("LabelGreen") else
if PostiveDown then color.dark_green else
if NegativeUp then Color.DARK_gray else
if NegativeDown then Color.RED else
 Color.GRAY);
MACD_dots.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
MACD_dots.SetLineWeight(1);
# ########################################################
input ShowLabels = yes ;
AddLabel(ShowLabels,
if buy_scan then "MACD Trend Begin" else
if sell_scan and !sell_scan[1] then "MACD Trend End" else
if PositiveUp then "MACD Trending " + Round(Diff, 1) else
if PostiveDown then "MACD Rising " + Round(Diff, 1) else
if NegativeUp then "MACD Watch It " + Round(Diff, 1) else
if NegativeDown then "MACD Falling " + Round(Diff, 1) else "MACD Wait ",
if buy_scan then GlobalColor("Pre_Cyan") else
if sell_scan and !sell_scan[1] then color.magenta else
if PositiveUp then GlobalColor("LabelGreen") else
if PostiveDown then color.dark_green else
if NegativeUp then Color.DARK_gray else
if NegativeDown then Color.RED else
 Color.GRAY);

WatchList
Ruby:
# ########################################################
# MACD with a more Normal Distribution by Mobius V01.09.2015
#Hint: Plots a Gaussian distribution. If Normal Distribution is met, then at minimum, 68.2% of the close values should be inside a One Standard Deviation Envelope and 95.4% of the close values should be inside a 2 Standard Deviation Envelope.

input fastLength = 8 ; # short 6, 13, 6 BB length 5
input slowLength = 17; # default 8 17 9
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;
}

#My Standard Chart Colors
# Modified MACD
def MACD_Value = g(length = fastLength) - g(length = slowLength);
def MACD_Avg = g(price = MACD_Value, length = MACDLength);
def Diff = MACD_Value - MACD_Avg;

def PositiveUp   = MACD_Value > MACD_Value[1] and MACD_Value > MACD_Avg ;
def NegativeUp   = MACD_Value < MACD_Value[1] and MACD_Value > MACD_Avg ;
def NegativeDown = MACD_Value < MACD_Value[1] and MACD_Value < MACD_Avg ;
def PostiveDown  = MACD_Value > MACD_Value[1] and MACD_Value < MACD_Avg ;

plot Buy_scan = MACD_value < 0 and MACD_value >= MACD_value[1] and MACD_Value crosses above MACD_Avg ;
plot Sell_scan =  MACD_value < MACD_avg and MACD_value < MACD_value[1] ;
Buy_scan.Hide();
Sell_scan.Hide();
plot Buy_signal = if Buy_scan and !Buy_scan[1] then MACD_value else double.NaN  ;
Buy_signal.SetPaintingStrategy(PaintingStrategy.LINE_Vs_poINTS);
Buy_signal.SetDefaultColor(color.cyan) ;
Buy_signal.SetLineWeight(5);
plot sell_signal = if sell_scan and !sell_scan[1] then MACD_value else double.NaN  ;
sell_signal.SetPaintingStrategy(PaintingStrategy.LINE_Vs_poINTS);
sell_signal.SetDefaultColor(color.magenta) ;
sell_signal.SetLineWeight(5);

# ########################################################
# Charting and Formatting
DefineGlobalColor("Pre_Cyan", CreateColor(50, 200, 255)) ;
DefineGlobalColor("LabelGreen",  CreateColor(0, 165, 0)) ;

input ShowLabels = yes ;
AddLabel(ShowLabels,
if buy_scan then "Begin" else
if sell_scan and !sell_scan[1] then "End" else
if PositiveUp then "👍 " + Round(Diff, 1) else
if PostiveDown then "👍 " + Round(Diff, 1) else
if NegativeUp then "Chg'g " + Round(Diff, 1) else
if NegativeDown then "👎 " + Round(Diff, 1) else " ");
AssignBackgroundColor(
if buy_scan then color.cyan else
if sell_scan and !sell_scan[1] then color.magenta else
if PositiveUp then CreateColor(50, 200, 255) else
if PostiveDown then CreateColor(0, 165, 0) else
if NegativeUp then Color.gray else
if NegativeDown then Color.RED else
 Color.GRAY);
Hi @MerryDay, first off thank you for taking the time to create this! So far i love it. I am still testing it, but i will let you know if i have any questions.
 
I am looking to get MACD as a label on my chart. I need it to show the breakout signals alert as a label. can someone please help with this??
 

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