daily pastebin goal
11%
SHARE
TWEET

APEX REVERSAL 2.0

memer9161998 May 16th, 2018 (edited) 107 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //@version=2
  2. study("APEX REVERSAL",overlay=true)
  3. //////////
  4. //rsi
  5. src2 = close, len2 = input(2, minval=1, title="Length")
  6. up2 = rma(max(change(src2), 0), len2)
  7. down2 = rma(-min(change(src2), 0), len2)
  8. rsi2 = down2 == 0 ? 100 : up2 == 0 ? 0 : 100 - (100 / (1 + up2 / down2))
  9. //////////////////////////////////////////////////////////////////////
  10. resCustom = input(title="Timeframe", type=resolution, defval="W" )
  11. srcr = close, lenr = input(2, minval=1)
  12. upr = rma(max(change(srcr), 0), lenr)
  13. downr = rma(-min(change(srcr), 0), lenr)
  14. rsi = downr == 0 ? 100 : upr == 0 ? 0 : 100 - (100 / (1 + upr / downr))
  15. src = rsi
  16. mtf=security(tickerid, resCustom, src)
  17. resCustom1 = input(title="Timeframe1 ", type=resolution, defval="W" )
  18. length = input(2)
  19. upperx = highest(length)
  20. lowerx = lowest(length)
  21. outx = 100 * (close - upperx) / (upperx - lowerx)
  22. src1= outx
  23. mtf1=security(tickerid, resCustom1, src1)
  24. //bgcolor(mtf < mtf[7] and mtf1 > mtf1[7] and mtf1 < mtf1[14] ? lime : na, transp=70)
  25. /////////////////////////////////////////////////////////////////////////
  26. srcx = close, lenx = input(7, minval=1, title="Length")
  27. upx = rma(max(change(srcx), 0), lenx)
  28. downx = rma(-min(change(srcx), 0), lenx)
  29. rsix = downx == 0 ? 100 : upx == 0 ? 0 : 100 - (100 / (1 + upx / downx))
  30. v1 = highest(rsix, 100)
  31. v2 = lowest(rsix, 100)
  32. morng= v1 - v2
  33. mopct= morng * .01
  34. mocon= rsix - v2
  35. roval= mocon / mopct
  36. length1x = input(7, minval=1)
  37. src1x = input(close, title="Source")
  38. ma1x = sma(src1x, length1x)
  39. cci = (src1x - ma1x) / (0.015 * dev(src1x, length1x))
  40. z1 = highest(cci, 100)
  41. z2 = lowest(cci, 100)
  42. morng1= z1 - z2
  43. mopct1= morng1 * .01
  44. mocon1= cci - z2
  45. coval= mocon1 / mopct1
  46. lengthw = input(7, minval=1)
  47. upper = highest(lengthw)
  48. lower = lowest(lengthw)
  49. out = 100 * (close - upper) / (upper - lower)
  50. w1 = highest(out, 100)
  51. w2 = lowest(out, 100)
  52. morngw= w1 - w2
  53. mopctw= morngw * .01
  54. moconw= out - w2
  55. woval= moconw / mopctw
  56. ad = cum(close==high and close==low or high==low ? 0 : ((2*close-low-high)/(high-low))*volume)
  57. a1 = highest(ad, 100)
  58. a2 = lowest(ad, 100)
  59. mornga= a1 - a2
  60. mopcta= mornga * .01
  61. mocona= ad - a2
  62. aoval= mocona / mopcta
  63. xyz = roval < 30 and coval < 30 and woval < 30 and aoval < 30
  64.  
  65. ///////////////////////////////////////////////////////////////////////////
  66. maj_qual=input(6),maj_len=input(30)
  67. min_qual=input(5),min_len=input(5)
  68. maj=input(true,title="Show Major")
  69. min=input(true,title="Show Minor")
  70.  
  71. lele(qual,len)=>
  72.     bindex=nz(bindex[1],0)
  73.     sindex=nz(sindex[1],0)
  74.     ret=0
  75.     if (close>close[4])
  76.         bindex:=bindex + 1
  77.     if(close<close[4])
  78.         sindex:=sindex + 1
  79.     if (bindex>qual) and (close<open) and high>=highest(high,len)
  80.         bindex:=0
  81.         ret:=-1
  82.     if ((sindex>qual) and (close>open) and (low<= lowest(low,len)))
  83.         sindex:=0
  84.         ret:=1
  85.     return=ret
  86.  
  87. major=lele(maj_qual,maj_len)
  88. minor=lele(min_qual,min_len)
  89.  
  90. //////////////////////////////////////////////////////////////////////////////
  91. conversionPeriods = input(9, minval=1, title="Conversion Line Periods"),
  92. basePeriods = input(26, minval=1, title="Base Line Periods")
  93. laggingSpan2Periods = input(52, minval=1, title="Lagging Span 2 Periods"),
  94. displacement = input(26, minval=1, title="Displacement")
  95.  
  96. donchian(len) => avg(lowest(len), highest(len))
  97.  
  98. conversionLine = donchian(conversionPeriods)
  99. baseLine = donchian(basePeriods)
  100.  
  101. //second cloud
  102. xconversionPeriods = input(20),
  103. xbasePeriods = input(60)
  104. xlaggingSpan2Periods = input(120),
  105. xdisplacement = input(30)
  106.  
  107. xdonchian(len) => avg(lowest(len), highest(len))
  108.  
  109. xconversionLine = xdonchian(xconversionPeriods)
  110. xbaseLine = xdonchian(xbasePeriods)
  111.  
  112.  
  113.  
  114.  
  115.  
  116. leadLine1 = avg(conversionLine, baseLine)
  117. leadLine2 = donchian(laggingSpan2Periods)
  118.  
  119.  
  120. zlead1= offset(leadLine1,26)
  121. zlead2= offset(leadLine2,26)
  122.  
  123. xlead1= offset(leadLine1, displacement)
  124. xlead2= offset(leadLine2, displacement)
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138. //////////////////////////////////////////////////////////////////////////////
  139. cond1=rsi2 < 1
  140. c1=cond1?1:0
  141.  
  142. cond2=mtf < mtf[7] and mtf1 > mtf1[7] and mtf1 < mtf1[14]
  143. c2=cond2?1:0
  144.  
  145. cond3=roval < 30 and coval < 30 and woval < 30 and aoval < 30
  146. c3=cond3?1:0
  147.  
  148. cond4=(maj and (major==1?low:na)) or (min and (minor==1?low:na))
  149. c4=cond4?1:0
  150.  
  151. cond5=crossover(baseLine,conversionLine)
  152. c5=cond5?1:0
  153.  
  154. //cond6=
  155. //c6=cond6?1:0
  156.  
  157. //cond7=
  158. //c7=cond7?1:0
  159.  
  160. //cond8=
  161. //c8=cond8?1:0
  162.  
  163. //cond9=
  164. //c9=cond9?1:0
  165.  
  166. //cond10=
  167. //c10=cond10?1:0
  168.  
  169. //cond11=
  170. //c11=cond11?1:0
  171.  
  172. //cond12=
  173. //c12=cond12?1:0
  174.  
  175. //cond13=
  176. //c13=cond13?1:0
  177.  
  178. //cond14=
  179. //c14=cond14?1:0
  180.  
  181. //cond15=
  182. //c15=cond15?1:0
  183.  
  184. //cond16=
  185. //c16=cond16?1:0
  186.  
  187. //cond17=
  188. //c17=cond17?1:0
  189.  
  190. //cond18=
  191. //c18=cond18?1:0
  192.  
  193. //cond19=
  194. //c19=cond19?1:0
  195.  
  196. //cond20=
  197. //c20=cond20?1:0
  198.  
  199. sumz=c1+c2+c3+c4-c5//+c6+c7+c8+c9+c10+c11+c12+c13+c14+c15+c16+c17+c18+c19+c20
  200.  
  201. plotchar(sumz==1,char="▲",text='1',location=location.belowbar,color=green,transp=0)
  202. plotchar(sumz==2,char="▲",text='2',location=location.belowbar,color=green,transp=0)
  203. plotchar(sumz==3,char="▲",text='3',location=location.belowbar,color=green,transp=0)
  204. plotchar(sumz==4,char="▲",text='4',location=location.belowbar,color=green,transp=0)
  205. plotchar(sumz==5,char="▲",text='5',location=location.belowbar,color=green,transp=0)
  206. //plotchar(sumz==6,char="▲",text='6',location=location.belowbar,color=green,transp=0)
  207. //plotchar(sumz==7,char="▲",text='7',location=location.belowbar,color=green,transp=0)
  208. //plotchar(sumz==8,char="▲",text='8',location=location.belowbar,color=green,transp=0)
  209. //plotchar(sumz==9,char="▲",text='9',location=location.belowbar,color=green,transp=0)
  210. //plotchar(sumz==10,char="▲",text='10',location=location.belowbar,color=green,transp=0)
  211. //plotchar(sumz==11,char="▲",text='11',location=location.belowbar,color=green,transp=0)
  212. //plotchar(sumz==12,char="▲",text='12',location=location.belowbar,color=green,transp=0)
  213. //plotchar(sumz==13,char="▲",text='13',location=location.belowbar,color=green,transp=0)
  214. //plotchar(sumz==14,char="▲",text='14',location=location.belowbar,color=green,transp=0)
  215. //plotchar(sumz==15,char="▲",text='15',location=location.belowbar,color=green,transp=0)
  216. //plotchar(sumz==16,char="▲",text='16',location=location.belowbar,color=green,transp=0)
  217. //plotchar(sumz==17,char="▲",text='17',location=location.belowbar,color=green,transp=0)
  218. //plotchar(sumz==18,char="▲",text='18',location=location.belowbar,color=green,transp=0)
  219. //plotchar(sumz==19,char="▲",text='19',location=location.belowbar,color=green,transp=0)
  220. //plotchar(sumz==20,char="▲",text='20',location=location.belowbar,color=green,transp=0)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top