dual macd candles

jhogue78

New member
Currently finding value using a hull macd and exp Macd both on the 5 min timeframe. Would love to have my candles turn green when both (MACD's) are green and red when both are red concurrently. Neutral candles sound be any color or a user defined single color. Im using the standard MACD study provided in thinkorswim for both. Is this possible? Im admittedly not proficient with think script or pine script but would appreciate any help.
Thanks in advance
 
Solution
Currently finding value using a hull macd and exp Macd both on the 5 min timeframe. Would love to have my candles turn green when both (MACD's) are green and red when both are red concurrently. Neutral candles sound be any color or a user defined single color. Im using the standard MACD study provided in thinkorswim for both. Is this possible? Im admittedly not proficient with think script or pine script but would appreciate any help.
Thanks in advance

Code:
# macd_double_0

#https://usethinkscript.com/threads/dual-macd-candles.15288/
#dual macd candles

def na = Double.NaN;
def bn = BarNumber();

#----------------------------
# macd - hull
input m1_averageType = AverageType.HULL;
input m1_fast_Len = 12;
input m1_slow_Len = 26...
Currently finding value using a hull macd and exp Macd both on the 5 min timeframe. Would love to have my candles turn green when both (MACD's) are green and red when both are red concurrently. Neutral candles sound be any color or a user defined single color. Im using the standard MACD study provided in thinkorswim for both. Is this possible? Im admittedly not proficient with think script or pine script but would appreciate any help.
Thanks in advance

Code:
# macd_double_0

#https://usethinkscript.com/threads/dual-macd-candles.15288/
#dual macd candles

def na = Double.NaN;
def bn = BarNumber();

#----------------------------
# macd - hull
input m1_averageType = AverageType.HULL;
input m1_fast_Len = 12;
input m1_slow_Len = 26;
input MACD1_Length = 9;

def m1_Value = MovingAverage(m1_averageType, close, m1_fast_Len) - MovingAverage(m1_averageType, close, m1_slow_Len);
def m1_Avg = MovingAverage(m1_averageType, m1_Value, MACD1_Length);
def m1_Diff = m1_Value - m1_Avg;

def m1_up = (m1_Diff >= 0 and m1_Diff > m1_Diff[1]);
def m1_dwn = (m1_Diff <= 0 and m1_Diff < m1_Diff[1]); 


#----------------------------
# macd - exp
input m2_averageType = AverageType.EXPONENTIAL;
input m2_fast_Len = 12;
input m2_slow_Len = 26;
input MACD2_Length = 9;

def m2_Value = MovingAverage(m2_averageType, close, m2_fast_Len) - MovingAverage(m2_averageType, close, m2_slow_Len);
def m2_Avg = MovingAverage(m2_averageType, m2_Value, MACD2_Length);
def m2_Diff = m2_Value - m2_Avg;

def m2_up = (m2_Diff >= 0 and m2_Diff > m2_Diff[1]);
def m2_dwn = (m2_Diff <= 0 and m2_Diff < m2_Diff[1]); 


#----------------------------

def grn = m1_up and m2_up;
def red = m1_dwn and m2_dwn;

input change_bar_color = yes;

AssignPriceColor(if change_bar_color and grn then color.green
 else if change_bar_color and red then color.red
 else if change_bar_color then color.gray
 else color.current);

#----------------------------

input test_updwndots = no;

plot z1up = if test_updwndots and m1_up then high*1.002 else na;
z1up.SetPaintingStrategy(PaintingStrategy.points);
z1up.SetDefaultColor(Color.green);
z1up.setlineweight(2);
z1up.hidebubble();

plot z2up = if test_updwndots and m2_up then high*1.004 else na;
z2up.SetPaintingStrategy(PaintingStrategy.points);
z2up.SetDefaultColor(Color.cyan);
z2up.setlineweight(2);
z2up.hidebubble();


plot z1dwn = if test_updwndots and m1_dwn then low*0.998 else na;
z1dwn.SetPaintingStrategy(PaintingStrategy.points);
z1dwn.SetDefaultColor(Color.red);
z1dwn.setlineweight(2);
z1dwn.hidebubble();

plot z2dwn = if test_updwndots and m2_dwn then low*0.996 else na;
z2dwn.SetPaintingStrategy(PaintingStrategy.points);
z2dwn.SetDefaultColor(Color.yellow);
z2dwn.setlineweight(2);
z2dwn.hidebubble();

#
 
Solution
Code:
# macd_double_0

#https://usethinkscript.com/threads/dual-macd-candles.15288/
#dual macd candles

def na = Double.NaN;
def bn = BarNumber();

#----------------------------
# macd - hull
input m1_averageType = AverageType.HULL;
input m1_fast_Len = 12;
input m1_slow_Len = 26;
input MACD1_Length = 9;

def m1_Value = MovingAverage(m1_averageType, close, m1_fast_Len) - MovingAverage(m1_averageType, close, m1_slow_Len);
def m1_Avg = MovingAverage(m1_averageType, m1_Value, MACD1_Length);
def m1_Diff = m1_Value - m1_Avg;

def m1_up = (m1_Diff >= 0 and m1_Diff > m1_Diff[1]);
def m1_dwn = (m1_Diff <= 0 and m1_Diff < m1_Diff[1]);


#----------------------------
# macd - exp
input m2_averageType = AverageType.EXPONENTIAL;
input m2_fast_Len = 12;
input m2_slow_Len = 26;
input MACD2_Length = 9;

def m2_Value = MovingAverage(m2_averageType, close, m2_fast_Len) - MovingAverage(m2_averageType, close, m2_slow_Len);
def m2_Avg = MovingAverage(m2_averageType, m2_Value, MACD2_Length);
def m2_Diff = m2_Value - m2_Avg;

def m2_up = (m2_Diff >= 0 and m2_Diff > m2_Diff[1]);
def m2_dwn = (m2_Diff <= 0 and m2_Diff < m2_Diff[1]);


#----------------------------

def grn = m1_up and m2_up;
def red = m1_dwn and m2_dwn;

input change_bar_color = yes;

AssignPriceColor(if change_bar_color and grn then color.green
 else if change_bar_color and red then color.red
 else if change_bar_color then color.gray
 else color.current);

#----------------------------

input test_updwndots = no;

plot z1up = if test_updwndots and m1_up then high*1.002 else na;
z1up.SetPaintingStrategy(PaintingStrategy.points);
z1up.SetDefaultColor(Color.green);
z1up.setlineweight(2);
z1up.hidebubble();

plot z2up = if test_updwndots and m2_up then high*1.004 else na;
z2up.SetPaintingStrategy(PaintingStrategy.points);
z2up.SetDefaultColor(Color.cyan);
z2up.setlineweight(2);
z2up.hidebubble();


plot z1dwn = if test_updwndots and m1_dwn then low*0.998 else na;
z1dwn.SetPaintingStrategy(PaintingStrategy.points);
z1dwn.SetDefaultColor(Color.red);
z1dwn.setlineweight(2);
z1dwn.hidebubble();

plot z2dwn = if test_updwndots and m2_dwn then low*0.996 else na;
z2dwn.SetPaintingStrategy(PaintingStrategy.points);
z2dwn.SetDefaultColor(Color.yellow);
z2dwn.setlineweight(2);
z2dwn.hidebubble();

#
Very much appreciated
 

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