Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=3
- study("CM_SlingShotSystem zio", overlay=true)
- sae = input(true, title="Show Aggressive Entry?, Or Use as Alert To Potential Conservative Entry?")
- sce = input(true, title="Show Conservative Entry?")
- st = input(true, title="Show Trend Arrows at Top and Bottom of Screen?")
- def = input(false, title="Only Choose 1 - Either Conservative Entry Arrows or 'B'-'S' Letters")
- pa = input(true, title="Show Conservative Entry Arrows?")
- sl = input(false, title="Show 'B'-'S' Letters?")
- //EMA Definitions
- emaSlow = ema(close, 62)
- emaFast = ema(close, 38)
- //Aggressive Entry or Alert To Potential Trade
- pullbackUpT() => emaFast > emaSlow and close < emaFast
- pullbackDnT() => emaFast < emaSlow and close > emaFast
- //Conservative Entry Code For Highlight Bars
- entryUpT() => emaFast > emaSlow and close[1] < emaFast and close > emaFast
- entryDnT() => emaFast < emaSlow and close[1] > emaFast and close < emaFast
- //Conservative Entry True/False Condition
- entryUpTrend = emaFast > emaSlow and close[1] < emaFast and close > emaFast ? 1 : 0
- entryDnTrend = emaFast < emaSlow and close[1] > emaFast and close < emaFast ? 1 : 0
- //Define Up and Down Trend for Trend Arrows at Top and Bottom of Screen
- upTrend = emaFast >= emaSlow
- downTrend = emaFast < emaSlow
- //Definition for Conseervative Entry Up and Down PlotArrows
- codiff = entryUpTrend == 1 ? entryUpTrend : 0
- codiff2 = entryDnTrend == 1 ? entryDnTrend : 0
- //Color definition for Moving Averages
- col = emaFast > emaSlow ? lime : emaFast < emaSlow ? red : yellow
- //Moving Average Plots and Fill
- p1 = plot(emaSlow, title="Slow MA", style=linebr, linewidth=4, color=col)
- p2 = plot(emaFast, title="Slow MA", style=linebr, linewidth=2, color=col)
- fill(p1, p2, color=silver, transp=50)
- //Aggressive Entry, Conservative Entry Highlight Bars
- barcolor(sae and pullbackUpT() ? yellow : sae and pullbackDnT() ? yellow : na)
- barcolor(sce and entryUpT() ? aqua : sce and entryDnT() ? aqua : na)
- //Trend Triangles at Top and Bottom of Screen
- plotshape(st and upTrend ? upTrend : na, title="Conservative Buy Entry Triangle",style=shape.triangleup, location=location.bottom, color=lime, transp=0, offset=0)
- plotshape(st and downTrend ? downTrend : na, title="Conservative Short Entry Triangle",style=shape.triangledown, location=location.top, color=red, transp=0, offset=0)
- //Plot Arrows OR Letters B and S for Buy Sell Signals
- plotarrow(pa and codiff ? codiff : na, title="Up Entry Arrow", colorup=lime, maxheight=30, minheight=30, transp=0)
- plotarrow(pa and codiff2*-1 ? codiff2*-1 : na, title="Down Entry Arrow", colordown=red, maxheight=30, minheight=30, transp=0)
- plotchar(sl and codiff ? low - tr : na, title="Buy Entry", offset=0, char='B', location=location.absolute, color=lime, transp=0)
- plotchar(sl and codiff2 ? high + tr : na, title="Short Entry", offset=0, char='S', location=location.absolute, color=red, transp=0)
- //
- source = close
- useCurrentRes = input(false, title="Use Current Chart Resolution?")
- resCustom = input(title="Use Different Timeframe? Uncheck Box Above", type=resolution, defval="60")
- smd = input(true, title="Show MacD & Signal Line? Also Turn Off Dots Below")
- sd = input(true, title="Show Dots When MacD Crosses Signal Line?")
- sh = input(true, title="Show Histogram?")
- macd_colorChange = input(true,title="Change MacD Line Color-Signal Line Cross?")
- hist_colorChange = input(true,title="MacD Histogram 4 Colors?")
- res = useCurrentRes ? period : resCustom
- fastLength = input(12, minval=1), slowLength=input(26,minval=1)
- signalLength=input(9,minval=1)
- fastMA = ema(source, fastLength)
- slowMA = ema(source, slowLength)
- macd = fastMA - slowMA
- signal = sma(macd, signalLength)
- hist = macd - signal
- outMacD = security(tickerid, res, macd)
- outSignal = security(tickerid, res, signal)
- outHist = security(tickerid, res, hist)
- histA_IsUp = outHist > outHist[1] and outHist > 0
- histA_IsDown = outHist < outHist[1] and outHist > 0
- histB_IsDown = outHist < outHist[1] and outHist <= 0
- histB_IsUp = outHist > outHist[1] and outHist <= 0
- //MacD Color Definitions
- macd_IsAbove = outMacD >= outSignal
- macd_IsBelow = outMacD < outSignal
- plot_color = hist_colorChange ? histA_IsUp ? aqua : histA_IsDown ? blue : histB_IsDown ? red : histB_IsUp ? maroon :yellow :gray
- macd_color = macd_colorChange ? macd_IsAbove ? lime : red : red
- signal_color = macd_colorChange ? macd_IsAbove ? yellow : yellow : lime
- x=smd and outSignal ? outSignal : na
- circleYPosition = outSignal
- up= x<-10 and sd and crossover(outMacD, outSignal) ? circleYPosition : na
- down=crossunder(emaFast, emaSlow) and x>20
- plotshape(up, title="buy", style=shape.triangleup,location=location.belowbar, color=green, transp=0, size=size.small)
- plotshape(down, title="sell", style=shape.triangledown,location=location.abovebar, color=red, transp=0, size=size.small)
- alertcondition(up, title='buy', message='buy')
- alertcondition(down, title='sell', message='sell')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement