Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.85 KB | None | 0 0
  1. //@version=3
  2.  
  3. study("CM_SlingShotSystem zio", overlay=true)
  4. sae = input(true, title="Show Aggressive Entry?, Or Use as Alert To Potential Conservative Entry?")
  5. sce = input(true, title="Show Conservative Entry?")
  6. st = input(true, title="Show Trend Arrows at Top and Bottom of Screen?")
  7. def = input(false, title="Only Choose 1 - Either Conservative Entry Arrows or 'B'-'S' Letters")
  8. pa = input(true, title="Show Conservative Entry Arrows?")
  9. sl = input(false, title="Show 'B'-'S' Letters?")
  10.  
  11. //EMA Definitions
  12. emaSlow = ema(close, 62)
  13. emaFast = ema(close, 38)
  14. //Aggressive Entry or Alert To Potential Trade
  15. pullbackUpT() => emaFast > emaSlow and close < emaFast
  16. pullbackDnT() => emaFast < emaSlow and close > emaFast
  17. //Conservative Entry Code For Highlight Bars
  18. entryUpT() => emaFast > emaSlow and close[1] < emaFast and close > emaFast
  19. entryDnT() => emaFast < emaSlow and close[1] > emaFast and close < emaFast
  20. //Conservative Entry True/False Condition
  21. entryUpTrend = emaFast > emaSlow and close[1] < emaFast and close > emaFast ? 1 : 0
  22. entryDnTrend = emaFast < emaSlow and close[1] > emaFast and close < emaFast ? 1 : 0
  23. //Define Up and Down Trend for Trend Arrows at Top and Bottom of Screen
  24. upTrend = emaFast >= emaSlow
  25. downTrend = emaFast < emaSlow
  26. //Definition for Conseervative Entry Up and Down PlotArrows
  27. codiff = entryUpTrend == 1 ? entryUpTrend : 0
  28. codiff2 = entryDnTrend == 1 ? entryDnTrend : 0
  29. //Color definition for Moving Averages
  30. col = emaFast > emaSlow ? lime : emaFast < emaSlow ? red : yellow
  31. //Moving Average Plots and Fill
  32. p1 = plot(emaSlow, title="Slow MA", style=linebr, linewidth=4, color=col)
  33. p2 = plot(emaFast, title="Slow MA", style=linebr, linewidth=2, color=col)
  34. fill(p1, p2, color=silver, transp=50)
  35. //Aggressive Entry, Conservative Entry Highlight Bars
  36. barcolor(sae and pullbackUpT() ? yellow : sae and pullbackDnT() ? yellow : na)
  37. barcolor(sce and entryUpT() ? aqua : sce and entryDnT() ? aqua : na)
  38. //Trend Triangles at Top and Bottom of Screen
  39. plotshape(st and upTrend ? upTrend : na, title="Conservative Buy Entry Triangle",style=shape.triangleup, location=location.bottom, color=lime, transp=0, offset=0)
  40. plotshape(st and downTrend ? downTrend : na, title="Conservative Short Entry Triangle",style=shape.triangledown, location=location.top, color=red, transp=0, offset=0)
  41. //Plot Arrows OR Letters B and S for Buy Sell Signals
  42. plotarrow(pa and codiff ? codiff : na, title="Up Entry Arrow", colorup=lime, maxheight=30, minheight=30, transp=0)
  43. plotarrow(pa and codiff2*-1 ? codiff2*-1 : na, title="Down Entry Arrow", colordown=red, maxheight=30, minheight=30, transp=0)
  44. plotchar(sl and codiff ? low - tr : na, title="Buy Entry", offset=0, char='B', location=location.absolute, color=lime, transp=0)
  45. plotchar(sl and codiff2 ? high + tr : na, title="Short Entry", offset=0, char='S', location=location.absolute, color=red, transp=0)
  46. //
  47. source = close
  48. useCurrentRes = input(false, title="Use Current Chart Resolution?")
  49. resCustom = input(title="Use Different Timeframe? Uncheck Box Above", type=resolution, defval="60")
  50. smd = input(true, title="Show MacD & Signal Line? Also Turn Off Dots Below")
  51. sd = input(true, title="Show Dots When MacD Crosses Signal Line?")
  52. sh = input(true, title="Show Histogram?")
  53. macd_colorChange = input(true,title="Change MacD Line Color-Signal Line Cross?")
  54. hist_colorChange = input(true,title="MacD Histogram 4 Colors?")
  55.  
  56. res = useCurrentRes ? period : resCustom
  57.  
  58. fastLength = input(12, minval=1), slowLength=input(26,minval=1)
  59. signalLength=input(9,minval=1)
  60.  
  61. fastMA = ema(source, fastLength)
  62. slowMA = ema(source, slowLength)
  63.  
  64. macd = fastMA - slowMA
  65. signal = sma(macd, signalLength)
  66. hist = macd - signal
  67.  
  68. outMacD = security(tickerid, res, macd)
  69. outSignal = security(tickerid, res, signal)
  70. outHist = security(tickerid, res, hist)
  71.  
  72. histA_IsUp = outHist > outHist[1] and outHist > 0
  73. histA_IsDown = outHist < outHist[1] and outHist > 0
  74. histB_IsDown = outHist < outHist[1] and outHist <= 0
  75. histB_IsUp = outHist > outHist[1] and outHist <= 0
  76.  
  77. //MacD Color Definitions
  78. macd_IsAbove = outMacD >= outSignal
  79. macd_IsBelow = outMacD < outSignal
  80.  
  81. plot_color = hist_colorChange ? histA_IsUp ? aqua : histA_IsDown ? blue : histB_IsDown ? red : histB_IsUp ? maroon :yellow :gray
  82. macd_color = macd_colorChange ? macd_IsAbove ? lime : red : red
  83. signal_color = macd_colorChange ? macd_IsAbove ? yellow : yellow : lime
  84. x=smd and outSignal ? outSignal : na
  85. circleYPosition = outSignal
  86. up= x<-10 and sd and crossover(outMacD, outSignal) ? circleYPosition : na
  87. down=crossunder(emaFast, emaSlow) and x>20
  88. plotshape(up, title="buy", style=shape.triangleup,location=location.belowbar, color=green, transp=0, size=size.small)
  89. plotshape(down, title="sell", style=shape.triangledown,location=location.abovebar, color=red, transp=0, size=size.small)
  90. alertcondition(up, title='buy', message='buy')
  91. alertcondition(down, title='sell', message='sell')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement