# Price hit EMA 20 and MACD crossover average

#### tinxox7

##### New member
Someone help me with the script like this :
Price is greater than or equal to EMA 20 and MACD cross above Average
Price is less than or equal to EMA 20 and MACD cross below Average
I would like to get arrow signal on the upper chart
I appreciate for helping me

Last edited by a moderator:
Solution
Someone help me with the script like this :
Price is greater than or equal to EMA 20 and MACD cross above Average
Price is less than or equal to EMA 20 and MACD cross below Average
I would like to get arrow signal on the upper chart
I appreciate for helping me

Code:
``````#macd_ema_signals

#Price hit EMA 20 and MACD crossover average
#tinxox7  Sep 19, 2023

#Someone help me with the script like this :
#Price is greater than or equal to EMA 20 and MACD cross above Average
#Price is less than or equal to EMA 20 and MACD cross below Average
#I would like to get arrow signal on the upper chart

#declare lower;

def na = Double.NaN;
def bn =...``````
Someone help me with the script like this :
Price is greater than or equal to EMA 20 and MACD cross above Average
Price is less than or equal to EMA 20 and MACD cross below Average
I would like to get arrow signal on the upper chart
I appreciate for helping me

Code:
``````#macd_ema_signals

#Price hit EMA 20 and MACD crossover average
#tinxox7  Sep 19, 2023

#Someone help me with the script like this :
#Price is greater than or equal to EMA 20 and MACD cross above Average
#Price is less than or equal to EMA 20 and MACD cross below Average
#I would like to get arrow signal on the upper chart

#declare lower;

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

input avg1_type = AverageType.exponential;
#input avg1_type = AverageType.Simple;
input avg1_length = 20;
def avg1 = MovingAverage(avg1_type, data, avg1_length );

input show_average_lines = yes;
plot zavg1 = if show_average_lines then avg1 else na;

#-------------------------
# macd
# TD Ameritrade IP Company, Inc. (c) 2007-2023
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;

def Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
def Avg = MovingAverage(averageType, Value, MACDLength);
def Diff = Value - Avg;
def ZeroLine = 0;

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

def Upx = (close > avg1 and value crosses above avg);
def Downx = (close < avg1 and value crosses below avg);

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

input show_arrows = yes;
input v1 = 0.002;
plot zup = if upx then low * ( 1-v1) else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.GREEN);
zup.SetLineWeight(3);
zup.HideBubble();

plot zdwn = if downx then high * ( 1+v1) else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.RED);
zdwn.SetLineWeight(1);
zdwn.HideBubble();
#``````

Code:
``````#macd_ema_signals

#Price hit EMA 20 and MACD crossover average
#tinxox7  Sep 19, 2023

#Someone help me with the script like this :
#Price is greater than or equal to EMA 20 and MACD cross above Average
#Price is less than or equal to EMA 20 and MACD cross below Average
#I would like to get arrow signal on the upper chart

#declare lower;

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

input avg1_type = AverageType.exponential;
#input avg1_type = AverageType.Simple;
input avg1_length = 20;
def avg1 = MovingAverage(avg1_type, data, avg1_length );

input show_average_lines = yes;
plot zavg1 = if show_average_lines then avg1 else na;

#-------------------------
# macd
# TD Ameritrade IP Company, Inc. (c) 2007-2023
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
input showBreakoutSignals = no;

def Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
def Avg = MovingAverage(averageType, Value, MACDLength);
def Diff = Value - Avg;
def ZeroLine = 0;

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

def Upx = (close > avg1 and value crosses above avg);
def Downx = (close < avg1 and value crosses below avg);

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

input show_arrows = yes;
input v1 = 0.002;
plot zup = if upx then low * ( 1-v1) else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zup.SetDefaultColor(Color.GREEN);
zup.SetLineWeight(3);
zup.HideBubble();

plot zdwn = if downx then high * ( 1+v1) else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zdwn.SetDefaultColor(Color.RED);
zdwn.SetLineWeight(1);
zdwn.HideBubble();
#``````
thank you so much. I appreciate it.

Last edited by a moderator:
Is it possible to make this into a watchlist column that displays green when bullish signal appears and red when a bearish signal appears?

87k+ Posts
193 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?