Advertisement
danucante

Untitled

Nov 18th, 2023
131
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.56 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © danielcantea
  3.  
  4.  
  5. //@version=5
  6. strategy("THE MATRIX KILLER", overlay=true, pyramiding = 0, slippage = 1, initial_capital = 100, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)
  7.  
  8. // Plot Cobra Metrics Table
  9. import EliCobra/CobraMetrics/4 as cobra
  10.  
  11.  
  12. disp_ind = input.string ("Equity" , title = "Display Curve" , tooltip = "Choose which data you would like to display", options=["Strategy", "Equity", "Open Profit", "Gross Profit", "Net Profit", "None"], group = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  13. pos_table = input.string("Bottom Right", "Table Position", options = ["Top Left", "Middle Left", "Bottom Left", "Top Right", "Middle Right", "Bottom Right", "Top Center", "Bottom Center"], group = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  14. type_table = input.string("Full", "Table Type", options = ["Full", "Simple", "None"], group = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  15.  
  16. plot(cobra.curve(disp_ind))
  17. cobra.cobraTable(type_table, pos_table)
  18.  
  19. // Time Range
  20. startTime = input.time(defval = timestamp("01 January 2018"), title = "Start Date")
  21. isInTimeRange = time >= startTime
  22.  
  23.  
  24. //////////////////////////////////////////////////////////////////////////Main indicators////////////////////////////////////////////////////////////////////////
  25.  
  26.  
  27. //STC
  28. EEEEEE = input.int(defval = 13, step = 1, title = "STC Length", group = "STC")
  29. BBBB = input.int(defval = 31, step = 1, title = "STC Fast Length", group = "STC")
  30. BBBBB = input.int(defval = 70, step = 1, title = "STC Slow Length", group = "STC")
  31.  
  32. AAAA(BBB, BBBB, BBBBB) =>
  33. fastMA = ta.ema(BBB, BBBB)
  34. slowMA = ta.ema(BBB, BBBBB)
  35. AAAA = fastMA - slowMA
  36. AAAA
  37.  
  38. AAAAA(EEEEEE, BBBB, BBBBB) =>
  39. AAA = 0.5
  40. var CCCCC = 0.0
  41. var DDD = 0.0
  42. var DDDDDD = 0.0
  43. var EEEEE = 0.0
  44. BBBBBB = AAAA(close, BBBB, BBBBB)
  45. CCC = ta.lowest(BBBBBB, EEEEEE)
  46. CCCC = ta.highest(BBBBBB, EEEEEE) - CCC
  47. CCCCC := CCCC > 0 ? (BBBBBB - CCC) / CCCC * 100 : nz(CCCCC[1])
  48. DDD := na(DDD[1]) ? CCCCC : DDD[1] + AAA * (CCCCC - DDD[1])
  49. DDDD = ta.lowest(DDD, EEEEEE)
  50. DDDDD = ta.highest(DDD, EEEEEE) - DDDD
  51. DDDDDD := DDDDD > 0 ? (DDD - DDDD) / DDDDD * 100 : nz(DDDDDD[1])
  52. EEEEE := na(EEEEE[1]) ? DDDDDD : EEEEE[1] + AAA * (DDDDDD - EEEEE[1])
  53. EEEEE
  54.  
  55. mAAAAA = AAAAA(EEEEEE, BBBB, BBBBB)
  56.  
  57. STClong = mAAAAA > mAAAAA[1]
  58. STCshort = mAAAAA < mAAAAA[1]
  59.  
  60. // DMI
  61. LengthDMI = input.int(defval = 16, title = "DMI Length", group = 'DMI')
  62. LengthDMI_2 = input.int(defval = 16, title = "DMI Length_2", group = 'DMI')
  63. smoothing_lengthDMI = input.int(defval = 12, title = "DMI ADX Smoothing", group = 'DMI')
  64.  
  65. [diplus, diminus, adx] = ta.dmi(LengthDMI, smoothing_lengthDMI)
  66. [diplus_2, diminus_2, adx_2] = ta.dmi(LengthDMI_2, smoothing_lengthDMI)
  67.  
  68. DMIlong = diplus > diminus and adx > adx[1]
  69. DMIshort = diminus > diplus
  70. // DMIlong = ta.crossover(diplus, diminus) and ta.crossover(adx, adx[1])
  71. // DMIshort = ta.crossunder(diplus, diminus)
  72. DMIlong_2 = diplus_2 > diminus_2 and adx_2 > adx_2[1]
  73. DMIshort_2 = diminus_2 > diplus_2
  74.  
  75. // RTI
  76. trend_data_count = input.int(113, step=1, minval=10, title="Trend Length", inline = "RT", group="RTI")
  77. trend_sensitivity_percentage = input.int(95, step=1,minval=50, maxval=98,title='Sensitivity', inline = "RT1", group="RTI")
  78.  
  79. upper_trend = close + ta.stdev(close, 2)
  80. lower_trend = close - ta.stdev(close, 2)
  81.  
  82. upper_array = array.new<float>(0)
  83. lower_array = array.new<float>(0)
  84. for i = 0 to trend_data_count - 1
  85. upper_array.push(upper_trend[i])
  86. lower_array.push(lower_trend[i])
  87. upper_array.sort()
  88. lower_array.sort()
  89.  
  90. upper_index = math.round(trend_sensitivity_percentage / 100 * trend_data_count) - 1
  91. lower_index = math.round((100 - trend_sensitivity_percentage) / 100 * trend_data_count) - 1
  92. UpperTrend = upper_array.get(upper_index)
  93. LowerTrend = lower_array.get(lower_index)
  94. RelativeTrendIndex = ((close - LowerTrend) / (UpperTrend - LowerTrend))*100
  95. //
  96. RTIlong = RelativeTrendIndex > 50
  97. RTIshort = RelativeTrendIndex < 50
  98.  
  99. // RTIlong = ta.crossover(RelativeTrendIndex, 50)
  100. // RTIshort = ta.crossunder(RelativeTrendIndex, 50)
  101.  
  102. // rsi
  103. rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
  104. rsiSourceInput = input.source(close, group="RSI Settings")
  105. uprsi = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
  106. downrsi = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
  107. rsi = downrsi == 0 ? 100 : uprsi == 0 ? 0 : 100 - (100 / (1 + uprsi / downrsi))
  108.  
  109. rsi2 = ta.rsi(close, 21)
  110.  
  111. RSI_long = rsi2 > 50
  112. RSI_short = rsi2 < 50
  113. // RSI_long = ta.crossover(rsi2, 50)
  114. // RSI_short = ta.crossunder(rsi2, 50)
  115.  
  116. // Loxx supertrend
  117.  
  118. RMA(x, t) =>
  119. EMA1 = x
  120. EMA1 := na(EMA1[1]) ? x : (x - nz(EMA1[1])) * (1/t) + nz(EMA1[1])
  121. EMA1
  122.  
  123. fdip(float srcloxx, int per, int speedin)=>
  124. float fmax = ta.highest(srcloxx, per)
  125. float fmin = ta.lowest(srcloxx, per)
  126. float lengthloxx = 0
  127. float diff = 0
  128. for i = 1 to per - 1
  129. diff := (nz(srcloxx[i]) - fmin) / (fmax - fmin)
  130. if i > 0
  131. lengthloxx += math.sqrt( math.pow(nz(diff[i]) - nz(diff[i + 1]), 2) + (1 / math.pow(per, 2)))
  132. float fdi = 1 + (math.log(lengthloxx) + math.log(2)) / math.log(2 * per)
  133. float traildim = 1 / (2 - fdi)
  134. float alpha = traildim / 2
  135. int speed = math.round(speedin * alpha)
  136. speed
  137.  
  138. pine_supertrend(float srcloxx, float factor, int atrPeriod) =>
  139. float atr = RMA(ta.tr(true), atrPeriod)
  140. float upperBand = srcloxx + factor * atr
  141. float lowerBand = srcloxx - factor * atr
  142. float prevLowerBand = nz(lowerBand[1])
  143. float prevUpperBand = nz(upperBand[1])
  144.  
  145. lowerBand := lowerBand > prevLowerBand or close[1] < prevLowerBand ? lowerBand : prevLowerBand
  146. upperBand := upperBand < prevUpperBand or close[1] > prevUpperBand ? upperBand : prevUpperBand
  147. int directionloxx = na
  148. float superTrend = na
  149. float prevSuperTrend = superTrend[1]
  150. if na(atr[1])
  151. directionloxx := 1
  152. else if prevSuperTrend == prevUpperBand
  153. directionloxx := close > upperBand ? -1 : 1
  154. else
  155. directionloxx := close < lowerBand ? 1 : -1
  156. superTrend := directionloxx == -1 ? lowerBand : upperBand
  157. [superTrend, directionloxx]
  158.  
  159. srcloxx = input.source(hl2, group = "Loxx")
  160. per = input.int(30, "Fractal Period Ingest", group = "Loxx")
  161. speed = input.int(20, "Speed", group = "Loxx")
  162.  
  163. //Loxx input
  164. multloxx5 = input.float(7 , "1st Multiplier", group = "Loxx", step=1) //~using the same step as supertrend and *2 to test the robustness = 0.05*2 = 0.1
  165.  
  166. multloxx2 = input.float(3 , "2rd Multiplier", group = "Loxx", step=1) //~
  167.  
  168. adaptloxx = input.bool(true)
  169.  
  170. masterdom = fdip(srcloxx, per, speed)
  171. int lenloxx = math.floor(masterdom) < 1 ? 1 : math.floor(masterdom)
  172. lenloxx := nz(lenloxx, 1)
  173.  
  174. [supertrendloxx5, directionloxx] = pine_supertrend(srcloxx, multloxx5, adaptloxx ? lenloxx : per)
  175.  
  176. [supertrendloxx2, directionloxx2] = pine_supertrend(srcloxx, multloxx2, adaptloxx ? lenloxx : per)
  177.  
  178. loxx_long = close > supertrendloxx5
  179. loxx_short = close < supertrendloxx5
  180.  
  181. loxx_long_2 = directionloxx2 == -1 and directionloxx2[1] == 1
  182. loxx_short_2 = close < supertrendloxx2
  183.  
  184.  
  185. // rough avg
  186. len = input.int(70, "Length", group = "Rough AVG")
  187. colbar = input.string("None", "Bar Coloring", ["None", "Trend", "Extremities", "Reversions"])
  188. revshow = input.bool(true)
  189.  
  190. f_checkp() =>
  191. p = close
  192. count = 0
  193.  
  194. while p > 1
  195. p /= 10
  196. count += 1
  197.  
  198. math.pow(10, count)
  199.  
  200. f_profile(len) =>
  201. l = len
  202. integral = 0.0
  203.  
  204. f_x = math.abs(ta.rsi(close, len))
  205.  
  206. for x = low / f_checkp() to high / f_checkp()
  207. integral := integral + f_x
  208.  
  209. l * integral
  210.  
  211. spacing_profile = f_profile(len)
  212.  
  213. ra = ta.rsi(ta.ema(spacing_profile, len), len)
  214.  
  215. roughlong = ra > 50
  216. roughshort = ra < 50
  217. // roughlong = ta.crossover(ra, 50)
  218. // roughshort = ta.crossunder(ra, 50)
  219.  
  220. // {Gunzo} Trend Sniper
  221.  
  222. float ma_source = input(title='MA Source', defval=close,group = "Trend Sniper Settings")
  223. int ma_length = input.int(title='MA Length', defval=28, minval=1,group = "Trend Sniper Settings")
  224. int smoothing_length = input.int(title='MA Smooth ', defval=10, minval=1, maxval=13,group = "Trend Sniper Settings")
  225. coefficient = ma_length / 3.0
  226.  
  227. fn_calculate_wma_with_coefficient(source, length, coefficient) =>
  228.  
  229. candle_weighted_sum = 0.0
  230. total_weight = 0.0
  231.  
  232.  
  233. for i = 0 to length by 1
  234. candle_weight = length - i
  235. candle_weighted_sum += (candle_weight - coefficient) * source[i]
  236. total_weight += candle_weight - coefficient
  237. total_weight
  238.  
  239.  
  240. weighted_line = candle_weighted_sum / total_weight
  241.  
  242. [weighted_line]
  243.  
  244. [weighted_line] = fn_calculate_wma_with_coefficient(ma_source, ma_length, coefficient)
  245. weighted_line_smooth = ta.ema(weighted_line, smoothing_length)
  246.  
  247.  
  248.  
  249. trend_up = ta.crossover(weighted_line_smooth, weighted_line_smooth[1])
  250. // trend_down = ta.crossunder(weighted_line_smooth, weighted_line_smooth[1])
  251.  
  252. // {Gunzo} Trend Sniper_2
  253.  
  254. float ma_source2 = input(title='MA sni Source2', defval=close,group = "Trend Sniper Settings")
  255. int ma_length2 = input.int(title='MA sni Length2', defval=34, minval=1,group = "Trend Sniper Settings")
  256. int smoothing_length2 = input.int(title='MA sni Smooth2 ', defval=9, minval=1, maxval=13,group = "Trend Sniper Settings")
  257.  
  258. coefficient2 = ma_length2 / 3.0
  259.  
  260. fn_calculate_wma_with_coefficient2(source1, length2, coefficient2) =>
  261.  
  262. candle_weighted_sum2 = 0.0
  263. total_weight2 = 0.0
  264.  
  265.  
  266. for i2 = 0 to length2 by 1
  267. candle_weight2 = length2 - i2
  268. candle_weighted_sum2 += (candle_weight2 - coefficient2) * source1[i2]
  269. total_weight2 += candle_weight2 - coefficient2
  270. total_weight2
  271.  
  272.  
  273. weighted_line2 = candle_weighted_sum2 / total_weight2
  274.  
  275. [weighted_line2]
  276.  
  277. [weighted_line2] = fn_calculate_wma_with_coefficient2(ma_source2, ma_length2, coefficient2)
  278. weighted_line_smooth2 = ta.ema(weighted_line2, smoothing_length2)
  279.  
  280. trend_up2 = ta.crossover(weighted_line_smooth2, weighted_line_smooth2[1])
  281.  
  282. // Inputs
  283. timeframe1=input.timeframe(defval ='1D', group = "Hull", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
  284. modeSwitch = input.string("Thma", title="Hull Variation", options=["Thma"])
  285. length = input(175, title="Length(180-200 for floating S/R , 55 for swing entry)")
  286. lengthMult = input.float(1.0, title="Length multiplier (Used to view higher timeframes with straight band)")
  287. useHtf = input(false, title="Show Hull MA from X timeframe? (good for scalping)")
  288. htf = input("240", title="Higher timeframe")
  289.  
  290. //FUNCTIONS
  291. src = request.security(syminfo.tickerid,timeframe1 ,close)
  292.  
  293. //THMA
  294. //THMA(_src, _length) => ta.wma(ta.wma(_src,_length / 3) * 3 - ta.wma(_src, _length / 2) - ta.wma(_src, _length), _length)
  295. THMA(_src, _length) => request.security(syminfo.tickerid,timeframe1 ,ta.wma(ta.wma(_src,_length / 3) * 3 - ta.wma(_src, _length / 2) - ta.wma(_src, _length), _length))
  296.  
  297. //SWITCH
  298. Mode(modeSwitch, src, len) =>
  299. modeSwitch == "Thma" ? request.security(syminfo.tickerid,timeframe1,THMA(src, len/2)) : na
  300.  
  301. //OUT
  302. _hull = Mode(modeSwitch, src, int(length * lengthMult))
  303. HULL = useHtf ? request.security(syminfo.ticker, htf, _hull) : _hull
  304. MHULL = HULL[0]
  305. SHULL = HULL[2]
  306.  
  307. HullLong = request.security(syminfo.tickerid,timeframe1 ,ta.crossover(MHULL, SHULL))
  308. HullShort = request.security(syminfo.tickerid,timeframe1 ,ta.crossover(SHULL, MHULL))
  309.  
  310.  
  311. //EFI
  312.  
  313. // Inputs
  314. timeframeefi=input.timeframe(defval ='3D', group = "EFI", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
  315. efilength = input.int(111, minval=1, group = "EFI")
  316.  
  317. // Get high and low from selected timeframe instead of the one on the chart
  318. TFclose=request.security(syminfo.tickerid,timeframeefi , close)
  319. TFvolume=request.security(syminfo.tickerid,timeframeefi , volume)
  320.  
  321. var cumVol = 0.
  322. cumVol += request.security(syminfo.tickerid,timeframeefi ,nz(volume))
  323. if barstate.islast and cumVol == 0
  324. runtime.error('Nope')
  325. efi = ta.ema(ta.change(TFclose) * TFvolume, efilength)
  326. efiLong = efi > 0
  327. efiShort = efi < 0
  328.  
  329.  
  330.  
  331. // ***************************************************************************************************************************************************************
  332.  
  333. // VR
  334. volatilityLower = input.float(title = "Lower Range", defval= -39, group = "VRG")
  335. volatilityHigher = input.float(title = "Higher Range", defval= 9)
  336. volatilityLength = 58
  337. volatilityRange = ta.sma(close - open, volatilityLength)
  338.  
  339. //VR PARAMETERS
  340. VRL = volatilityRange > volatilityLower
  341. VRS = volatilityRange < volatilityHigher
  342.  
  343.  
  344. //VZO
  345. // inputs
  346. src0 = input.source(high, 'Source', group="VZO")
  347. len1 = input.float(17.25, 'VZO Length', minval=1, step=0.5, group="VZO")
  348. flen = input.float(3.5, 'Fisher Length', minval=1, step=0.5, group="VZO")
  349. ud = input.int(12, 'Updown val', group="VZO")
  350. var VZO_Intraday = input.bool(true, 'Smoothing', group="VZO")
  351. var repaint = input.bool(false, 'Allow Repainting', group="VZO")
  352. timeframe2=input.timeframe(defval ='1D', group="VZO", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
  353.  
  354. // Sauce
  355. get_close = request.security(syminfo.tickerid,timeframe2 , close[repaint ? 0 : 1])
  356. get_vol = request.security(syminfo.tickerid,timeframe2 , volume[repaint ? 0 : 1])
  357. sym = syminfo.tickerid
  358. VZO(length, get_close, vol) =>
  359. Volume_Direction = get_close > get_close[3] ? vol : -vol
  360. VZO_volume = request.security(syminfo.tickerid,timeframe2 , ta.linreg(Volume_Direction, int(length), 0))
  361. Total_volume = request.security(syminfo.tickerid,timeframe2 , ta.linreg(vol, int(length), 0))
  362. 100 * VZO_volume / Total_volume
  363.  
  364. VZO_ = VZO(len, get_close, get_vol)
  365. if VZO_Intraday
  366. VZO_ := ta.ema(VZO_, 9)
  367.  
  368. // Fish
  369. fsrc = VZO_
  370. MaxH = request.security(syminfo.tickerid,timeframe2 , ta.highest(fsrc, int(flen)))
  371. MinL = request.security(syminfo.tickerid,timeframe2 , ta.lowest(fsrc, int(flen)))
  372. var nValue1 = 0.0
  373. var nFish = 0.0
  374. nValue1 := 0.33 * 2 * ((fsrc - MinL) / (MaxH - MinL) - 0.5) + 0.67 * nz(nValue1[1])
  375. nValue2 = (nValue1 > 0.99 ? 0.999 : (nValue1 < -0.99 ? -0.999 : nValue1))
  376. nFish := 0.5 * math.log((1 + nValue2) / (1 - nValue2)) + 0.5 * nz(nFish[1])
  377. f1 = nFish
  378. f2 = nz(nFish[1])
  379. stat = 0
  380. fzvzo_up = f1 > f2
  381. fzvzo_down = f1 < f2
  382. // Can use stat or fzvzoshort and fzvzoshort for firing buy/sell signals
  383. fzvzoshort = request.security(syminfo.tickerid,timeframe2 , ta.crossunder(f1, f2))
  384. fzvzolong = request.security(syminfo.tickerid,timeframe2 , ta.crossover(f1, f2))
  385. if fzvzolong
  386. stat := 1
  387. if fzvzoshort
  388. stat := -1
  389.  
  390. //MACD
  391.  
  392. // Inputs
  393. FastLength = input(title="MACD Fast Length", group="MACD", defval=44)
  394. Slowlength = input(title="MACD Slow Length", group="MACD", defval=95)
  395. MACDLength = input(title="MACD Signal Length", group="MACD", defval=31)
  396. timeframe3=input.timeframe(defval ='1D', group = "MACD", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
  397.  
  398. MACD = request.security(syminfo.tickerid,timeframe3 , ta.ema(close, FastLength)) - request.security(syminfo.tickerid,timeframe3 , ta.ema(close, Slowlength))
  399. aMACD = request.security(syminfo.tickerid,timeframe3 , ta.ema(MACD, MACDLength))
  400. delta = MACD - aMACD
  401.  
  402.  
  403.  
  404. // Calculate Buy/Sell orders
  405. LongMACD = ta.crossover(delta, 0)
  406. ShortMACD = ta.crossunder(delta, 0)
  407.  
  408. length4 = input.int(46, minval=1, title="CCI LENGTH", group = "CCI")
  409. src_CCI = high
  410.  
  411. //CALCULATIONS//
  412. ma = ta.sma(src_CCI, length4)
  413. cci = (src_CCI - ma) / (0.015 * ta.dev(src_CCI, length4))
  414.  
  415. //TRADE CONDITIONS//
  416. CCI_LONG = cci > 90
  417. CCI_SHORT = cci < -90
  418.  
  419. // Coral Trend
  420. sm =input(21, title="Smoothing Period", group = "CoralTrend")
  421. cd = input(0.6, title="Constant D", group = "CoralTrend")
  422. ribm=input(false, title="Ribbon Mode", group = "CoralTrend")
  423. timeframe4=input.timeframe(defval ='2D', group = "CoralTrend")
  424.  
  425. //initialise vars
  426. var float i1 = na
  427. var float i2 = na
  428. var float i3 = na
  429. var float i4 = na
  430. var float i5 = na
  431. var float i6 = na
  432.  
  433. src1=request.security(syminfo.tickerid,timeframe4, close)
  434.  
  435. di = (sm - 1.0) / 2.0 + 1.0
  436. c1 = 2 / (di + 1.0)
  437. c2 = 1 - c1
  438. c3 = 3.0 * (cd * cd + cd * cd * cd)
  439. c4 = -3.0 * (2.0 * cd * cd + cd + cd * cd * cd)
  440. c5 = 3.0 * cd + 1.0 + cd * cd * cd + 3.0 * cd * cd
  441.  
  442. i1 := c1*src1 + c2*nz(i1[1])
  443. i2 := c1*i1 + c2*nz(i2[1])
  444. i3 := c1*i2 + c2*nz(i3[1])
  445. i4 := c1*i3 + c2*nz(i4[1])
  446. i5 := c1*i4 + c2*nz(i5[1])
  447. i6 := c1*i5 + c2*nz(i6[1])
  448.  
  449. bfr = -cd*cd*cd*i6 + c3*(i5) + c4*(i4) + c5*(i3)
  450.  
  451. CoralLong = bfr > nz(bfr[1])?true:false
  452. CoralShort = bfr < nz(bfr[1])?true:false
  453.  
  454.  
  455. //INPUTS//
  456. length_AROON = input.int(25, minval=1, group = "AROON")
  457.  
  458. //CALCULATIONS//
  459. upper1 = 100 * (ta.highestbars(high, length_AROON + 1) + length_AROON)/length_AROON
  460. lower1 = 100 * (ta.lowestbars(low, length_AROON + 1) + length_AROON)/length_AROON
  461.  
  462. //TRADE CONDITIONS//
  463. AROON_LONG = upper1 > 94 and lower1 < 6
  464. AROON_SHORT = lower1 > 94 and upper1< 6
  465.  
  466. // STOCHASTIC
  467.  
  468. lengthK = input.int(10, "%K Length", minval = 1, maxval = 15000)
  469. lengthD = input.int(4, "%D Length", minval = -1, maxval = 4999)
  470. lengthEMA = input.int(13, "EMA Length", minval = 1, maxval = 4999)
  471.  
  472. emaEma(source, length) => ta.ema(ta.ema(source, length), length)
  473.  
  474. highestHigh = ta.highest(lengthK)
  475. lowestLow = ta.lowest(lengthK)
  476. highestLowestRange = highestHigh - lowestLow
  477. relativeRange = close - (highestHigh + lowestLow) / 2
  478. smi = 200 * (emaEma(relativeRange, lengthD) / emaEma(highestLowestRange, lengthD))
  479. EMAsmi = ta.ema(smi, lengthEMA)
  480.  
  481. // LONG/SHORT STOCHASTIC
  482.  
  483. StochasticLong = smi > EMAsmi
  484. StochasticShort = smi < EMAsmi
  485.  
  486. /////////
  487. longCondition = (RTIlong or STClong and (loxx_long and loxx_long_2)
  488. or efiLong and fzvzo_up and RSI_long or LongMACD or roughlong or trend_up or trend_up2 or AROON_LONG )
  489. and (DMIlong and DMIlong_2 ) or (HullLong and VRL or CCI_LONG and CoralLong and AROON_LONG and StochasticLong )
  490.  
  491.  
  492. shortCondition = (RTIshort or STCshort and loxx_short and loxx_short_2
  493. or efiShort and fzvzo_down and RSI_short or ShortMACD or roughshort )
  494. and (DMIshort and DMIshort_2 ) or (HullShort and VRS or CCI_SHORT and CoralShort and StochasticShort )
  495.  
  496.  
  497. if barstate.isconfirmed and isInTimeRange and longCondition
  498. strategy.entry("Long", strategy.long)
  499.  
  500.  
  501. if barstate.isconfirmed and isInTimeRange and shortCondition
  502. strategy.entry("Short", strategy.short)
  503.  
  504.  
  505.  
Advertisement
Comments
  • # text 0.12 KB | 0 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