Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.94 KB | None | 0 0
  1. study(title="SCMR V3", precision=0, overlay = true)
  2. HC = input(defval=false, title="-----> High Contrast. Automatic Dark Background")
  3. showPT=input(true, title="Show Pivots Text", type=bool)
  4. showRev=input(true, title="Show Confirmed Upside Reversals Text", type=bool)
  5. showDet=input(true, title="Show Early Detection", type=bool)
  6.  
  7.  
  8. //Declare General Trend
  9.  
  10. TL1(src, len) =>
  11. weight = 3.5 / (len + 1)
  12. sum = nz(sum[1]) - nz(src[len]) + src
  13. ma = na(src[len]) ? na : sum/len
  14. out = na(out[1]) ? ma : (src - out[1]) * weight + out[1]
  15. out
  16. TL(src, len) =>
  17. weight = 2 / (len + 1)
  18. sum = nz(sum[1]) - nz(src[len]) + src
  19. ma = na(src[len]) ? na : sum/len
  20. out = na(out[1]) ? ma : (src - out[1]) * weight + out[1]
  21. out
  22.  
  23. TL3 = TL(low,16) - TL1(low,16)
  24. TL4 = percentrank(TL3, 8)
  25. TL5 = (TL3 < 0 and TL4 > 75) ? 1 : 0
  26.  
  27. //////
  28.  
  29. TH1(src, len) =>
  30. weight = 3.5 / (len + 1)
  31. sum = nz(sum[1]) - nz(src[len]) + src
  32. ma = na(src[len]) ? na : sum/len
  33. out = na(out[1]) ? ma : (src - out[1]) * weight + out[1]
  34. out
  35. TH(src, len) =>
  36. weight = 2 / (len + 1)
  37. sum = nz(sum[1]) - nz(src[len]) + src
  38. ma = na(src[len]) ? na : sum/len
  39. out = na(out[1]) ? ma : (src - out[1]) * weight + out[1]
  40. out
  41.  
  42. TH3 = TH1(high,16) - TH(high,16)
  43. TH4 = percentrank(TH3, 8)
  44. TH5 = (TH3 > 0 and TH4 < 25) ? 1 : 0
  45.  
  46. //Bar Offsets
  47. offset1 = low - (low * .9998)
  48. h = iff(TH5, TH(high,16), TH1(high,16))
  49. o1 = offset(h,1)
  50. o2 = offset(h,2)
  51. o3 = offset(h,3)
  52. o4 = offset(h,4)
  53. l = iff(TL5, TL(low,16), TL1(low,16))
  54. i1 = offset(l,1)
  55. i2 = offset(l,2)
  56. i3 = offset(l,3)
  57. i4 = offset(l,4)
  58. i5 = offset(l,5)
  59. //min lows
  60. ll1 = lowest(low,2)
  61. ll2 = lowest(low,3)
  62. // Offset
  63. Minl = offset(ll1, 1)
  64. Minla = offset(ll1, 2)
  65. Minl2 = offset(ll2,1)
  66. //max highs
  67. hh1 = highest(high,2)
  68. hh2 = highest(high,3)
  69. // Offset
  70. Maxh = offset(hh1, 1)
  71. Maxh2 = offset(hh2,1)
  72. Maxh3 = offset(hh2,2)
  73.  
  74. //Decisions
  75. //isIntra() => dayofweek > dayofweek(1) and change(dayofweek(1) = dayofweek(1,1)
  76. isBO() => title = "Price Breakout", close[3] < i3 and close[2] < i2 and close[1] < i1 and close > h
  77. isBD() => title = "Price Breakdown", close[3] > o3 and close[2] > o2 and close[1] > o1 and close < l
  78. isUR() => title = "Price Pivot, Downside warning", close[2] > o2 and close < close[1] and close < h and close > Minl2 and close < open and close < low[1]
  79. isBOn() => title = "Price Broke Out, no followthrough, treat as pivot", (close[4] < i4 and close[3] < i3 and close[2] < i2 and close[1] > o1 and close > Minl and close < high[1]) or (close[5] < i5 and close[4] < i4 and close[3] < i3 and close[2] > o2 and close < h and close[1] > Minla and close > Minl and close < high[1] and open > close)
  80. isUCRU() => title = "Price UNconfirmed Reversal Up", close[1] < i1 and close > l and close < h and close > open
  81. isUNCRD() => title = "Price Pivot, Downside Bias", (close[2] > i2 and low[1] < i1 and close[1] < i1 and high < high[1] and close < l and low > low[1] and close > close[1]) or (low[2] > i2 and low[1] < i1 and close[1] > i1 and close > low[1] and close < l) or (close[2] > i2 and close[1] < i2 and low[1] > low[2] and (close > low[1] or close > low[2]) and low > low[2] and close < l)
  82. isP() => title = "Price Pivot", (close[1] < o1 and close[2] > i2 and low[1] < i1 and close[1] > i1 and high < high[1] and high > l and (close < l or close < close[1]) and close > low[1] and open < close) or (close[4] > o4 and close[3] < i3 and close[1] > o1 and close > h and close[1] < Maxh3 and open > close and close > low[1])
  83. // isP2
  84. is5HR() => title = "Price 5 Bar High, then reversal, 1-3 bar downside bias", high > (Maxh2 + .01) and close < open and close[1] > o1 and close[1] > open[1] and close > l
  85. isUW() => title = "Price in WEAK Uptrend", (close[1] < o1 and close > TH(high, 16) and close < high[1])
  86. isUp() => title = "Price in Uptrend", close > TH(high,16)
  87. isDown() => title = "Price in Downtrend", close < TL(low, 16)
  88. isN() => title = "Price is Neutral, no definable sequence", (close > TL(low, 16) and close < TH(high, 16)) or close > TH(high,16) and close[1] < TL(low,16)
  89.  
  90. //Plot BarColor
  91. barcolor(isBO() ? yellow : isBD() ? purple : isUR() ? orange : isBOn() ? olive : isUCRU() ? #0066FF : isUNCRD() ? #FF00FF : isP() ? #FF00FF : is5HR() ? #758A0A : isUW() ? green : isUp() ? lime : isDown() ? red : isN() ? #9FB4B4 : na)
  92.  
  93.  
  94. //Condition Offsets
  95. Piv = isUR() or isBOn() or isP() or isUNCRD()
  96. RevUp = (offset(isUCRU(), 1) and close > high[1]) or
  97. (offset(isUCRU(), 2) and close[1] <= high[2] and close[1] > low[1] and low[1] > Minl2 and close > high[2])
  98. RevX = (((offset(isUCRU(), 2) and close[1] > high[2] and close < open and (high < high[1] or close < high[2])) or
  99. (offset(isUCRU(), 3) and close[2] > high[3] and close[1] > high[3] and close[1] > lowest(low,3) and low[2] > low[4] and (open > close and low < open[2] and low < open[3])) or
  100. (offset(isUCRU(), 3) and close[2] <= high[3] and close[1] > high[3] and close[1] > lowest(low,3) and low[2] > low[4])) and (high <= high[1] or (open > close and low < max(open[2], close[2]))))
  101.  
  102. RevX1 = offset(RevX, 1)
  103. RevX2 = offset(RevX, 2)
  104. RevX3 = ((close[5] > i5 and close[4] < i4 and close[3] > i3) and offset(isUCRU(), 3) and close[2] > high[3] and close[1] < open[1] and (high[1] < high[2] or close[1] < high[3] or low < high[3]))
  105. RevXX = (RevX1 or RevX2 or RevX3) and (close > high[2] and close > high[3])
  106.  
  107. //Define Warning
  108. Early = abs((close[3] > open[3] and close[2] > open[2] and close[1] > open[1] and close < open) or
  109. (close[3] > open[3] and close[2] > open[2] and close[1] < open[1] and close > open) or
  110. (close[3] > open[3] and close[2] < open[2] and close[1] > open[1] and close > open) or
  111. (close[3] < open[3] and close[2] > open[2] and close[1] > open[1] and close > open) or
  112. (close[3] > open[3] and close[2] > open[2] and close[1] > open[1] and close > open))*(low*.9999525)
  113.  
  114. EarlyD = abs((close[3] < open[3] and close[2] < open[2] and close[1] < open[1] and close > open) or
  115. (close[3] < open[3] and close[2] < open[2] and close[1] > open[1] and close < open) or
  116. (close[3] < open[3] and close[2] > open[2] and close[1] < open[1] and close < open) or
  117. (close[3] > open[3] and close[2] < open[2] and close[1] < open[1] and close < open) or
  118. (close[3] < open[3] and close[2] < open[2] and close[1] < open[1] and close < open))*(high*1.00009525)
  119.  
  120. EarlyTd = abs(close > TL(low, 16) and close < l)*(low*.9999525)
  121. EarlyTu = abs(close < TH(high, 16) and close > h)*(high*1.00009525)
  122.  
  123.  
  124. //Plot Background
  125. bgcolor(HC ? #1A1A1A : na)
  126.  
  127. //CharacterText
  128.  
  129. plotchar(showPT and close > open ? Piv : na, char='P', location=location.belowbar, color=blue)
  130. plotchar(showPT and close < open ? Piv : na, char='P', location=location.abovebar, color=blue)
  131.  
  132. plotchar(showRev ? RevUp : na, char='L', location=location.belowbar, color=blue)
  133. plotchar(showRev ? RevX : na, char='X', location=location.abovebar, color=red)
  134. plotchar(showRev ? RevXX : na, char='Z', location=location.belowbar, color=green)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement