Guest User

Untitled

a guest
Dec 25th, 2023
144
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.60 KB | Cryptocurrency | 0 0
  1. //@version=5
  2. strategy("BTC NANDORFEHERVAR", overlay=false, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, pyramiding=0, slippage=1)
  3.  
  4. // ELiCobra Metrics Import
  5. import EliCobra/CobraMetrics/4 as cobra
  6. //// PLOT DATA
  7. disp_ind = input.string ("None" , title = "Display Curve" , tooltip = "Choose which data you would like to display", options=["Strategy", "Equity", "Open Profit", "Gross Profit", "Net Profit", "None"], group = "๐Ÿ ๐“’๐“ธ๐“ซ๐“ป๐“ช ๐“œ๐“ฎ๐“ฝ๐“ป๐“ฒ๐“ฌ๐“ผ ๐Ÿ")
  8. pos_table = input.string("Middle Left", "Table Position", options = ["Top Left", "Middle Left", "Bottom Left", "Top Right", "Middle Right", "Bottom Right", "Top Center", "Bottom Center"], group = "๐Ÿ ๐“’๐“ธ๐“ซ๐“ป๐“ช ๐“œ๐“ฎ๐“ฝ๐“ป๐“ฒ๐“ฌ๐“ผ ๐Ÿ")
  9. type_table = input.string("None", "Table Type", options = ["Full", "Simple", "None"], group = "๐Ÿ ๐“’๐“ธ๐“ซ๐“ป๐“ช ๐“œ๐“ฎ๐“ฝ๐“ป๐“ฒ๐“ฌ๐“ผ ๐Ÿ")
  10. plot(cobra.curve(disp_ind))
  11. cobra.cobraTable(type_table, pos_table)
  12.  
  13. startTime = input.time(title="Start Filter", defval=timestamp("01 Jan 2018 19:30 +0000"), group="Time Filter", tooltip="Start date & time to begin searching for setups")
  14. endTime = input.time(title="End Filter", defval=timestamp("1 Jan 2099 19:30 +0000"), group="Time Filter", tooltip="End date & time to stop searching for setups")
  15. dateFilter(int st, int et) => time >= st and time <= et
  16. // #1
  17. g_stc ="Schaff Trend Cycle"
  18. EEEEEE = input(13, 'Length',group = g_stc)
  19. BBBB = input(31, 'FastLength',group = g_stc)
  20. BBBBB = input(70, 'SlowLength',group = g_stc)
  21.  
  22. AAAA(BBB, BBBB, BBBBB) =>
  23. fastMA = ta.ema(BBB, BBBB)
  24. slowMA = ta.ema(BBB, BBBBB)
  25. AAAA = fastMA - slowMA
  26. AAAA
  27.  
  28. AAAAA(EEEEEE, BBBB, BBBBB) =>
  29. AAA = 0.5
  30. var CCCCC = 0.0
  31. var DDD = 0.0
  32. var DDDDDD = 0.0
  33. var EEEEE = 0.0
  34. BBBBBB = AAAA(close, BBBB, BBBBB)
  35. CCC = ta.lowest(BBBBBB, EEEEEE)
  36. CCCC = ta.highest(BBBBBB, EEEEEE) - CCC
  37. CCCCC := CCCC > 0 ? (BBBBBB - CCC) / CCCC * 100 : nz(CCCCC[1])
  38. DDD := na(DDD[1]) ? CCCCC : DDD[1] + AAA * (CCCCC - DDD[1])
  39. DDDD = ta.lowest(DDD, EEEEEE)
  40. DDDDD = ta.highest(DDD, EEEEEE) - DDDD
  41. DDDDDD := DDDDD > 0 ? (DDD - DDDD) / DDDDD * 100 : nz(DDDDDD[1])
  42. EEEEE := na(EEEEE[1]) ? DDDDDD : EEEEE[1] + AAA * (DDDDDD - EEEEE[1])
  43. EEEEE
  44.  
  45. mAAAAA = AAAAA(EEEEEE, BBBB, BBBBB)
  46.  
  47. //LONG
  48. STClong1 = (mAAAAA > mAAAAA[1])
  49. //STClong2 = ta.crossover(mAAAAA,mAAAAA[1])
  50.  
  51. //SHORT
  52. STCshort1 = (mAAAAA < mAAAAA[1])
  53. //STCshort2 = ta.crossunder(mAAAAA,mAAAAA[1])
  54.  
  55. // #2 RWI
  56. length = input.int(title="Length", defval=32, minval=1,group = "RWI")
  57.  
  58. rwiHigh = (high - nz(low[length])) / (ta.atr(length) * math.sqrt(length))
  59. rwiLow = (nz(high[length]) - low) / (ta.atr(length) * math.sqrt(length))
  60.  
  61. bullCO= ta.crossover(rwiHigh,rwiLow)
  62. shortCU = ta.crossunder(rwiHigh,rwiLow)
  63. rwiLong = rwiHigh > rwiLow
  64. rwiShort = rwiLow > rwiHigh
  65.  
  66. // FILTERING #3 Trend Step - Trailing
  67. g_ts = "Trend Step - Trailing "
  68. matype = input.string("WMA", title="MA Type", options=["WMA"],group = g_ts)
  69. len = input.int(53, minval=2, title='Length',group = g_ts)
  70. Step = input.int(50, minval=0, title='Step Size [Ticks]',group = g_ts) * syminfo.mintick // The syminfo.mintick variable returns the minimum tick value for the instrument that the script calculates on (TradingView, n.d.). That value is the instrumentโ€™s smallest possible price movement. We can use the syminfo.mintick variable in indicator (study) and strategy scripts.
  71.  
  72.  
  73. ma(type)=>
  74. float ma = switch type
  75. "WMA" => ta.wma(close, len)
  76. // Default
  77. => ta.sma(close, len)
  78.  
  79.  
  80. set_ma = ma(matype)
  81. varip MA = close
  82. if set_ma > MA + Step
  83. MA := set_ma
  84. MA
  85. else if set_ma < MA - Step
  86. MA := set_ma
  87. MA
  88.  
  89. stepLong1 = set_ma[1]<set_ma
  90. stepShort1 = set_ma[1]>set_ma
  91. stepLong2 = ta.crossover(set_ma,set_ma[1])
  92. stepShort2 =ta.crossunder(set_ma,set_ma[1])
  93.  
  94. //#4 QSTICK
  95. Length = input.int(61, minval=1,group = "QSTICK")
  96. xR = close - open
  97. xQstick = ta.sma(xR, Length)
  98.  
  99.  
  100. qLong2 = ta.crossover(xQstick,0)
  101. qLong1 = xQstick > 0
  102.  
  103. qShort1 = ta.crossunder(xQstick,0)
  104. qShort2 = xQstick < 0
  105.  
  106. // #5 DECYCLER
  107.  
  108. g_d = "Decycler"
  109. highpassLength = input.int(title="Highpass Period", defval=50,group =g_d )
  110. srcd = input(title="Source", defval=close,group = g_d)
  111.  
  112. PI = 2 * math.asin(1)
  113.  
  114. // High-pass Filter
  115. alphaArg = 2 * PI / (highpassLength * math.sqrt(2))
  116.  
  117. alpha = 0.0
  118. alpha := math.cos(alphaArg) != 0
  119. ? (math.cos(alphaArg) + math.sin(alphaArg) - 1) / math.cos(alphaArg)
  120. : nz(alpha[1])
  121.  
  122. hp = 0.0
  123. hp := math.pow(1 - (alpha / 2), 2) * (srcd - 2 * nz(srcd[1]) + nz(srcd[2])) + 2 * (1 - alpha) * nz(hp[1]) - math.pow(1 - alpha, 2) * nz(hp[2])
  124.  
  125. decycler = srcd - hp
  126.  
  127. decLong = decycler >= decycler[1]
  128. decShort = decycler < decycler[1]
  129. //#6 ARSI
  130. lengthr = input.int(title="RSI LENGTH", defval=135,group = "RSI")
  131. alphar = 2 * math.abs(ta.rsi(close, lengthr) / 100 - 0.5)
  132. arsi = 0.0
  133. arsi := alphar * close + (1 - alphar) * nz(arsi[1])
  134. aRSIlong = arsi > arsi[1]
  135. aRSIshort = arsi <= arsi[1]
  136. //#7 DMI
  137. lenD = input.int(14, minval=1, title="DI Length")
  138. lensig = input.int(14, title="ADX Smoothing", minval=1, maxval=50)
  139.  
  140. up = ta.change(high)
  141. down = -ta.change(low)
  142. plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
  143. minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
  144. trur = ta.rma(ta.tr, lenD)
  145. plus = fixnan(100 * ta.rma(plusDM, lenD) / trur)
  146. minus = fixnan(100 * ta.rma(minusDM, lenD) / trur)
  147. sum = plus + minus
  148. adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)
  149. diLong = plus >= minus
  150. diShort = plus < minus
  151. //ENTER
  152. longEn = (STClong1 and rwiLong and aRSIlong ) or (decLong and rwiLong)
  153. shortEn = (STCshort1 and rwiShort and stepShort1 and aRSIshort) or (stepShort2 and qShort2)
  154.  
  155.  
  156. //
  157.  
  158. var color barColor = color.rgb(180, 180, 180)
  159.  
  160. //ENTER
  161. if longEn and dateFilter(startTime,endTime)
  162. strategy.entry("Long",strategy.long)
  163. barColor := #2DD204
  164. if shortEn and dateFilter(startTime,endTime)
  165. strategy.entry("Short",strategy.short)
  166. barColor := #D2042D
  167.  
  168. //Monitoring trades
  169. plot(STClong1 ? 100 : STCshort1 ? 98 : 99,color = color.purple,linewidth = 2,title = "STC")
  170. plot(rwiLong ? 97 : rwiShort ? 95 : 96,color = color.yellow,linewidth = 2,title = "RWI")
  171. plot(stepLong2 ? 94 : stepShort2 ? 92 : 93,color = color.blue,linewidth = 2,title = "TREND STEP")
  172. plot(qLong1 ? 91 : qShort2 ? 89 : 91,color = color.green,linewidth = 2,title = "QSTICK")
  173. plot(decLong ? 88 : decShort ? 86 : 87,color = color.orange,linewidth = 2,title = "Decycler")
  174.  
  175. //plotcandle(open,high,low,close, color = barColor, bordercolor = barColor, wickcolor = barColor)
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