//version=2
//Name: Price Action Channel Trading System v0.3 by JustUncleL
//Created By: JustUncleL on 3 Aug 2016
//Version: 0.3
//
study(title="Price Action Trading System v0.3 by JustUncleL",overlay = true, shorttitle="CCIPAT v0.3 by JustUncleL")
//
len = input(14, minval=1, title="CCI Length")
lenUpper = input(75, minval=1, title="CCI UpLevel")
lenLower = input(-75, maxval=-1, title="CCI DownLevel")
bars_on = input(true, title="Color CCI Bars")
src = input(close,title="CCI Source")
lenLo = input(5, minval=2, title="Low Channel Length")
lenHi = input(5, minval=2, title="High Channel Length")
lenMe = input(4, minval=1, title="Median Channel Length")
//
fastLength = input(12, minval=1,title="MACD Fast Length")
slowLength=input(17,minval=1,title="MACD Slow Length")
signalLength=input(8,minval=1,title="MACD Signal Length")
//
rsiLen = input(7,minval=2,title="RSI length")
rsiUpper= input(70,minval=50,maxval=100,title="RSI Upper limit")
rsiLower= input(30,maxval=50,minval=0,title="RSI Lower Limit")
//
filterM = input(true,title="Use MACD confilter filter")
filterR = input(true,title="Use RSI confirm filter")
filterE = input(true,title="Use Trend direction filter")
dCandles= input(4,minval=2,title="Direction test Candles")
//
rsiVal = rsi(src,rsiLen)
//
// Calculate MACD and color background
fastMC = ema(src, fastLength)
slowMC = ema(src, slowLength)
macd = fastMC - slowMC
signal = sma(macd, signalLength)
OutputSignal = signal > macd ? 1 : signal < macd ? -1 : 0
bgcolor(OutputSignal>0?red: OutputSignal<0?green:yellow, transp=90)
plot(slowMC,color=blue,transp=0,title="Slow EMA trend line", linewidth=2)

// Calculate and draw the Price Action channel
emaLo = ema(low,lenLo)
emaHi = ema(high,lenHi)
emaMe = ema(hl2,lenMe)
plot(emaLo,title="Low Price Line",style=line,color=gray,transp=0,linewidth=2)
plot(emaHi,title="High Price Line",style=line,color=gray,transp=0,linewidth=2)
plot(emaMe,title="Median Price Line",style=line,color=orange,transp=0,linewidth=2)

// Calculate CCI
cciVal = cci(src, len)

// Calculate CCI indicating continuance of trend.
isup = cciVal > lenUpper
isdown = cciVal < lenLower
barcolor(bars_on ? isup ? aqua : isdown ? black : na : na )

// Check have alert and use MACD filter
cciup_alert = isup and close>open and (not filterR or rsiVal>rsiUpper) and (not filterM or OutputSignal<0) and
(not filterE or (emaMe>slowMC and rising(slowMC,dCandles))) ? na(cciup_alert[1]) ? 1 : cciup_alert[1]+1 : 0
ccidn_alert = isdown and close<open and (not filterR or rsiVal<rsiLower) and (not filterM or OutputSignal>0) and
(not filterE or (emaMe<slowMC and falling(slowMC,dCandles))) ? na(ccidn_alert[1]) ? 1 : ccidn_alert[1]+1 : 0
//
plotshape(cciup_alert==1? cciup_alert : na, title="CCIPAT Up Arrow", style=shape.triangleup,location=location.belowbar, color=olive, transp=0, size=size.small)
plotshape(ccidn_alert==1? ccidn_alert : na, title="CCIPAT Down Arrow", style=shape.triangledown,location=location.abovebar, color=red, transp=0, size=size.small)

// generate an alert if required.
alertcondition(cciup_alert==1 or ccidn_alert==1, title="CCIPAT Alert", message="CCIPAT Alert")

//EOF
Chart Patterns

Thông báo miễn trừ trách nhiệm