repo32

Moving Average Colored EMA/SMA

This script will give you the ability to put an EMA and/or SMA on the chart that changes color based upon the direction. Default at startup is EMA visible and SMA hidden. When the MA is moving up, it is green. When the MA is moving down, it is red. You can change the color to whatever you like.
Keluarkan daripada Skrip Pilihan Tambah kepada Skrip Pilihan
//Created by Robert Nance on 072315
study(title="Moving Average Colored EMA/SMA", shorttitle="Colored EMA /SMA", overlay=true)
emaplot = input (true, title="Show EMA on chart")
len = input(8, minval=1, title="ema Length")
src = close
out = ema(src, len)
up = out > out[1]
down = out < out[1]
mycolor = up ? green : down ? red : blue
plot(out and emaplot ? out :na, title="EMA", color=mycolor, linewidth=3)


smaplot = input (false, title="Show SMA on chart")
len2 = input(8, minval=1, title="sma Length")
src2 = close
out2 = sma(src2, len2)
up2 = out2 > out2[1]
down2 = out2 < out2[1]
mycolor2 = up2 ? green : down2 ? red : blue
plot(out2 and smaplot ? out2 :na , title="SMA", color=mycolor2, linewidth=1)

Komen

can this indicator give message when price crossing line?
+5 Balas
repo32 vitalycool
@vitalycool, You can do that with most indicators. Just right click on the line and setup an alert.
+1 Balas
which language it is> and howto use?
+2 Balas
This is really great, thanks for making it available.

I'm trying to apply the idea to this HPotter's ADV Line indicator, but can't figure it out. Any chance you could help?
This is the code:

study(title="Advance/Decline Volume Line", shorttitle="ADV Line", overlay = false)
AdvSymbolVolume = input(title="Advancing Volume Symbol", type=symbol, defval="USI:UVOL")
DecSymbolVolume = input(title="Declining Volume Symbol", type=symbol, defval="USI:DVOL")
Resolutin = input(title="Resolution", type=resolution, defval="D")
xASVValue = security(AdvSymbolVolume, Resolutin, close)
xDSVValue = security(DecSymbolVolume, Resolutin, close)
NetADV = xASVValue - xDSVValue
nRes = nz(nRes, 0) + NetADV
plot(nRes, color=green, title="ADV Line", style=line)

Many thanks in advance.
+2 Balas
repo32 OTMRob
@OTMRob, At first glance you are trying to create a new value that is referencing itself (nRes): nRes = nz(nRes, 0) + NetADV
Balas
OTMRob repo32
@repo32, thanks for the reply, sorry to take so long to reply myself, I hadn't noticed the alert...
I'm not familiar enough with pine to understand what you're saying there about the self referencing value, unfortunately, but would love to try to understand if you have the time to explain. This is @HPotter 's script.

I would be happy to pay for the script above with code that changes color based upon the direction added in.

Thanks,
Rob
Balas
repo32 OTMRob
@OTMRob, Please post the link to the script.
+1 Balas
OTMRob repo32
@repo32,

Thanks in advance.
Balas
repo32 OTMRob
@OTMRob, Just remove the last line from his script and add the following:

UnRes = nRes > nRes
DnRes = nRes < nRes
mycolor =UnRes ? green : DnRes ? red:blue
plot(nRes, color=mycolor, title="ADV Line", style=line)
Balas
repo32 repo32
@repo32, Not sure why the is being removed from the end of the first two lines.
Balas
Laman Utama Penyaring Saham Penyaring Forex Penyaring Kripto Kalendar Ekonomi Bagaimana ia berfungsi Ciri-ciri Carta Harga Rujuk rakan Peraturan Dalaman Pusat Bantuan Laman web dan Penyelesaian Broker Widget Penyelesaian Pencartaan Perpustakaan Pencartaan yang Ringan Blog & Berita Twitter
Profil Tetapan Profil Akaun dan Pengebilan Kawan-kawan yang dirujuk Coin Tiket Sokongan Saya Pusat Bantuan Idea yang diterbitkan Pengikut Mengikuti Mesej Peribadi Sembang Daftar Keluar