Price-SMA Crossover

42 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")
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
SV Svenska
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
AR العربية
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing My Support Tickets Contact Support Ideas Published Followers Following Private Messages Chat Sign Out