vatsid

Price-SMA Crossover

38 0 3
If Price > SMA , show green bars, else red
Remove from Favorite Scripts Add to Favorite Scripts
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 20/06/2014
// Modified by Vats, Due thanks to HPotter
// This modified version uses crossover of price (close) and its simple moving average (default 20 period SMA)

// 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="Price-SMA Crossover", shorttitle="Price-SMA Crossover", overlay = true)
LengthSMA = input(20,minval=2)
xSMA = sma(close, LengthSMA)
pos = iff(xSMA < close , 1,
	    iff(xSMA > close, -1, nz(pos[1], 0))) 
barcolor(pos == -1 ? red: pos == 1 ? lime : blue)
plot(close, color=white, title="MA")
plot(xSMA, color=lime, title="SMA")
Ideas Scripts Chart
United States
United Kingdom
India
España
Italia
Brasil
Россия
Türkiye
日本
한국
Home Stock Screener Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter
Private Messages Chat Ideas Published Followers Following Priority Support Public Profile Profile Settings Billing Sign Out