Join useThinkScript to post your question to a community of 21,000+ developers and traders.
declare lower;
def data = close;
input MACD_type = {default SLOW, "FAST", TekMuNNee, Neo};
input averagetype = averageType.EXPONENTIAL;
input ShowNOWLabels = yes;
input ShowHOWLONGLabel = yes;
def fastlength;
def slowlength;
def MACDlength;
switch (MACD_Type) {
case SLOW:
fastlength = 33;
slowlength = 100;
MACDlength = 13;
case FAST:
fastlength = 12;
slowlength = 26;
MACDlength = 9;
case TekMunNee:
fastlength = 5;
slowlength = 9;
MACDlength = 5;
case Neo:
Fastlength = 5;
slowlength = 8;
MACDLength = 5;
}
def fastMacd = fastlength == 12 and slowlength == 26 and macdlength == 9;
def slowmacd = fastlength == 33 and slowlength == 100 and macdlength == 13;
def TekMuNNeeMACD = fastlength == 5 and slowlength == 9 and macdlength == 5;
def NeoMacd = fastlength == 5 and slowlength == 8 and macdlength == 5;
AddLabel(1,if slowmacd then "Slow MACD" else if fastmacd then "Fast MACD" else if tekmunneemacd then "TekMuNNee" else if NeoMacd then "MyNameIsNEO" else "AddOption", Color.YELLOW);
plot Value = MACD(fastLength, slowLength, MACDLength, averagetype).value;
plot Avg = MACD(fastLength, slowLength, MACDLength, averageType).Avg;
plot ZeroLine = 0;
value.setdefaultcolor(color.cyan);
avg.setdefaultcolor(color.yellow);
zeroline.setdefaultcolor(color.white);
def valueavg = average((value),14);
def valuehigh = highestall(valueavg);
#Addlabel(1,valuehigh,color.cyan);
def bullish = value > avg;
addlabel(shownowlabels,if value is greater than avg then "BULL" else "BEAR",if bullish then color.green else color.red);
addlabel(ShowHOWLONGlabel,if value is greater than avg then "BULL1" else "BEAR1",if bullish then color.green else color.red);
addlabel(ShowHOWLONGlabel,if value[1] is greater than avg[1] then "BULL2" else "BEAR2",if bullish[1] then color.green else color.red);
addlabel(ShowHOWLONGlabel,if value[2] is greater than avg[2] then "BULL3" else "BEAR3",if bullish[2] then color.green else color.red);
addlabel(ShowHOWLONGlabel,if value[3] is greater than avg[3] then "BULL4" else "BEAR4",if bullish[3] then color.green else color.red);
addlabel(ShowHOWLONGlabel,if value[4] is greater than avg[4] then "BULL5" else "BEAR5",if bullish[4] then color.green else color.red);
wow thank you for this appreciate itPersonal Opinion here:
You could:
1) slow down your MACD using 33,100,13, often referred to as a "slow MACD" (or a host of other possibilities).
or
2) consider adapting your MACD to a longer timeframe. Shorter timeframes like this present the "noise" you're experiencing.
What you're illustrating here is a combination of divergence and the math of the MACD itself.
I have come to accept the formation you're illustrating to be referred to personally as a "MACD ramp". It happens a fair bit and is worth paying attention to.
In the code below, I've set up a MACD with a switch. I was in a group with some people who had their own settings they had discovered and also, I wanted to switch the MACD settings faster.
You can copy the code of the MACD you're working with into a new indicator script and set up inputs for your levels to mess around and see what works for you.
This script also has a set of labels that give you an indication of whether the MACD is bullish or bearish along with showing you the last 5 periods.
Another tactic I've looked at with some success is adjusting the MACD to calculate based on highs and lows vs. just the close. I've never tried this, but, if you do stay with close, try setting it one bar back by adding [1]. Since "close" varies during a bar, the idea of "locking down" the MACD to the previous and complete close of the last bar could bring some clarity. Again, I've never tried it with MACD, but, I have done it with success.
Code:declare lower; def data = close; input MACD_type = {default SLOW, "FAST", TekMuNNee, Neo}; input averagetype = averageType.EXPONENTIAL; input ShowNOWLabels = yes; input ShowHOWLONGLabel = yes; def fastlength; def slowlength; def MACDlength; switch (MACD_Type) { case SLOW: fastlength = 33; slowlength = 100; MACDlength = 13; case FAST: fastlength = 12; slowlength = 26; MACDlength = 9; case TekMunNee: fastlength = 5; slowlength = 9; MACDlength = 5; case Neo: Fastlength = 5; slowlength = 8; MACDLength = 5; } def fastMacd = fastlength == 12 and slowlength == 26 and macdlength == 9; def slowmacd = fastlength == 33 and slowlength == 100 and macdlength == 13; def TekMuNNeeMACD = fastlength == 5 and slowlength == 9 and macdlength == 5; def NeoMacd = fastlength == 5 and slowlength == 8 and macdlength == 5; AddLabel(1,if slowmacd then "Slow MACD" else if fastmacd then "Fast MACD" else if tekmunneemacd then "TekMuNNee" else if NeoMacd then "MyNameIsNEO" else "AddOption", Color.YELLOW); plot Value = MACD(fastLength, slowLength, MACDLength, averagetype).value; plot Avg = MACD(fastLength, slowLength, MACDLength, averageType).Avg; plot ZeroLine = 0; value.setdefaultcolor(color.cyan); avg.setdefaultcolor(color.yellow); zeroline.setdefaultcolor(color.white); def valueavg = average((value),14); def valuehigh = highestall(valueavg); #Addlabel(1,valuehigh,color.cyan); def bullish = value > avg; addlabel(shownowlabels,if value is greater than avg then "BULL" else "BEAR",if bullish then color.green else color.red); addlabel(ShowHOWLONGlabel,if value is greater than avg then "BULL1" else "BEAR1",if bullish then color.green else color.red); addlabel(ShowHOWLONGlabel,if value[1] is greater than avg[1] then "BULL2" else "BEAR2",if bullish[1] then color.green else color.red); addlabel(ShowHOWLONGlabel,if value[2] is greater than avg[2] then "BULL3" else "BEAR3",if bullish[2] then color.green else color.red); addlabel(ShowHOWLONGlabel,if value[3] is greater than avg[3] then "BULL4" else "BEAR4",if bullish[3] then color.green else color.red); addlabel(ShowHOWLONGlabel,if value[4] is greater than avg[4] then "BULL5" else "BEAR5",if bullish[4] then color.green else color.red);
@autolox , Thanks for posting this awesome indicator. Is it possible to add sound alerts when value line crosses below 10% and when value line crosses above 90% (yes, its percent). Not sure what other modifications the code may require. Found a snippet of code (Thanks @MerryDay) that i modified / displays labels, not tested live or sure if it'll work. Posting code lines below with link to page.Personal Opinion here:
You could:
1) slow down your MACD using 33,100,13, often referred to as a "slow MACD" (or a host of other possibilities).
or
2) consider adapting your MACD to a longer timeframe. Shorter timeframes like this present the "noise" you're experiencing.
What you're illustrating here is a combination of divergence and the math of the MACD itself.
I have come to accept the formation you're illustrating to be referred to personally as a "MACD ramp". It happens a fair bit and is worth paying attention to.
In the code below, I've set up a MACD with a switch. I was in a group with some people who had their own settings they had discovered and also, I wanted to switch the MACD settings faster.
You can copy the code of the MACD you're working with into a new indicator script and set up inputs for your levels to mess around and see what works for you.
This script also has a set of labels that give you an indication of whether the MACD is bullish or bearish along with showing you the last 5 periods.
Another tactic I've looked at with some success is adjusting the MACD to calculate based on highs and lows vs. just the close. I've never tried this, but, if you do stay with close, try setting it one bar back by adding [1]. Since "close" varies during a bar, the idea of "locking down" the MACD to the previous and complete close of the last bar could bring some clarity. Again, I've never tried it with MACD, but, I have done it with success.
Code:declare lower; def data = close; input MACD_type = {default SLOW, "FAST", TekMuNNee, Neo}; input averagetype = averageType.EXPONENTIAL; input ShowNOWLabels = yes; input ShowHOWLONGLabel = yes; def fastlength; def slowlength; def MACDlength; switch (MACD_Type) { case SLOW: fastlength = 33; slowlength = 100; MACDlength = 13; case FAST: fastlength = 12; slowlength = 26; MACDlength = 9; case TekMunNee: fastlength = 5; slowlength = 9; MACDlength = 5; case Neo: Fastlength = 5; slowlength = 8; MACDLength = 5; } def fastMacd = fastlength == 12 and slowlength == 26 and macdlength == 9; def slowmacd = fastlength == 33 and slowlength == 100 and macdlength == 13; def TekMuNNeeMACD = fastlength == 5 and slowlength == 9 and macdlength == 5; def NeoMacd = fastlength == 5 and slowlength == 8 and macdlength == 5; AddLabel(1,if slowmacd then "Slow MACD" else if fastmacd then "Fast MACD" else if tekmunneemacd then "TekMuNNee" else if NeoMacd then "MyNameIsNEO" else "AddOption", Color.YELLOW); plot Value = MACD(fastLength, slowLength, MACDLength, averagetype).value; plot Avg = MACD(fastLength, slowLength, MACDLength, averageType).Avg; plot ZeroLine = 0; value.setdefaultcolor(color.cyan); avg.setdefaultcolor(color.yellow); zeroline.setdefaultcolor(color.white); def valueavg = average((value),14); def valuehigh = highestall(valueavg); #Addlabel(1,valuehigh,color.cyan); def bullish = value > avg; addlabel(shownowlabels,if value is greater than avg then "BULL" else "BEAR",if bullish then color.green else color.red); addlabel(ShowHOWLONGlabel,if value is greater than avg then "BULL1" else "BEAR1",if bullish then color.green else color.red); addlabel(ShowHOWLONGlabel,if value[1] is greater than avg[1] then "BULL2" else "BEAR2",if bullish[1] then color.green else color.red); addlabel(ShowHOWLONGlabel,if value[2] is greater than avg[2] then "BULL3" else "BEAR3",if bullish[2] then color.green else color.red); addlabel(ShowHOWLONGlabel,if value[3] is greater than avg[3] then "BULL4" else "BEAR4",if bullish[3] then color.green else color.red); addlabel(ShowHOWLONGlabel,if value[4] is greater than avg[4] then "BULL5" else "BEAR5",if bullish[4] then color.green else color.red);
On your last line, I figure you'll need to make that .99 vs. 99.9.@autolox , Thanks for posting this awesome indicator. Is it possible to add sound alerts when value line crosses below 10% and when value line crosses above 90% (yes, its percent). Not sure what other modifications the code may require. Found a snippet of code (Thanks @MerryDay) that i modified / displays labels, not tested live or sure if it'll work. Posting code lines below with link to page.
Link
https://usethinkscript.com/threads/...list-for-thinkorswim.7745/page-12#post-139326
Modified untested code from link
def nMACD = MACD();
AddLabel(yes, value,
if value<0.01 then color.white else color.black );
AddLabel(yes, VALUE,
if VAlUE>99.9 then color.white else color.black );
Thank you for taking time to respond while on vacation! This website has contributed significantly to my wealth of indicator knowledge. Its been a couple of years of hard work and taking significant losses to be where I am today, as is the norm for many new traders, I guess! As mentioned in a couple of posts before, this could be something big or fizzle out (as it did in those posts!) and feel uneasy posting untested code. Would feel more comfortable publicly posting reasonably tested code. You are the author of this indicator, hence reaching out to you.On your last line, I figure you'll need to make that .99 vs. 99.9.
I'm away from the desk for vacation, so, it'll be a bit before I can try the % idea. Another thing you can do is average the two lines into one single line.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
![]() |
How to avoid labels hide lines? | Questions | 6 | |
![]() |
How to avoid noisy market | Questions | 7 | |
D | Avoid plotting study in Premarket/aftermarket charting | Questions | 4 | |
E | Help: ATR Zones, EMA Cloud, MACD, and Structure Lines | Questions | 0 | |
J | psar macd --need ma cross | Questions | 0 |
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.