0% found this document useful (0 votes)
35 views

Support Resistance MTF With EMA No Change Color

The document describes a Pine script for identifying support and resistance levels on multiple time frames using highest/lowest bars and EMAs. It inputs parameters like the source, timeframe, period for highest/lowest bars, and colors. It then calculates highest and lowest bars, plots support and resistance zones, and adds four EMA lines with customizable colors. Optional lines can extend support and resistance levels left from the current bar.

Uploaded by

Deni Suryadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Support Resistance MTF With EMA No Change Color

The document describes a Pine script for identifying support and resistance levels on multiple time frames using highest/lowest bars and EMAs. It inputs parameters like the source, timeframe, period for highest/lowest bars, and colors. It then calculates highest and lowest bars, plots support and resistance zones, and adds four EMA lines with customizable colors. Optional lines can extend support and resistance levels left from the current bar.

Uploaded by

Deni Suryadi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

//@version=4

study("Support Resistance MTF with EMA", overlay=true, max_bars_back = 4900)

src = input(defval = 'High/Low', title = "Source", options = ['High/Low',


'Close/Open'])
TimeframeU = input(defval = 'Auto', title ="Higher Time Frame", options = ['Auto',
'15', '30', '60', '120', '180', '240', '720', 'D', 'W', '2W', 'M', '3M', '6M',
'12M'])
prd = input(defval = 10, title = "Period for Highest/Lowest Bars", minval = 1)

// Custom Colors for EMA


ema20Color = input(color.green, title="EMA 20 Color")
ema50Color = input(color.yellow, title="EMA 50 Color")
ema100Color = input(color.aqua, title="EMA 100 Color")
ema200Color = input(color.orange, title="EMA 200 Color")

// Resistance and Support Colors


resistancecol = input(defval = color.red, title = "Resistance Color")
supportcol = input(defval = color.lime, title = "Support Color")

Transp = input(defval = 80, title = "Transparency for Zones", minval = 0, maxval =


100)
extendlines = input(defval = false, title = "Extend Lines")

Timeframe = timeframe.period
if TimeframeU == 'Auto'
Timeframe := timeframe.period == '1' ? '15' :
timeframe.period == '3' ? '15' :
timeframe.period == '5' ? '60' :
timeframe.period == '15' ? '60' :
timeframe.period == '30' ? '120' :
timeframe.period == '45' ? '120' :
timeframe.period == '60' ? '240' :
timeframe.period == '120' ? 'D' :
timeframe.period == '180' ? 'D' :
timeframe.period == '240' ? 'D' :
timeframe.period == 'D' ? 'W' :
timeframe.period == 'W' ? 'M' :
'12M'
else
Timeframe := TimeframeU

var float hc = na
var float lc = na
srch = src == 'High/Low' ? high : max(close, open)
srcl = src == 'High/Low' ? low : min(close, open)
hc := highestbars(srch, prd) == 0 ? srch : hc
lc := lowestbars(srcl, prd) == 0 ? srcl : lc

hcp = plot(hc, color = hc == hc[1] ? resistancecol : na)


lcp = plot(lc, color = lc == lc[1] ? supportcol : na)

bool newbar = change(time(Timeframe)) != 0


var float htfh = na
var float htfl = na
if newbar
htfh := srch
htfl := srcl
else
htfh := max(htfh, srch)
htfl := min(htfl, srcl)

highestbar(src, len)=>
ll = 1
if len > 1
for x = 0 to 4000
if na(newbar[x]) or na(close[x + 1])
break
if newbar[x]
if src <= src[x + 1]
break
ll := ll + 1
if ll >= len
break
ret = ll >= len

lowestbar(src, len)=>
ll = 1
if len > 1
for x = 0 to 4000
if na(newbar[x]) or na(close[x + 1])
break
if newbar[x]
if src >= src[x + 1]
break
ll := ll + 1
if ll >= len
break
ret = ll >= len

var float hh = 0
var float ll = 0
bool hbar = highestbar(htfh, prd)
bool lbar = lowestbar(htfl, prd)
hh := hbar ? htfh : hh
ll := lbar ? htfl : ll

hhp = plot(hh, color = hc == hc[1] and hh == hh[1] ? resistancecol : na)


llp = plot(ll, color = lc == lc[1] and ll == ll[1] ? supportcol : na)

fill(hhp, hcp, color = hc == hc[1] and hh == hh[1] ? color.new(resistancecol,


Transp) : na)
fill(llp, lcp, color = lc == lc[1] and ll == ll[1] ? color.new(supportcol,
Transp) : na)

// EMA 20
length20 = input(20, title="EMA 20 Period")
ema20 = ema(close, length20)
plot(ema20, color=ema20Color, title="EMA 20")

// EMA 50
length50 = input(50, title="EMA 50 Period")
ema50 = ema(close, length50)
plot(ema50, color=ema50Color, title="EMA 50")

// EMA 100
length100 = input(100, title="EMA 100 Period")
ema100 = ema(close, length100)
plot(ema100, color=ema100Color, title="EMA 100")

// EMA 200
length200 = input(200, title="EMA 200 Period")
ema200 = ema(close, length200)
plot(ema200, color=ema200Color, title="EMA 200")

// extend lines
if extendlines
var line s1 = na
var line s2 = na
var line r1 = na
var line r2 = na
line.delete(s1)
line.delete(s2)
line.delete(r1)
line.delete(r2)
s1 := line.new(bar_index, lc, bar_index - 1, lc, color = supportcol, extend =
extend.left)
s2 := line.new(bar_index, ll, bar_index - 1, ll, color = supportcol, extend =
extend.left)
r1 := line.new(bar_index, hc, bar_index - 1, hc, color = resistancecol, extend
= extend.left)
r2 := line.new(bar_index, hh, bar_index - 1, hh, color = resistancecol, extend
= extend.left)

You might also like