Advertisement
Guest User

scalperscript 1min XBTUSD

a guest
Nov 25th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.54 KB | None | 0 0
  1. //@version=3
  2. study("RelStr Multitime, Multistatement V0.95")
  3.  
  4.  
  5.  
  6. // Resolution Setting
  7.  
  8.  
  9. // Inputs for alternate resolutions. tp_res_custom1 for High / Low sources and tp_res_custom2 for Mixed source.
  10. rtprice = input(title="realtime price source", defval = hl2)
  11. tp_res_custom1 = input(title="High TP and Low TP Source Resolution", type=string, defval="2")
  12. tp_res_custom2 = input(title="Mixed TP Source Resolution", type=string, defval="15")
  13. tp_res_custom3 = input(title="Fractal Timeframe", type=string, defval="30")
  14. //res_pri = primary_pricet
  15. res_tp1 = tp_res_custom1
  16. res_tp2 = tp_res_custom2
  17. res_fract = tp_res_custom3
  18.  
  19.  
  20. // TP Delta-V Sources
  21. //primary_price_src = input(defval = hlc3, title = 'Primary Source')
  22. tp_pricesrc1 = input(defval = high, title = 'High TP Source')
  23. tp_pricesrc2 = input(defval = low, title = 'Low TP Source')
  24. tp_pricesrc3 = input(defval = hl2, title = 'Mixed TP Source')
  25. tp_pricesrc4 = input(defval = open, title = 'Open Price')
  26. tp_pricesrc5 = input(defval = close, title = 'Closed Price')
  27. // src3 Also used for Volume
  28.  
  29.  
  30. // TP Delta-V Sources for selected 'Take-Profit Resolution'
  31. //src_primary1 = security(tickerid, res_pri , tp_pricesrc1)
  32. tp_src0 = security(tickerid, res_tp1 , tp_pricesrc3)
  33. tp_src1 = security(tickerid, res_tp1 , tp_pricesrc1)
  34. tp_src2 = security(tickerid, res_tp1 , tp_pricesrc2)
  35. tp_src3 = security(tickerid, res_tp2 , tp_pricesrc3)
  36.  
  37. fr_src_O = security(tickerid, res_fract , tp_pricesrc4)
  38. fr_src_H = security(tickerid, res_fract , tp_pricesrc1)
  39. fr_src_L = security(tickerid, res_fract , tp_pricesrc2)
  40. fr_src_C = security(tickerid, res_fract , tp_pricesrc5)
  41.  
  42. //Volume for Selected Resolution
  43.  
  44. tpvolume1= security(tickerid, res_tp1 , volume)
  45. tpvolume2= security(tickerid, res_tp2 , volume)
  46.  
  47.  
  48. //SHORT 'ZIPPY' SOURCES
  49.  
  50. short_rsalm_1 = input (13, title = 'SHORT_HI_LO STRENGTH')
  51. //
  52. short_almawin_1 = input (9, title = ' SHORT ALMA window/2')
  53. short_almaoffset_1 = input (0.85, title = 'SHORT ALMA offset ', step=0.05)
  54. short_almawindow_1 = input (6, title = 'SHORT ALMA sigma')
  55. //
  56. short_barschange_1 = input (7, title = 'SHORT bars of change High')
  57. short_barschange_2 = input (7, title = 'SHORT bars of change Low')
  58. //
  59. short_tphimax = input (5.5, title = 'SHORTtphi max change', step=0.5)
  60. short_tphimin = input (-5.5, title = 'SHORTtphi min change', step=0.5)
  61. //
  62. //END
  63.  
  64.  
  65. // LONG SOURCES
  66. rsalm_1 = input (20, title = 'STRENGTH')
  67. rsalm_2 = input (14, title = 'Hi_LOW STRENGTH')
  68. //
  69. almawin_1 = input (135, title = ' ALMA window')
  70. //
  71. //
  72. almawin_2 = input (20, title = ' ALMA window for HI_LO') // <THIS SHITS IMPORTANT!
  73. //
  74. //
  75. almaoffset_1 = input (1.15, title = ' ALMA offset ', step=0.05)
  76. almawindow_1 = input (20, title = 'ALMA sigma')
  77. //
  78. barschange_1 = input (105, title = ' bars of change MixTP')
  79. barschange_2 = input (7, title = ' bars of change High Low')
  80. //
  81. tphimax = input (3.5, title = 'tphi max change', step=0.5)
  82. tphimin = input (-3.5, title = 'tphi min change', step=0.5)
  83. //
  84. rsmovethresh = input (40, title = 'TP HI_LO change threshold')
  85. //
  86. ifchangeamnt = input (20, title = 'TP HI_LO change Bars for Threshold Meet')
  87. //
  88. //
  89. //Fractal MA and TSI of Fractal MA inputs
  90.  
  91. //Fract Input sources
  92. FractInputSrc = input (1)
  93. //
  94. f1_len = input(defval=16,minval=1, title = 'Fractal MA Length' )
  95. f1_FC = input(defval=1,minval=1, title = 'Fractal MA f1_FC' )
  96. f1_SC = input(defval=198,minval=1, title = 'Fractal MA f1_SC')
  97. //
  98. f2_len = input(defval=16,minval=1, title = 'Fractal MA Length' )
  99. f2_FC = input(defval=1,minval=1, title = 'Fractal MA f1_FC' )
  100. f2_SC = input(defval=198,minval=1, title = 'Fractal MA f1_SC')
  101. //
  102. len = input(defval=16,minval=1, title = 'long Fractal MA Length' )
  103. FC = input(defval=1,minval=1, title = 'long Fractal MA FC' )
  104. SC = input(defval=198,minval=1, title = 'long Fractal MA SC')
  105. //
  106. //
  107. fractsi_short = input (7, title = 'Fractal TSI Short Length')
  108. fractsi_long = input (41, title = 'Fractal TSI Long Length')
  109. // and Mult *
  110. fractsimult = input (defval=21, title = 'Fractal TSI Multiplier')
  111. centerprice_mult = input (defval = 12.5, step = 0.5, title = ' Price Action Mult')
  112.  
  113. roc_length = input(20, title = 'roc_barsback')
  114. prcminmax = input(.012, title = "Precentage Up Down for trigger from last", step = 0.001 )
  115. tuneoffset = input(0.694, title = 'multX', step = .001)
  116.  
  117. //
  118.  
  119. // END INPUTS
  120. price = fr_src_L
  121. len1 = f1_len/2
  122. w = log(2/(f1_SC+1))
  123. H1 = highest(fr_src_H,len1)
  124. L1 = lowest(fr_src_L,len1)
  125. N1 = (H1-L1)/len1
  126. H2 = highest(fr_src_H,f1_len)[len1]
  127. L2 = lowest(fr_src_L,f1_len)[len1]
  128. N2 = (H2-L2)/len1
  129. H3 = highest(fr_src_H,f1_len)
  130. L3 = lowest(fr_src_L,f1_len)
  131. N3 = (H3-L3)/f1_len
  132. dimen1 = (log(N1+N2)-log(N3))/log(2)
  133. dimen = iff(N1>0 and N2>0 and N3>0,dimen1,nz(dimen1[1]))
  134. alpha1 = exp(w*(dimen-1))
  135. oldalpha = alpha1>1?1:(alpha1<0.01?0.01:alpha1)
  136. oldN = (2-oldalpha)/oldalpha
  137. N = (((f1_SC-f1_FC)*(oldN-1))/(f1_SC-1))+f1_FC
  138. alpha_ = 2/(N+1)
  139. alpha = alpha_<2/(f1_SC+1)?2/(f1_SC+1):(alpha_>1?1:alpha_)
  140. out = na
  141. out := (1-alpha)*nz(out[1]) + alpha*price
  142.  
  143. lowfract = out
  144.  
  145.  
  146.  
  147.  
  148. //(longfract[7] > shortprice_upper) ? 30 : (longfract[7] < shortprice_lower) ? -30 : 0
  149.  
  150. ///
  151. f1_price = fr_src_H
  152. f1_len1 = f1_len/2
  153. f1_w = log(2/(f1_SC+1))
  154. f1_H1 = highest(fr_src_H,f1_len1)
  155. f1_L1 = lowest(fr_src_L,f1_len1)
  156. f1_N1 = (f1_H1-f1_L1)/f1_len1
  157. f1_H2 = highest(fr_src_H,f1_len)[f1_len1]
  158. f1_L2 = lowest(fr_src_L,f1_len)[f1_len1]
  159. f1_N2 = (f1_H2-f1_L2)/f1_len1
  160. f1_H3 = highest(fr_src_H,f1_len)
  161. f1_L3 = lowest(fr_src_L,f1_len)
  162. f1_N3 = (f1_H3-f1_L3)/f1_len
  163. f1_dimen1 = (log(f1_N1+f1_N2)-log(f1_N3))/log(2)
  164. f1_dimen = iff(f1_N1>0 and f1_N2>0 and f1_N3>0,f1_dimen1,nz(f1_dimen1[1]))
  165. f1_alpha1 = exp(f1_w*(f1_dimen-1))
  166. f1_oldalpha = f1_alpha1>1?1:(f1_alpha1<0.01?0.01:f1_alpha1)
  167. f1_oldN = (2-f1_oldalpha)/f1_oldalpha
  168. f1_N = (((f1_SC-f1_FC)*(f1_oldN-1))/(f1_SC-1))+f1_FC
  169. f1_alpha_ = 2/(f1_N+1)
  170. f1_alpha = f1_alpha_<2/(f1_SC+1)?2/(f1_SC+1):(f1_alpha_>1?1:f1_alpha_)
  171. f1_out = na
  172. f1_out := (1-f1_alpha)*nz(f1_out[1]) + f1_alpha*f1_price
  173.  
  174. highfract = (f1_out)
  175. fratsi = ((tsi(f1_out, fractsi_short, fractsi_long))*fractsimult)
  176.  
  177. //
  178.  
  179. f2_price = input(hl2)
  180. f2_len1 = f2_len/2
  181. f2_w = log(2/(f2_SC+1))
  182. f2_H1 = highest(high,f2_len1)
  183. f2_L1 = lowest(low,f2_len1)
  184. f2_N1 = (f2_H1-f2_L1)/f2_len1
  185. f2_H2 = highest(high,f2_len)[f2_len1]
  186. f2_L2 = lowest(low,f2_len)[f2_len1]
  187. f2_N2 = (f2_H2-f2_L2)/f2_len1
  188. f2_H3 = highest(high,f2_len)
  189. f2_L3 = lowest(low,f2_len)
  190. f2_N3 = (f2_H3-f2_L3)/f2_len
  191. f2_dimen1 = (log(f2_N1+f2_N2)-log(f2_N3))/log(2)
  192. f2_dimen = iff(f2_N1>0 and f2_N2>0 and f2_N3>0,f2_dimen1,nz(f2_dimen1[1]))
  193. f2_alpha1 = exp(f2_w*(f2_dimen-1))
  194. f2_oldalpha = f2_alpha1>1?1:(f2_alpha1<0.01?0.01:f2_alpha1)
  195. f2_oldN = (2-f2_oldalpha)/f2_oldalpha
  196. f2_N = (((f2_SC-f2_FC)*(f2_oldN-1))/(f2_SC-1))+f2_FC
  197. f2_alpha_ = 2/(f2_N+1)
  198. f2_alpha = f2_alpha_<2/(f2_SC+1)?2/(f2_SC+1):(f2_alpha_>1?1:f2_alpha_)
  199. f2_out = na
  200. f2_out := (1-f2_alpha)*nz(f2_out[1]) + f2_alpha*f2_price
  201.  
  202. realtimefract = f2_out
  203.  
  204. fractdeviation = realtimefract - ((lowfract+highfract)/2)
  205. pricerangeprecent = alma(ema((((lowfract/highfract)-1)*500),26),9,0.85,6)
  206. pricerangeprecentl = alma(ema((((highfract/lowfract)-1)*500),26),9,0.85,6)
  207.  
  208.  
  209.  
  210. /// Reversal Zone
  211. //
  212. //
  213. //highs
  214. rzh1 = (sma(close,3) > highfract) ? (sma(close,3) - highfract) : 0
  215.  
  216. rzh2 = (realtimefract > highfract) ? (realtimefract - highfract) : 0
  217.  
  218. rzh3 = (sma(close,3) > realtimefract) ? (sma(close,3) - realtimefract) : 0
  219.  
  220. //
  221. //
  222. //lows
  223. rzl1 = (sma(close,3) < lowfract) ? (sma(close,3) - lowfract) : 0
  224.  
  225. rzl2 = (realtimefract < lowfract) ? (realtimefract - lowfract) : 0
  226.  
  227. rzl3 = (sma(close,3) < realtimefract) ? (sma(close,3) - realtimefract) : 0
  228.  
  229.  
  230.  
  231.  
  232. ///
  233. ///
  234. ///
  235. ///
  236.  
  237.  
  238. //Mixed Signal on longer TF
  239. mixed_tp_singal = change(alma((rsi(tp_src3,(rsalm_1*2))),almawin_1,almaoffset_1,almawindow_1),barschange_1)
  240.  
  241. // Long Zippy Args
  242. //
  243. //LongHigh
  244. RelStr_tphi = max((change(alma((rsi(tp_src1,(rsalm_2*2))),almawin_2,almaoffset_1,almawindow_1),(barschange_2))),tphimax)
  245. //
  246. //RelStrMove_tphi = if(change(RelStr_tphi,ifchangeamnt))>(rsmovethresh/10)
  247. // 4
  248. //else
  249. // 0
  250.  
  251. //
  252. //LongLow
  253. RelStr_tplo = min((change(alma((rsi(tp_src2,(rsalm_2*2))),almawin_2,almaoffset_1,almawindow_1),(barschange_2))),tphimin)
  254.  
  255.  
  256.  
  257.  
  258. // Short Zippy Args
  259. //
  260. //ShortHigh
  261. short_RelStr_tphi = max((change(alma((rsi(tp_src1,((short_rsalm_1)))),(short_almawin_1)/2,short_almaoffset_1,short_almawindow_1),(short_barschange_1))),short_tphimax)
  262. //
  263. //Shortlow
  264. short_RelStr_tplo = min((change(alma((rsi(tp_src2,((short_rsalm_1)))),(short_almawin_1)/2,short_almaoffset_1,short_almawindow_1),(short_barschange_2))),short_tphimin)
  265. //
  266. //Order Placement Logic, revision 0.1
  267. //
  268.  
  269.  
  270. /////////////////// ALOT OF WORK TO DO HERE WITH ROC's N SHIT
  271. //scalplonga = if ((roc(short_RelStr_tphi,6)) > roc(short_tphimax,6)) and (roc(RelStr_tphi,6)) > roc(short_tphimax,6) //and (fractdeviation>fractdeviation[1])
  272.  
  273. scalplonga = if (short_RelStr_tphi>short_tphimax) and (RelStr_tphi > tphimax) //and (fractdeviation>fractdeviation[1])
  274.  
  275. 40
  276. else
  277. 0
  278.  
  279. //scalpshorta = if ((roc(short_RelStr_tplo,6))< roc(short_tphimin,6)) and (roc(RelStr_tplo,6)) < roc(tphimin,6) //and (fractdeviation<fractdeviation[1])
  280. scalpshorta = if (short_RelStr_tplo<short_tphimin) and (RelStr_tplo < tphimin) //and (fractdeviation<fractdeviation[1])
  281. -40
  282. else
  283. 0
  284.  
  285.  
  286.  
  287. trnkscalplong = scalplonga
  288. trnkscalpshort = scalpshorta
  289.  
  290. pricedirection = if ((valuewhen(trnkscalpshort,(hl2), 2))) > ((valuewhen(trnkscalplong,(hl2*(1+(prcminmax*tuneoffset))), 2)) + (valuewhen(trnkscalplong,(hl2*(1+(-1*prcminmax))), 2)) / 2)
  291. scalpshorta
  292. else
  293. scalplonga
  294.  
  295. ma1 = if(change(scalplonga,1)>0)
  296. 40
  297. else
  298. 0
  299.  
  300. ma2 = if(change(scalpshorta,1)<0)
  301. -40
  302. else
  303. 0
  304.  
  305.  
  306.  
  307.  
  308.  
  309. ////
  310. ////
  311. ////
  312. ////
  313.  
  314. //isTP =
  315. //tp = input(0, "Take Profit") / qty
  316. //long_tp = isTP and crossover(high, last_open_longCondition + tp) and longCondition == 0
  317. //short_tp = isTP and crossunder(low, last_open_shortCondition - tp) and shortCondition == 0
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325. //plot (rtprice, title = 'price', color = blue)
  326. //plot (mixed_tp_singal, title = "TP Mixed" , color = blue )
  327. //plot (RelStr_tphi, title = "TP Hi" , color = purple)
  328. //plot (RelStr_tplo, title = "TP Low" , color = red)
  329. //plot (short_RelStr_tphi, title = "Short TP Hi" , color = green)
  330. //plot (short_RelStr_tplo, title = "Short TP Low" , color = red)
  331. //plot (fratsi, title = "fractal tsi" , color = orange)
  332. //plot (lowfract, title = "lowfract" , color = purple)
  333. //plot (highfract, title = "highfract" , color = purple)
  334. //plot (realtimefract, title = "realtimefract" , color = purple)
  335. //plot (ishighfract, title = ' ishighfract ' , color = purple)
  336. //plot (scalpshorta, title = 'scalplong' , color = green, style = line, linewidth = 1 )
  337. //plot (scalplonga, title = 'scalpshort' , color = purple, style = line, linewidth = 1 )
  338. //plot (ma1, title = 'longblip' , color = ma2 < 0 ? green : na, style = cross, linewidth = 4)
  339. //plot (ma2, title = 'shortblip' , color = ma1 > 0 ? red : na, style = cross, linewidth = 4 )
  340. //plot (scalplongz, title = 'scalplongz' , color = black, style = line, linewidth = 1 )
  341. //plot (scalpshortz, title = 'scalpshortz' , color = blue, style = line, linewidth = 1 )
  342. //plot (fractdeviation, title = ' fractdeviation ' , color = red)
  343. //plot (pricerangeprecentl, title = "pricerangeprecent" , color = purple)
  344. //plot (pricerangeprecent, title = "pricerangeprecent" , color = purple)
  345. plot (rzh1, title = "rzh1" , color = purple)
  346. plot (rzh2, title = "rzh2" , color = red)
  347. plot (rzh3, title = "rzh3" , color = blue)
  348. plot (rzl1, title = "rzh1" , color = purple)
  349. plot (rzl2, title = "rzh2" , color = red)
  350. plot (rzl3, title = "rzh3" , color = blue)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement