Advertisement
danucante

Untitled

Nov 9th, 2023
186
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.86 KB | None | 0 0
  1. //@version=5
  2. strategy("the list of all indicators for strats", overlay=true, pyramiding = 0, slippage = 1, initial_capital = 100, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)
  3.  
  4.  
  5.  
  6.  
  7. //////////////////////////////////////////////////////////////////////////Main indicators////////////////////////////////////////////////////////////////////////
  8.  
  9.  
  10. //STC
  11. timeframe=input.timeframe(defval ='1D')
  12. EEEEEE = input.int(defval = 13, step = 1, title = "STC Length", group = "STC")
  13. BBBB = input.int(defval = 31, step = 1, title = "STC Fast Length", group = "STC")
  14. BBBBB = input.int(defval = 70, step = 1, title = "STC Slow Length", group = "STC")
  15.  
  16. AAAA(BBB, BBBB, BBBBB) =>
  17. fastMA = ta.ema(BBB, BBBB)
  18. slowMA = ta.ema(BBB, BBBBB)
  19. AAAA = fastMA - slowMA
  20. AAAA
  21.  
  22. AAAAA(EEEEEE, BBBB, BBBBB) =>
  23. AAA = 0.5
  24. var CCCCC = 0.0
  25. var DDD = 0.0
  26. var DDDDDD = 0.0
  27. var EEEEE = 0.0
  28. BBBBBB = AAAA(close, BBBB, BBBBB)
  29. CCC = ta.lowest(BBBBBB, EEEEEE)
  30. CCCC = ta.highest(BBBBBB, EEEEEE) - CCC
  31. CCCCC := CCCC > 0 ? (BBBBBB - CCC) / CCCC * 100 : nz(CCCCC[1])
  32. DDD := na(DDD[1]) ? CCCCC : DDD[1] + AAA * (CCCCC - DDD[1])
  33. DDDD = ta.lowest(DDD, EEEEEE)
  34. DDDDD = ta.highest(DDD, EEEEEE) - DDDD
  35. DDDDDD := DDDDD > 0 ? (DDD - DDDD) / DDDDD * 100 : nz(DDDDDD[1])
  36. EEEEE := na(EEEEE[1]) ? DDDDDD : EEEEE[1] + AAA * (DDDDDD - EEEEE[1])
  37. EEEEE
  38.  
  39. mAAAAA = AAAAA(EEEEEE, BBBB, BBBBB)
  40.  
  41. STClong = mAAAAA > mAAAAA[1]
  42. STCshort = mAAAAA < mAAAAA[1]
  43.  
  44. STCLONG = request.security(syminfo.tickerid,timeframe , STClong)
  45.  
  46. STCSHORT = request.security(syminfo.tickerid,timeframe,STCshort)
  47.  
  48.  
  49.  
  50.  
  51.  
  52. // DMI
  53. LengthDMI = input.int(defval = 16, title = "DMI Length", group = 'DMI')
  54. LengthDMI_2 = input.int(defval = 16, title = "DMI Length_2", group = 'DMI')
  55. smoothing_lengthDMI = input.int(defval = 12, title = "DMI ADX Smoothing", group = 'DMI')
  56.  
  57. [diplus, diminus, adx] = ta.dmi(LengthDMI, smoothing_lengthDMI)
  58. [diplus_2, diminus_2, adx_2] = ta.dmi(LengthDMI_2, smoothing_lengthDMI)
  59.  
  60. DMIlong = diplus > diminus and adx > adx[1]
  61. DMIshort = diminus > diplus
  62. // DMIlong = ta.crossover(diplus, diminus) and ta.crossover(adx, adx[1])
  63. // DMIshort = ta.crossunder(diplus, diminus)
  64. DMIlong_2 = diplus_2 > diminus_2 and adx_2 > adx_2[1]
  65. DMIshort_2 = diminus_2 > diplus_2
  66.  
  67.  
  68. //////////////////////////////////////////////////////////////////////////filters////////////////////////////////////////////////////////////////////////
  69.  
  70.  
  71. // RTI
  72. trend_data_count = input.int(113, step=4, minval=10, title="Trend Length", inline = "RT", group="RTI")
  73. trend_sensitivity_percentage = input.int(95, step=1,minval=50, maxval=98,title='Sensitivity', inline = "RT1", group="RTI")
  74.  
  75. upper_trend = close + ta.stdev(close, 2)
  76. lower_trend = close - ta.stdev(close, 2)
  77.  
  78. upper_array = array.new<float>(0)
  79. lower_array = array.new<float>(0)
  80. for i = 0 to trend_data_count - 1
  81. upper_array.push(upper_trend[i])
  82. lower_array.push(lower_trend[i])
  83. upper_array.sort()
  84. lower_array.sort()
  85.  
  86. upper_index = math.round(trend_sensitivity_percentage / 100 * trend_data_count) - 1
  87. lower_index = math.round((100 - trend_sensitivity_percentage) / 100 * trend_data_count) - 1
  88. UpperTrend = upper_array.get(upper_index)
  89. LowerTrend = lower_array.get(lower_index)
  90. RelativeTrendIndex = ((close - LowerTrend) / (UpperTrend - LowerTrend))*100
  91.  
  92.  
  93. RTIlong = RelativeTrendIndex > 50
  94. RTIshort = RelativeTrendIndex < 50
  95.  
  96. // RTIlong = ta.crossover(RelativeTrendIndex, 50)
  97. // RTIshort = ta.crossunder(RelativeTrendIndex, 50)
  98.  
  99.  
  100.  
  101. // Supertrend
  102.  
  103. atrSupertrend = input.int(10, "ATR", group="Supertrend")
  104. factor = input.float(3, "Factor", step=0.05,group="Supertrend")
  105. [a, direction] = ta.supertrend(factor, atrSupertrend)
  106.  
  107. // supertrend_Long = direction < 0
  108. // supertrend_Short = direction > 0
  109. supertrend_Long = ta.crossunder(direction, 0)
  110. supertrend_Short = ta.crossover(direction, 0)
  111.  
  112.  
  113.  
  114. // rsi
  115. rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
  116. rsiSourceInput = input.source(close, group="RSI Settings")
  117. uprsi = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
  118. downrsi = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
  119. rsi = downrsi == 0 ? 100 : uprsi == 0 ? 0 : 100 - (100 / (1 + uprsi / downrsi))
  120. lengthrsiema = input.int(14, group="RSI Settings")
  121. RSIEMA = ta.ema(rsi,lengthrsiema)
  122.  
  123. // RSIema_long = RSIEMA > 50
  124. RSIema_short = RSIEMA < 50
  125. RSIema_long = ta.crossover(RSIEMA, 50)
  126. // RSIema_short = ta.crossunder(RSIEMA, 50)
  127.  
  128. rsi2 = ta.rsi(close, 21)
  129.  
  130. RSI_long = rsi2 > 50
  131. RSI_short = rsi2 < 50
  132.  
  133.  
  134.  
  135. //Aroon
  136. aroonlength = input.int(27, "Aroon UP", group = "Aroon")
  137. lowerlength = input.int(28,"Aroon Down", group = "Aroon")
  138.  
  139. upper = 100 * (ta.highestbars(high, aroonlength+1) + aroonlength)/aroonlength
  140. lower = 100 * (ta.lowestbars(low, lowerlength+1) + lowerlength)/lowerlength
  141. oscillator1 = upper - lower
  142. smoothing1 = input.int(14, "Aroon Smoothing", group = "Aroon")
  143. oscillator = ta.ema(oscillator1, smoothing1)
  144. aroonup = input.int(7, "AroonUP lvl", group = "Aroon")
  145. aroondn = input.int(14,"AroonDN lvl", group = "Aroon")
  146.  
  147.  
  148.  
  149. aroon_long = upper > aroonup
  150. aroon_short = lower > aroondn and oscillator < 75
  151.  
  152. // Loxx supertrend
  153.  
  154. RMA(x, t) =>
  155. EMA1 = x
  156. EMA1 := na(EMA1[1]) ? x : (x - nz(EMA1[1])) * (1/t) + nz(EMA1[1])
  157. EMA1
  158.  
  159. fdip(float srcloxx, int per, int speedin)=>
  160. float fmax = ta.highest(srcloxx, per)
  161. float fmin = ta.lowest(srcloxx, per)
  162. float lengthloxx = 0
  163. float diff = 0
  164. for i = 1 to per - 1
  165. diff := (nz(srcloxx[i]) - fmin) / (fmax - fmin)
  166. if i > 0
  167. lengthloxx += math.sqrt( math.pow(nz(diff[i]) - nz(diff[i + 1]), 2) + (1 / math.pow(per, 2)))
  168. float fdi = 1 + (math.log(lengthloxx) + math.log(2)) / math.log(2 * per)
  169. float traildim = 1 / (2 - fdi)
  170. float alpha = traildim / 2
  171. int speed = math.round(speedin * alpha)
  172. speed
  173.  
  174. pine_supertrend(float srcloxx, float factor, int atrPeriod) =>
  175. float atr = RMA(ta.tr(true), atrPeriod)
  176. float upperBand = srcloxx + factor * atr
  177. float lowerBand = srcloxx - factor * atr
  178. float prevLowerBand = nz(lowerBand[1])
  179. float prevUpperBand = nz(upperBand[1])
  180.  
  181. lowerBand := lowerBand > prevLowerBand or close[1] < prevLowerBand ? lowerBand : prevLowerBand
  182. upperBand := upperBand < prevUpperBand or close[1] > prevUpperBand ? upperBand : prevUpperBand
  183. int directionloxx = na
  184. float superTrend = na
  185. float prevSuperTrend = superTrend[1]
  186. if na(atr[1])
  187. directionloxx := 1
  188. else if prevSuperTrend == prevUpperBand
  189. directionloxx := close > upperBand ? -1 : 1
  190. else
  191. directionloxx := close < lowerBand ? 1 : -1
  192. superTrend := directionloxx == -1 ? lowerBand : upperBand
  193. [superTrend, directionloxx]
  194.  
  195. srcloxx = input.source(hl2, group = "Loxx")
  196. per = input.int(30, "Fractal Period Ingest", group = "Loxx")
  197. speed = input.int(20, "Speed", group = "Loxx")
  198.  
  199. //Loxx input
  200. multloxx5 = input.float(5 , "1st Multiplier", group = "Loxx", step=0.1) //~using the same step as supertrend and *2 to test the robustness = 0.05*2 = 0.1
  201. multloxx2 = input.float(2 , "2nd Multiplier", group = "Loxx", step=0.1) //~
  202. multloxx3 = input.float(3 , "3rd Multiplier", group = "Loxx", step=0.1) //~
  203. multloxx1825 = input.float(1.825, "4th Multiplier", group = "Loxx", step=0.1) //~
  204. adaptloxx = input.bool(true)
  205.  
  206. masterdom = fdip(srcloxx, per, speed)
  207. int lenloxx = math.floor(masterdom) < 1 ? 1 : math.floor(masterdom)
  208. lenloxx := nz(lenloxx, 1)
  209.  
  210. [supertrendloxx5, directionloxx] = pine_supertrend(srcloxx, multloxx5, adaptloxx ? lenloxx : per)
  211.  
  212. [supertrendloxx3, directionloxx3] = pine_supertrend(srcloxx, multloxx3, adaptloxx ? lenloxx : per)
  213.  
  214. [supertrendloxx2, directionloxx2] = pine_supertrend(srcloxx, multloxx2, adaptloxx ? lenloxx : per)
  215.  
  216. [supertrendloxx1825, directionloxx1825] = pine_supertrend(srcloxx, multloxx1825, adaptloxx ? lenloxx : per)
  217. // loxx_long = directionloxx == -1 and directionloxx[1] == 1
  218. // loxx_short = directionloxx == 1 and directionloxx[1] == -1
  219.  
  220. loxx_long = close > supertrendloxx5
  221. loxx_short = close < supertrendloxx5
  222.  
  223. loxx_long_2 = directionloxx2 == -1 and directionloxx2[1] == 1
  224. loxx_short_2 = directionloxx == 1 and directionloxx[1] == -1
  225.  
  226. loxx_long_3 = directionloxx3 == -1 and directionloxx3[1] == 1
  227. loxx_short_3 = close < supertrendloxx3
  228.  
  229. loxx_long_1_825 = close > supertrendloxx1825
  230. loxx_short_1_825 = close < supertrendloxx1825
  231.  
  232. //adx
  233. adxlen = input(7, title="ADX Smoothing", group = "ADX")
  234. dilen = input(6, title="ADX_DI Length", group = "ADX")
  235. adx_crit = input(27, title="ADX Crit", group = "ADX")
  236. dirmov(len) =>
  237. up = ta.change(high)
  238. down = -ta.change(low)
  239. plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
  240. minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
  241. truerange = ta.rma(ta.tr, len)
  242. plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
  243. minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
  244. [plus, minus]
  245. adx(dilen, adxlen) =>
  246. [plus, minus] = dirmov(dilen)
  247. sum = plus + minus
  248. //adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
  249. sig = adx(dilen, adxlen)
  250. adx_up = sig > adx_crit
  251. adx_down = sig > adx_crit
  252.  
  253.  
  254.  
  255.  
  256. //longCondition =
  257. // STClong and ((DMIlong and DMIlong_2) or ((loxx_long_2 or loxx_long_3) and supertrend_Long and trend_up))
  258. // and (RSIema_long or RTIlong or roughlong or loxx_long or loxx_long_2 )
  259. //
  260. //shortCondition =
  261. // STCshort and (DMIshort and DMIshort_2) and (loxx_short_1_825 or loxx_short_3)
  262. // and (RSIema_short or RTIshort or roughshort or loxx_short or loxx_short_2 or (trend_down2 and trend_down2_2))
  263.  
  264.  
  265.  
  266.  
  267. //psar
  268. start = input(0.02)
  269. increment = input(0.02)
  270. maximum = input(0.2)
  271.  
  272.  
  273.  
  274.  
  275. psar = ta.sar(start, increment, maximum)
  276.  
  277. // Signals
  278. psar_long = high[1] < psar[2] and high > psar[1]
  279. psar_short = low[1] > psar[2] and low < psar[1]
  280.  
  281.  
  282.  
  283. // GET INPUTS FVZSO //----------------------------------------------------------------------------------
  284.  
  285. src0 = input.source (close , 'Source', group = "VZO" )
  286. len = input.int (45 , 'VZO Length', group = "VZO" , minval=1)
  287. malen = input.int (7 , 'MA Length', group = "VZO" , minval=1)
  288. flen = input.int (7 , 'Fisher Length', group = "VZO", minval=1)
  289.  
  290. col_1 = input.color(#22ab94,'Color 1')
  291. col_2 = input.color(#f7525f,'Color 2')
  292.  
  293.  
  294. // CALC VZO //------------------------------------------------------------------------------------
  295.  
  296.  
  297. zone(_src, _len) =>
  298. vol = volume
  299. src = ta.wma(2 * ta.wma(_src, malen / 2) - ta.wma(_src, malen), math.round(math.sqrt(malen)))
  300. vp = src > src[1] ? vol : src < src[1] ? -vol : src == src[1] ? 0 : 0
  301. z = 100 * (ta.ema(vp, _len) / ta.ema(vol, _len))
  302.  
  303.  
  304. vzo = request.security(syminfo.tickerid,"",zone(src0, len))
  305.  
  306.  
  307. // CALC FISHER //---------------------------------------------------------------------------------
  308.  
  309. fsrc = vzo
  310. MaxH = ta.highest (fsrc , flen)
  311. MinL = ta.lowest (fsrc , flen)
  312. var nValue1 = 0.0
  313. var nFish = 0.0
  314.  
  315.  
  316. nValue1 := 0.33 * 2 * ((fsrc - MinL) / (MaxH - MinL) - 0.5) + 0.67 * nz(nValue1[1])
  317. nValue2 = (nValue1 > 0.99 ? 0.999 : (nValue1 < -0.99 ? -0.999: nValue1))
  318. nFish := 0.5 * math.log((1 + nValue2) / (1 - nValue2)) + 0.5 * nz(nFish[1])
  319.  
  320. f1 = nFish
  321. f2 = nz(nFish[1])
  322.  
  323.  
  324. // PLOT //----------------------------------------------------------------------------------------
  325.  
  326. col = f1 > f2 ? col_1 : col_2
  327. fzvzo_up = f1 > f2
  328. plot(f1 , color=col , title="Fisher" )
  329. plot(f2 , color=col , title="Trigger" )
  330.  
  331.  
  332. //DMI
  333. //lensig2 = input.int(34, title="ADX Smoothing", minval=1, maxval=50, group="DMI - Confluence 1")
  334. lensig2 = 34
  335. len2 = input.int(15, minval=1, title="DI Length", group="DMI - Confluence 1")
  336. up2 = ta.change(high)
  337. down2 = -ta.change(low)
  338. plusDM2 = na(up2) ? na : (up2 > down2 and up2 > 0 ? up2 : 0)
  339. minusDM2 = na(down2) ? na : (down2 > up2 and down2 > 0 ? down2 : 0)
  340. trur2 = ta.rma(ta.tr, len2)
  341. plus2 = fixnan(100 * ta.rma(plusDM2, len2) / trur2)
  342. minus2 = fixnan(100 * ta.rma(minusDM2, len2) / trur2)
  343. sum2 = plus2 + minus2
  344. adx2 = 100 * ta.rma(math.abs(plus2 - minus2) / (sum2 == 0 ? 1 : sum2), lensig2)
  345.  
  346. dmi_long = ((plus2 > adx2) and (adx2 > 20) and (plus2 > 20)) or (((adx2 > adx2[1]) and (adx2[1] > adx2[2])) and (plus2 > adx2) and (adx2 >20)) or ((ta.crossover(plus2, minus2) and adx2 > 40)) or ((adx2 > 30) and (minus2 < plus2) and (plus2 > 25))
  347. dmi_up = ((plus2[0] > plus2[1]) and (plus2[0] > plus2[2]) and (plus2[0] > plus2[3])) and ((adx2 > adx2[1]) and (adx2[1] > adx2[2]) and (adx2[2] > adx2[3]))
  348. dmi_cross_up = ta.crossover(plus2, minus2)
  349. dmi_bottom = (adx2 > 55) and (minus2 > 40) and (plus2 <15)
  350.  
  351.  
  352. //or ((minus2 < 20) and (plus2 <20) and (adx2 < 35))
  353. dmi_short = ((ta.crossover(minus2, plus2) and adx2 > 20)) or ((adx2 > 32) and (minus2 > plus2)) or ((minus2 > adx2) and (adx2 > 40) and (minus2 > 25)) or (((adx2 > adx2[1]) and (adx2[1] > adx2[2])) and (minus2 > adx2) and (adx2 > 25)) or ((minus2 > plus2) and (adx2 >30))
  354. dmi_down = ((minus2[0] > minus2[1]) and (minus2[0] > minus2[2]) and (minus2[0] > minus2[3])) and ((adx2 > adx2[1]) and (adx2[1] > adx2[2]) and (adx2[2] > adx2[3]))
  355. dmi_cross_down = ta.crossover(minus2, plus2)
  356. dmi_top = (adx2 > 55) and (plus2 > 40) and (minus2 <15)
  357.  
  358.  
  359. //Bolinger Bands
  360. source = hlc3
  361. BB_Length = input.int(13, minval=1, group="BBANDS - Confluence 2")
  362. mult = input.float(2.3, title="BB Mult",minval=0.001, maxval=50, group="BBANDS - Confluence 2")
  363. basis = ta.sma(source, BB_Length)
  364. dev = mult * ta.stdev(source, BB_Length)
  365. upper = basis + dev
  366. lower = basis - dev
  367. bblong = source < upper
  368. bbshort = source > lower
  369.  
  370.  
  371.  
  372. //AROON
  373. AROON_Length = input.int(5, minval=1, group="AROON")
  374. AROONupper = 100 * (ta.highestbars(high, AROON_Length+1) + AROON_Length)/AROON_Length
  375. AROONlower = 100 * (ta.lowestbars(low, AROON_Length+1) + AROON_Length)/AROON_Length
  376.  
  377. aroon_bull = ta.crossover(AROONupper, AROONlower)
  378. aroon_bear = ta.crossunder(AROONupper, AROONlower)
  379. //aroon_long = AROONlower > AROONupper
  380. //aroon_short = AROONlower < AROONupper
  381.  
  382.  
  383. //STC
  384. //EEEEEE = input(14, 'LengthSTC', group="STC")
  385. ///BBBB = input(25, 'FastLengthSTC', group="STC")
  386. //BBBBB = input(60, 'SlowLengthSTC', group="STC")
  387.  
  388. ///AAAA(BBB, BBBB, BBBBB) =>
  389. /// fastMA = ta.ema(BBB, BBBB)
  390. // slowMA = ta.ema(BBB, BBBBB)
  391. // AAAA = fastMA - slowMA
  392. /// AAAA
  393.  
  394. //AAAAA(EEEEEE, BBBB, BBBBB) =>
  395. AAA = input(1.5, title="STC Factor", group="STC")
  396. var CCCCC = 0.0
  397. var DDD = 0.0
  398. var DDDDDD = 0.0
  399. var EEEEE = 0.0
  400. BBBBBB = AAAA(close, BBBB, BBBBB)
  401. CCC = ta.lowest(BBBBBB, EEEEEE)
  402. CCCC = ta.highest(BBBBBB, EEEEEE) - CCC
  403. CCCCC := CCCC > 0 ? (BBBBBB - CCC) / CCCC * 100 : nz(CCCCC[1])
  404. DDD := na(DDD[1]) ? CCCCC : DDD[1] + AAA * (CCCCC - DDD[1])
  405. DDDD = ta.lowest(DDD, EEEEEE)
  406. DDDDD = ta.highest(DDD, EEEEEE) - DDDD
  407. DDDDDD := DDDDD > 0 ? (DDD - DDDD) / DDDDD * 100 : nz(DDDDDD[1])
  408. EEEEE := na(EEEEE[1]) ? DDDDDD : EEEEE[1] + AAA * (DDDDDD - EEEEE[1])
  409. EEEEE
  410.  
  411. //mAAAAA = AAAAA(EEEEEE, BBBB, BBBBB)
  412.  
  413.  
  414. stc_short = (mAAAAA[3] <= mAAAAA[2]) and (mAAAAA[2] >= mAAAAA[1]) and (mAAAAA > 40)
  415. stc_long = (mAAAAA[3] >= mAAAAA[2]) and (mAAAAA[2] <= mAAAAA[1]) and (mAAAAA < 60)
  416.  
  417. stc_low = mAAAAA < 25
  418. stc_high = mAAAAA > 75
  419.  
  420.  
  421.  
  422. //MACD
  423. MACD_Fast_Length = input(15, group="MACD")
  424. MACD_Slow_Length = input(200, group="MACD")
  425. MACD_Length = input(25, group="MACD")
  426. MACD = ta.ema(close, MACD_Fast_Length) - ta.ema(close, MACD_Slow_Length)
  427. aMACD = ta.ema(MACD, MACD_Length)
  428. delta = MACD - aMACD
  429.  
  430. macd_long = MACD > aMACD
  431. macd_short = MACD < aMACD
  432.  
  433.  
  434.  
  435.  
  436. //Momentum
  437. length4 = input.int(10, title="Momentum Length", minval=1, group="Momentum Indicator")
  438. price = close
  439. momentum(seria, length4) =>
  440. mom = seria - seria[length4]
  441. mom
  442. mom0 = momentum(price, length4)
  443. mom1 = momentum( mom0, 1)
  444. mom_long = (mom0 > 0 and mom1 > 0)
  445.  
  446.  
  447. mom_short = (mom0 < 0 and mom1 < 0)
  448.  
  449.  
  450. //trend
  451. atrPeriod = input(200, "Trendline Length", group="Trendline Indicator")
  452. factor = input.float(2, "Trendline Factor", step = 0.01, group="Trendline Indicator")
  453.  
  454. [_, direction] = ta.supertrend(factor, atrPeriod)
  455.  
  456. trendlong = ta.change(direction) < 0
  457.  
  458.  
  459. trendshort = ta.change(direction) > 0
  460.  
  461. //RSI
  462. //RSI_Length = input.int(14, minval=1, group="RSI - Confluence 3")
  463. rsi = ta.rsi(close, 14)
  464. rsi_over_sold = rsi < 37
  465. rsi_over_bought = rsi > 60
  466. rsi_high = rsi > 50
  467. rsi_low = rsi < 50
  468.  
  469. //EMA
  470. fastEMA = ta.ema(close, 26)
  471. slowEMA = ta.ema(hlc3, 200)
  472. ema_long = fastEMA > slowEMA
  473. ema_short = fastEMA < slowEMA
  474. slow_ema_long = slowEMA > src
  475. slow_ema_short = slowEMA < src
  476.  
  477. //VWAP
  478. vwap = ta.vwap(close)
  479. vwap_long = vwap > src
  480. vwap_short = vwap < src
  481.  
  482.  
  483. ///////////INDICATORS BEGIN - ONE AT A TIME, OPTIMISED FOR THE ASSET, BTC IN THIS CASE
  484.  
  485. //HULL
  486. src = close
  487. modeSwitch = input.string("Thma", title="Hull Variation", options=["Thma"])
  488. length = input(178, title="Length(180-200 for floating S/R , 55 for swing entry)")
  489. lengthMult = input.float(1.0, title="Length multiplier (Used to view higher timeframes with straight band)")
  490.  
  491. useHtf = input(false, title="Show Hull MA from X timeframe? (good for scalping)")
  492. htf = input("240", title="Higher timeframe")
  493.  
  494. switchColor = input(false, "Color Hull according to trend?")
  495. candleCol = input(false, title="Color candles based on Hull's Trend?")
  496. visualSwitch = input(false, title="Show as a Band?")
  497. thicknesSwitch = input(1, title="Line Thickness")
  498. transpSwitch = input.int(40, title="Band Transparency", step=5)
  499.  
  500. //FUNCTIONS
  501.  
  502. //THMA
  503. THMA(_src, _length) => ta.wma(ta.wma(_src,_length / 3) * 3 - ta.wma(_src, _length / 2) - ta.wma(_src, _length), _length)
  504.  
  505. //SWITCH
  506. Mode(modeSwitch, src, len) =>
  507. modeSwitch == "Thma" ? THMA(src, len/2) : na
  508.  
  509. //OUT
  510. _hull = Mode(modeSwitch, src, int(length * lengthMult))
  511. HULL = useHtf ? request.security(syminfo.ticker, htf, _hull) : _hull
  512. MHULL = HULL[0]
  513. SHULL = HULL[2]
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520. ///////ANOTHER ONE
  521.  
  522. //EMAs
  523. EMA_Length_1 = input.int(title="EMA 1 Length", group="EMA", defval=10)
  524. EMA_Length_2 = input.int(title="EMA 2 Length", group="EMA", defval=69)
  525. EMA_Length_3 = input.int(title="EMA 3 Length", group="EMA", defval=115)
  526.  
  527. EMA1 = ta.ema(close, EMA_Length_1)
  528. EMA2 = ta.ema(close, EMA_Length_2)
  529. EMA3 = ta.ema(close, EMA_Length_3)
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536. ///////ANOTHER ONE
  537.  
  538. // VR
  539. volatilityLower = input.float(title = "Lower Range", defval= -39, group = "VRG")
  540. volatilityHigher = input.float(title = "Higher Range", defval= 9)
  541. volatilityLength = 58
  542. volatilityRange = ta.sma(close - open, volatilityLength)
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552. ////////ANOTHER ONE
  553.  
  554.  
  555. //MACD
  556. FastLength = input(title="MACD Fast Length", group="MACD", defval=47)
  557. Slowlength = input(title="MACD Slow Length", group="MACD", defval=79)
  558. MACDLength = input(title="MACD Signal Length", group="MACD", defval=30)
  559.  
  560. MACD = ta.ema(close, FastLength) - ta.ema(close, Slowlength)
  561. aMACD = ta.ema(MACD, MACDLength)
  562. delta = MACD - aMACD
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574. ////////YOU CAN PUT THESE STRAT PARAMETERS WITH THE INDICATOR THEMSELVES OR SEPARATE - I DID IT SEPARATE SO I COULD SEE THAT AND THE ENTRY CONDITIONS AT THE SAME TIME
  575. //STRATEGY PARAMETERS
  576. LongEMA = ta.crossover(EMA1, EMA2) or ta.crossover(EMA1, EMA3) or ta.crossover(EMA2, EMA3)
  577. ShortEMA = ta.crossunder(EMA1, EMA2) or ta.crossunder(EMA1, EMA3) or ta.crossunder(EMA2, EMA3)
  578.  
  579. LongMACD = ta.crossover(delta, 0)
  580. ShortMACD = ta.crossunder(delta, 0)
  581.  
  582. VRL = volatilityRange > volatilityLower
  583. VRS = volatilityRange < volatilityHigher
  584. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  585. //STRATEGY
  586.  
  587.  
  588. //////////EACH BIT HAS A DEFINITION - START TIME FOR CONDITION AND EITHER LONG OR SHORT.
  589. start= timestamp(2012,1,1,0,0)
  590. timeCond = time > start
  591.  
  592. Longoption1 = ta.crossover(MHULL, SHULL)
  593. Longoption2 = LongMACD
  594. Longoption3 = LongEMA
  595. Longoption4 = VRL
  596.  
  597. Shortoption1 = ta.crossover(SHULL, MHULL)
  598. Shortoption2 = ShortMACD
  599. Shortoption3 = ShortEMA
  600. Shortoption4 = VRS
  601.  
  602.  
Advertisement
Comments
  • # text 0.12 KB | 1 0
    1. download all types of premium tradingview indicators codes available on telegram - https://t.me/tradingview_premium_indicator
Add Comment
Please, Sign In to add comment
Advertisement