Trender & mov avg Jayy update

638 visualizzazioni
638 0
The Trender and moving average for a version of trend analysis. This is an update of a previously published script. A recent Pine script update makes this update necessary.
This is my interpretation of Bloomberg's Trender.
The script is derived from this document:

I have no idea what settings are best. I like the ones I have used because I see some harmony with the
20ema but that could be said for a variety of settings. The chief variable for adjustment is "sensitivity" which is really just the number of standard deviations away from the midpoint calculation. The Trender is plotted as crosses.
Also the moving average will be green if its own 8 period moving average is below the
moving average or red if it is above. In other words a Green moving average suggests an uptrend and a red moving average a down trend as far as moving averages are concerned. In formatting you can have an ema or sma at the click of a button. also at the bottom you will have an option to display moving averages as emas in intraday and smas if the period is daily or higher. In this option you will also see the 50 moving average ( ema if intraday and sma if daily or more.) Most people will opt for consistency and simply use either an ema or sma . In this case leave the
"Show EMAs intraday and smas interday" unchecked.
Rimuovi dagli script preferiti Aggiungi agli script preferiti
//The Trender and moving average for trend analysis

// This is my interpretation of Bloombergs Trender.
// The script is derived from a few limnes in this this document:
// //http://www.forexfactory.com/attachment.php?attachmentid=704677&d=1306114269
// I have no idea what settings are best.
// The the moving average will be green if its own 8 period moving average is below the 
// moving average or red if it is above.  Green suggests an uptrend and red a down trend
// as far as moving averages are concerned.  
// As well there is a moving average either 20 ema or 20 sma.
// The averaging period is adjustable.

study("Trender & mov avg Jayy", overlay=true)
showTrndr= input(true, title= " Show The Trender?")
EMP = input (8, title = "Length of midpoint (hl2) ema for Trender ")
EATR = input (9, title = "Length of EMA ATR for Trender")
EATRsd = input (8, title = "Length of Std Deviation for Trender")
multsd = input(3,minval=.2, title="multiple of std deviation for Trender" )
smas20=input(true,  title="Show 20 period moving average")
smas8=input(false, title=" Show signal line (8 period) of 20 period moving average")

THEMA=input(true,   title=" check for EMA with  ema signal line uncheck for sma?")
//THESMA=input(false, type=bool,  title="Show SMA with sma signal line?")
lenei = input (20, title="period for ema")
lenei_ema = input (8, title="period for signal line of the ema")
lensd = input (20, title=" period for sma ")
lensd_sma = input (8, title="period for signal line of the sma")
lene50 = input (50, title="intraday period longest ema  - intraday ema")
lens50 = input (50, title=" interday period longest sma - interday sma")
LWMA=input(false, type=bool,  title=" Show EMAs intraday and smas interday")
smas50=input(true, type=bool,  title=" Show 50 period moving average if box above checked")
TRperiod = tr(false)
ADMl=  ema(hl2,EMP) + ema(TRperiod,EATR)/2
ADMs=ema(hl2,EMP)- ema(TRperiod,EATR)/2
hibndfr = ADMl + stdev(ema(TRperiod,EATR),EATRsd)* multsd
lobndfr= ADMs - stdev(ema(TRperiod,EATR),EATRsd)* multsd 
lobnd=close[1]>nz(lobnd[1])? max(lobndfr,nz(lobnd[1])) :lobndfr
hibnd=close[1]<nz(hibnd[1])? min(hibndfr,nz(hibnd[1])) : hibndfr
trendtr = close> nz(hibnd[1]) ? 1: close< lobnd[1]? -1: nz(trendtr[1],1)
Trender = trendtr==1? lobnd[1]: hibnd[1]
crosscolortr = trendtr==1? green:red
plot(showTrndr?Trender:na, color= crosscolortr , style=cross, linewidth=2,title="Trender for current period")

dcresevol= volume[0]< nz(volume[1]) and volume[0] < nz(volume[2])? true:false
weakbar= dcresevol and close> nz(close[1])?true:false
strongbar= dcresevol and close< nz(close[1])?true:false
// plotchar( weakbar? high:na, title= "weakbar", char= '❄', location= location.abovebar, color= red) //close>supttr and 
// plotchar( strongbar? low:na, title= "strengthbar", char= '❄', location= location.belowbar, color= green) // close>supttr and

emaintra= ema(close, lenei)
sma_emaintra= sma(emaintra, lenei_ema)

emainter= sma(close, lensd)
sma_emainter= sma(emainter, lensd_sma)

emaintrai= ema(close, lene50)
emainterl= sma(close, lens50)
plot ((LWMA and isintraday) ?emaintra:LWMA or THEMA==false?emainter:THEMA?emaintra:na, color= smas20 and emaintra>sma_emaintra?green:smas20 and emaintra<=sma_emaintra?red:
    smas20 and emainter>sma_emainter?green:smas20 and emainter<=sma_emainter?red:na, title="moving avg of closes",linewidth=2)
plot ((LWMA and isintraday) ?sma_emaintra: LWMA or THEMA==false?sma_emainter:THEMA?sma_emaintra:na, color=smas8?fuchsia:na,  title="s moving avg of longer moving avg ")
plot ((LWMA and isintraday)?emaintrai:LWMA?emainterl:na, color= smas50? blue:na,  title="longeest moving avg ")
Home Screener azioni Screener forex Screener cripto Calendario economico Show Come funziona Caratteristiche Grafico Costi Regolamento Moderatori Soluzioni per broker & siti web Widget Librerie grafiche Libreria grafica leggera Centro di supporto Invita un amico Suggerisci funzionalità Blog & Novità FAQ Wiki Twitter
Profilo Impostazioni profilo Account e fatturazione Invita un amico I miei ticket di supporto Centro di supporto Idee pubblicate Follower Seguiti Messaggi Privati Chat Esci