Moving average convergence watchlist

guthiwari

New member
VIP
Hi Experts,

Is there a way to have a watchlist column to indicate when say 5,8 and 13 EMA's converge or very close to each other?

Thanks
 
Last edited:
Solution
This may be close to what you're looking for. I have it as a scan right now, but you should be able to make it into a watch list without too much difficulty.

Code:
input closeness = 0.0005;

def ema05 = MovingAverage(averageType = AverageType.EXPONENTIAL, length = 5, data = close);

def ema08 = MovingAverage(averageType = AverageType.EXPONENTIAL, length = 8, data = close);

def ema13 = MovingAverage(averageType = AverageType.EXPONENTIAL, length = 13, data = close);

def highest = max(max(ema05, ema08), ema13);
def lowest = min(min(ema05, ema08), ema13);

def middle = (highest + lowest) / 2;

def upperbound = middle * (1 + closeness);
def lowerbound = middle * (1 - closeness);

def cond1 = if ema05 > lowerbound AND ema05 < upperbound then...
This may be close to what you're looking for. I have it as a scan right now, but you should be able to make it into a watch list without too much difficulty.

Code:
input closeness = 0.0005;

def ema05 = MovingAverage(averageType = AverageType.EXPONENTIAL, length = 5, data = close);

def ema08 = MovingAverage(averageType = AverageType.EXPONENTIAL, length = 8, data = close);

def ema13 = MovingAverage(averageType = AverageType.EXPONENTIAL, length = 13, data = close);

def highest = max(max(ema05, ema08), ema13);
def lowest = min(min(ema05, ema08), ema13);

def middle = (highest + lowest) / 2;

def upperbound = middle * (1 + closeness);
def lowerbound = middle * (1 - closeness);

def cond1 = if ema05 > lowerbound AND ema05 < upperbound then 1 else 0;
def cond2 = if ema08 > lowerbound AND ema08 < upperbound then 1 else 0;
def cond3 = if ema13 > lowerbound AND ema13 < upperbound then 1 else 0;

plot eureka = if cond1 == 1 AND cond2 == 1 and cond3 == 1 then 1 else double.nan;

To run through what it's doing...
It calculates the 5, 8, and 13 EMAs
It finds the highest of those three
it finds the lowest of the three
it finds the average of the highest and lowest
it finds boundaries within whatever closeness you've specified
it checks whether each ema is between those boundaries
if all three emas are between the boundaries, it is a hit.

Note that I prefer explicit 1 and 0 results for things. it makes debugging much simpler than implied true and false statements.

I, of course, didn't actually look at any of the results, but with closeness Set at 0.0005 and a minimum price of 5 and a min vol of 1M, I got back something like 14 results.

happy trading,
mashume
 
Solution
This may be close to what you're looking for. I have it as a scan right now, but you should be able to make it into a watch list without too much difficulty.

Code:
input closeness = 0.0005;

def ema05 = MovingAverage(averageType = AverageType.EXPONENTIAL, length = 5, data = close);

def ema08 = MovingAverage(averageType = AverageType.EXPONENTIAL, length = 8, data = close);

def ema13 = MovingAverage(averageType = AverageType.EXPONENTIAL, length = 13, data = close);

def highest = max(max(ema05, ema08), ema13);
def lowest = min(min(ema05, ema08), ema13);

def middle = (highest + lowest) / 2;

def upperbound = middle * (1 + closeness);
def lowerbound = middle * (1 - closeness);

def cond1 = if ema05 > lowerbound AND ema05 < upperbound then 1 else 0;
def cond2 = if ema08 > lowerbound AND ema08 < upperbound then 1 else 0;
def cond3 = if ema13 > lowerbound AND ema13 < upperbound then 1 else 0;

plot eureka = if cond1 == 1 AND cond2 == 1 and cond3 == 1 then 1 else double.nan;

To run through what it's doing...
It calculates the 5, 8, and 13 EMAs
It finds the highest of those three
it finds the lowest of the three
it finds the average of the highest and lowest
it finds boundaries within whatever closeness you've specified
it checks whether each ema is between those boundaries
if all three emas are between the boundaries, it is a hit.

Note that I prefer explicit 1 and 0 results for things. it makes debugging much simpler than implied true and false statements.

I, of course, didn't actually look at any of the results, but with closeness Set at 0.0005 and a minimum price of 5 and a min vol of 1M, I got back something like 14 results.

happy trading,
mashume
Excellent ! Thanks mashume
 

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