Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=3
- strategy(title="[STRATEGY]Price Action Trading System v0.2 by JustUncleL",overlay = true, shorttitle="[STRATEGY]CCIPAT v0.2 by JustUncleL")
- //Created By: JustUncleL on 3 Aug 2016
- //Version: 0.1
- //
- //Description:
- // Strategy version:
- // This is an implementation of 'Price Action Channel, “The Gold line” Trading System'
- // for Binary Options, originally a scapling system, but without the MA cross "Arrow1".
- // This is a Trend following price action system.
- // To complete the setup instead of the two "Chandelier Stop" indications,
- // I replaced them with a MACD(12,17,8) indicator.
- // This is suitable for 15min charts, with 2 to 4 candle (30min to 60min) expiry.
- //
- // Call Entry:
- // - Green Triangle, confirmed by MACD background green.
- // - CCI Candles aqua.
- // - For best call entry wait for the price retrace back to the gold line,
- // back inside channel also works well.
- //
- // Put Entry:
- // - Red Triangle, confirmed by MACD background red.
- // - CCI Candles black.
- // - For best put entry wait for the price retrace on the gold line,
- // back inside channel also works well.
- //
- //Notes:
- // - will work well on trending patterns only.
- // - works best on the first alert after MACD cross over.
- // - don't take trades when MACD and signal are close together.
- //
- //Modifications:
- // 0.1 : Original version.
- //
- // reference:
- // - Chandelier Stop by pipCharlie (not used in this version)
- // - http://www.forexstrategiesresources.com/scalping-forex-strategies/73-price-action-channel-the-gold-line/
- // - Used some ideas from RSI Candles by glaz
- //
- //
- 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")
- //
- // 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)
- // 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 = 0
- ccidn_alert = 0
- cciup_alert := isup and OutputSignal<0? na(cciup_alert[1]) ? 1 : cciup_alert[1]+1 : 0
- ccidn_alert := isdown and OutputSignal>0? 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)
- // === STRATEGY RELATED INPUTS ===
- //
- // stop loss and target profit
- slPoints = input(defval = 0, title = "Stop Loss Points (zero to disable)", minval = 0)
- tpPoints = input(defval = 0, title = "Target Profit Points (zero for disable)", minval = 0)
- //
- ebar = input(defval = 5000, title="Number of Bars for Back Testing", minval=0)
- dummy = input(false, title="- SET to ZERO for Daily or Longer Timeframes" )
- // Alternative Method to Restrict bars is to use Days since:
- // Calculate how many mars since last bar (only works for timeframes less than 1Day)
- tdays = (timenow-time)/60000.0 // number of minutes since last bar
- tdays := period=='M'? tdays/1440.0/5.0/4.3/interval : period=='W'? tdays/1440.0/5.0/interval : period=='D'? tdays/1440.0/interval : tdays/interval // number of bars since last bar
- //Set up money management parameters
- TP = tpPoints>0?tpPoints:na
- SL = slPoints>0?slPoints:na
- // === STRATEGY - CLOSE ALL IF TOO MANY CANDLES ===
- if (ebar>0 and tdays>ebar)
- strategy.close_all()// ...and when to get out
- // === STRATEGY - LONG AND SHORT POSITION EXECUTION, limit Lookk back to ebars ===
- if (ebar==0 or tdays<=ebar)
- // Long position
- strategy.entry("long", strategy.long, when = cciup_alert==1)
- strategy.close("long", when = isdown)
- strategy.exit("XL", from_entry = "long", profit = TP, loss = SL)
- // Short position
- strategy.entry("short", strategy.short, when = ccidn_alert==1)
- strategy.close("short", when = isup)
- strategy.exit("XS", from_entry = "short", profit = TP, loss = SL)
- //EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement