Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. fastMA = input(title="MACD Fast moving average", type = integer, defval = 12, minval = 7)
  2. slowMA = input(title="MACD Slow moving average", type = integer, defval = 26, minval = 7)
  3.  
  4.  
  5. lastColor = yellow
  6. [currMacd,_,_] = macd(close[0], fastMA, slowMA, 9)
  7. [prevMacd,_,_] = macd(close[1], fastMA, slowMA, 9)
  8.  
  9. signalLength=input(9,minval=1, title="MACD Signal Length")
  10. signal = sma(currMacd, signalLength)
  11.  
  12. //alertcondition(currMacd > 0 and prevMacd < 0, title = "Cross Upwards", message = "Macd Upwards")
  13. //alertcondition(currMacd < 0 and prevMacd > 0, title = "Cross Downwards", message = "Macd Downwards")
  14. //alertcondition((currMacd > 0 and currMacd < prevMacd) or (currMacd < 0 and currMacd > prevMacd) , title = "Direction Change", message = "Macd Change")
  15. //alertcondition(currMacd < 0 and ( prevMacd > 0, title = "Cross Downwards", message = "Macd Downwards")
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22. plotColor = currMacd > 0 ? currMacd > prevMacd ? lime : green : currMacd < prevMacd ? maroon : red
  23. //plot(currMacd, style = columns, transp=20, color = plotColor, linewidth = 3)
  24. //plot(0, title = "Zero line", linewidth = 1, color = gray)
  25. //plot(signal, color=white, transp=0, title="Signal")
  26.  
  27. //stoch
  28.  
  29. smoothK = input(3, minval=1, title="Stoch RSI K")
  30. smoothD = input(3, minval=1, title="Stoch RSI D")
  31. lengthRSI = input(7, minval=1, title="Stoch RSI Length")
  32. lengthStoch = input(7, minval=1,title="Stock Length")
  33. src4 = input(close, title="Stoch RSI Source")
  34.  
  35. rsi1 = rsi(src4, lengthRSI)
  36. k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
  37. d = sma(k, smoothD)
  38.  
  39. //plot(k)
  40. //plot(d)
  41.  
  42.  
  43. //RSI
  44. length = input( 14, title="RSI Length" )
  45. overSold = input( 35 , title="RSI Oversold")
  46. overBought = input( 80,title="RSI Overbought" )
  47. price = close
  48.  
  49. vrsi = rsi(price, length)
  50.  
  51. //plot(vrsi)
  52.  
  53. //BB
  54. source = close
  55. bblength = input(20, title= "BB Length", minval=1)
  56. mult = input(2.0, minval=0.001, maxval=50, title="BB Mult")
  57. bbmin = input(0.2, title="BB Min range")
  58. bbmax = input(1.0, title="BB MMax range")
  59.  
  60. basis = sma(source, bblength)
  61. dev = mult * stdev(source, bblength)
  62.  
  63. upper = basis + dev
  64. lower = basis - dev
  65.  
  66. bbpercentage = (close - lower) / (upper - lower)
  67.  
  68. //plot(bbpercentage)
  69.  
  70. volpercentageinc = input(5, title="Volume Percentage Increase") / 100
  71. barssincesignal = input(5, title="Bars Since Signal")
  72.  
  73.  
  74.  
  75. volumeup = volume[0] > volume[1] * (1 + volpercentageinc) and volume[1] > volume[2] * (1 + volpercentageinc)
  76.  
  77.  
  78.  
  79.  
  80. buy = crossover(k,d) and vrsi < overSold and bbpercentage <= bbmin
  81. sell = bbpercentage >= bbmax and crossover(d,k)
  82.  
  83. volupinrange = volumeup and barssince(buy) < barssincesignal
  84.  
  85. //sell = bbpercentage >= bbmax and crossover(d,k)
  86.  
  87. //conditionmet = k >
  88.  
  89. //colorbg =(currMacd < 0) and (slow_percentD > percentD) and(vrsi >= 70) ? red : (currMacd > 0) and (slow_percentD < percentD) and (vrsi <= 30) ? green:na
  90.  
  91. //plotshape(conditionmet, style=shape.arrowup)
  92.  
  93. alertcondition(buy, title = "Conditions Met", message = "Conditions Met")
  94. alertcondition(sell, title = "Sell", message = "Sell")
  95. alertcondition(volupinrange, title = "Buy", message = "Buy")
  96.  
  97.  
  98.  
  99. //colorbg = buy ? green : sell ? red : na
  100. plotshape(buy,style=shape.arrowup, color=black, size = size.huge)
  101. plotshape(sell,style=shape.arrowdown, color=red, size = size.huge)
  102. plotshape(volupinrange,style=shape.arrowup, color=green, size = size.huge)
  103.  
  104. //plotshape(volumeup,style=shape.arrowup, color=orange)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement