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

#https://usethinkscript.com/threads/price-hit-ema-20-and-macd-crossover-average.16575/
#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

#https://usethinkscript.com/threads/price-hit-ema-20-and-macd-crossover-average.16575/
#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();
#
 
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Code:
#macd_ema_signals

#https://usethinkscript.com/threads/price-hit-ema-20-and-macd-crossover-average.16575/
#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:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
329 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