HPotter

EMA & MA Crossover

The Moving Average Crossover trading strategy is possibly the most popular
trading strategy in the world of trading. First of them were written in the
middle of XX century, when commodities trading strategies became popular.
This strategy is a good example of so-called traditional strategies.
Traditional strategies are always long or short. That means they are never
out of the market. The concept of having a strategy that is always long or
short may be scary, particularly in today’s market where you don’t know what
is going to happen as far as risk on any one market. But a lot of traders
believe that the concept is still valid, especially for those of traders who
do their own research or their own discretionary trading.
This version uses crossover of moving average and its exponential moving average .
Remove from Favorite Scripts Add to Favorite Scripts
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 20/06/2014
// The Moving Average Crossover trading strategy is possibly the most popular
// trading strategy in the world of trading. First of them were written in the
// middle of XX century, when commodities trading strategies became popular.
// This strategy is a good example of so-called traditional strategies. 
// Traditional strategies are always long or short. That means they are never 
// out of the market. The concept of having a strategy that is always long or 
// short may be scary, particularly in today’s market where you don’t know what 
// is going to happen as far as risk on any one market. But a lot of traders 
// believe that the concept is still valid, especially for those of traders who 
// do their own research or their own discretionary trading. 
// This version uses crossover of moving average and its exponential moving average. 
////////////////////////////////////////////////////////////
study(title="EMA & MA Crossover", shorttitle="EMA & MA Crossover", overlay = true)
LengthMA = input(10, minval=1)
LengthEMA = input(10,minval=1)
xMA = sma(close, LengthMA)
xEMA = ema(xMA, LengthEMA)
pos = iff(xEMA < xMA , 1,
	    iff(xEMA > xMA, -1, nz(pos[1], 0))) 
barcolor(pos == -1 ? red: pos == 1 ? green : blue)
plot(xMA, color=red, title="MA")
plot(xEMA, color=blue, title="EMA")

Comments

do you have that for mt5 ? cheers
thank you for your work
Reply
HPotter filipeaguiartrader
@filipeaguiartrader, No. Sorry.
Reply
Hey there I’m trying to add this indicator on my trading view page but it doesn’t come up on indicators. Can you please assist?
Reply
HPotter jeffersonabreu
@jeffersonabreu, Hi, what are your steps?
Reply
Why does this change the colour of the bars ?
Reply
HPotter acjohno18
@acjohno18, It recommended way - long or short signal. You can make comment this line: barcolor.... and change the color will fix.
Reply
This strategy is even better if you consider the volatility. Sometimes, MA leads the price ;)
Reply
Looks great - well done!
Now I want to use this to screen stocks that just did a crossover. How do I use this indicator script for screening in Tradingview?
+13 Reply
Hey mate, nice indicator. Works great. Just wondering how to add this indicator manually in MT4? Do I set one Simple MA and one Exponential MA at both 10?
+2 Reply
HPotter JimmyJambles
Hi, you should to use one sma 10 and then calculate Exponential MA 10 from sma 10, double smooting. And it will be same.

+9 Reply
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter
Profile Profile Settings Account and Billing Refer a friend My Support Tickets Help Center Ideas Published Followers Following Private Messages Chat Sign Out