Advertisement
danucante

Untitled

Nov 25th, 2023
237
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.40 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. // © Coff3eG
  3.  
  4.  
  5. //@version=5
  6. strategy(title='painn', shorttitle='painn', overlay=false,
  7. pyramiding = 0,
  8. initial_capital = 10000000000000000,
  9. default_qty_value = 100,
  10. default_qty_type = "percent_of_equity",calc_on_every_tick = true, process_orders_on_close = true,slippage = 0)//
  11.  
  12. import TradingView/ta/5
  13. import IllllIIIIIIIllllIIIIIllll/AlphaDragonTA/2 as dragon_lib
  14.  
  15. // Date
  16. start_date = input.int(title='Start Date', defval=1, minval=1, maxval=31, group='Date Range', inline='1')
  17. end_date = input.int(title='End Date', defval=1, minval=1, maxval=31, group='Date Range', inline='1')
  18. start_month = input.int(title='Start Month', defval=1, minval=1, maxval=12, group='Date Range', inline='2')
  19. end_month = input.int(title='End Month', defval=1, minval=1, maxval=12, group='Date Range', inline='2')
  20. start_year = input.int(title='Start Year', defval=2018, minval=1800, maxval=3000, group='Date Range', inline='3')
  21. end_year = input.int(title='End Year', defval=2099, minval=1800, maxval=3000, group='Date Range', inline='3')
  22. in_date_range = time >= timestamp(syminfo.timezone, start_year, start_month, start_date, 0, 0) and
  23. time < timestamp(syminfo.timezone, end_year, end_month, end_date, 0, 0)
  24.  
  25.  
  26. // Non-Repainting function
  27. res = input.timeframe(title='Timeframe NoRepainting', defval='D')
  28.  
  29. // Create non-repainting security function
  30. rp_security(_symbol, _res, _src) =>
  31. request.security(_symbol, _res, _src[barstate.isrealtime ? 1 : 0])
  32.  
  33. // Get HTF (high time frame) price data
  34. htfHigh = rp_security(syminfo.tickerid, res, high)
  35. htfLow = rp_security(syminfo.tickerid, res, low)
  36.  
  37. //// TRUNCATE FUNCTION
  38. truncate(number, decimals) =>
  39. factor = math.pow(10, decimals)
  40. int(number * factor) / factor
  41.  
  42.  
  43. // STC
  44. EEEEEE = input(39, 'LengthSTC', group="STC")
  45. BBBB = input(51, 'FastLengthSTC', group="STC")
  46. BBBBB = input(685, 'SlowLengthSTC', group="STC")
  47. AAA = input.float(0.57, title="STC Factor", group="STC", step = 0.01)
  48.  
  49. AAAA(BBB, BBBB, BBBBB) =>
  50. fastMA = ta.ema(BBB, BBBB)
  51. slowMA = ta.ema(BBB, BBBBB)
  52. AAAA = fastMA - slowMA
  53. AAAA
  54.  
  55. AAAAA(EEEEEE, BBBB, BBBBB) =>
  56. var CCCCC = 0.0
  57. var DDD = 0.0
  58. var DDDDDD = 0.0
  59. var EEEEE = 0.0
  60. BBBBBB = AAAA(close, BBBB, BBBBB)
  61. CCC = ta.lowest(BBBBBB, EEEEEE)
  62. CCCC = ta.highest(BBBBBB, EEEEEE) - CCC
  63. CCCCC := CCCC > 0 ? (BBBBBB - CCC) / CCCC * 100 : nz(CCCCC[1])
  64. DDD := na(DDD[1]) ? CCCCC : DDD[1] + AAA * (CCCCC - DDD[1])
  65. DDDD = ta.lowest(DDD, EEEEEE)
  66. DDDDD = ta.highest(DDD, EEEEEE) - DDDD
  67. DDDDDD := DDDDD > 0 ? (DDD - DDDD) / DDDDD * 100 : nz(DDDDDD[1])
  68. EEEEE := na(EEEEE[1]) ? DDDDDD : EEEEE[1] + AAA * (DDDDDD - EEEEE[1])
  69. EEEEE
  70.  
  71. mAAAAA = AAAAA(EEEEEE, BBBB, BBBBB)
  72. mColor = mAAAAA > mAAAAA[1] ? color.new(color.green, 20) : color.new(color.red, 20)
  73.  
  74. fastMA = ta.ema(close, BBBB)
  75. slowMA = ta.ema(close, BBBBB)
  76.  
  77. stc_low = mAAAAA < 50
  78. stc_high = mAAAAA > 50
  79. stc_long = mAAAAA > mAAAAA[1]
  80. stc_short = mAAAAA < mAAAAA[1]
  81.  
  82.  
  83. // idk wtf is gg on here but AlphaDragon helped me out here to plot some shit
  84. stc_value = dragon_lib.stc_v2(close, EEEEEE, BBBB, BBBBB)
  85.  
  86. [diff_power, diff_power_color, diff_close_value, diff_close_color] = dragon_lib.source_comparition(fastMA, slowMA)
  87.  
  88. // plot_my_plot = input.bool(true,"plot it NOW")
  89.  
  90. // plot(plot_my_plot ? diff_power : na, "diff_power", color = diff_power_color )
  91.  
  92. // Filtering shit
  93. some_ma_len = input.int(200)
  94. crazy_ma_filter = dragon_lib.butterworth_filter(close,some_ma_len)
  95.  
  96.  
  97. // Old STC Short
  98. short1 = stc_short and stc_high and diff_power >= -1
  99.  
  100. // STC Long and Short conditions
  101. stclong1 = stc_long and stc_low
  102. stcshort2 = short1 and close > crazy_ma_filter
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116. fastLength = input(title='MACD Fast Length', defval=9)
  117. slowLength = input(title='MACD Slow Length', defval=34)
  118. cycleLength = input(title='Cycle Length', defval=11)
  119. d1Length = input(title='1st %D Length', defval=1)
  120. d2Length = input(title='2nd %D Length', defval=4)
  121. src = close
  122. upper1 = 75
  123. lower1 = 25
  124.  
  125. macd = ta.ema(src, fastLength) - ta.ema(src, slowLength)
  126. k = nz(fixnan(ta.stoch(macd, macd, macd, cycleLength)))
  127. d1 = ta.ema(k, d1Length)
  128. kd = nz(fixnan(ta.stoch(d1, d1, d1, cycleLength)))
  129. stc = ta.ema(kd, d2Length)
  130. stc := math.max(math.min(stc, 100), 0)
  131.  
  132.  
  133. buySignal = ta.crossover(stc, lower1)
  134. sellSignal = ta.crossunder(stc, upper1)
  135.  
  136.  
  137.  
  138. LONGMSG = ""
  139. SHORTMSG = ""
  140.  
  141. if stclong1
  142. LONGMSG += 'stclong1, '
  143.  
  144.  
  145. if stcshort2
  146. SHORTMSG += 'stcshort2, '
  147.  
  148. if buySignal
  149. LONGMSG+="NEOSTC"
  150.  
  151. if sellSignal
  152. SHORTMSG+="NEOSTC"
  153.  
  154.  
  155.  
  156.  
  157.  
  158. src12= input.source(hlcc4, group= 'rsi')
  159. rsiLength= input.int(17, group= 'rsi')
  160. rsi = ta.rsi(src12, rsiLength)
  161.  
  162. ysell= input.int(61)
  163. ybuy= input.int(54)
  164.  
  165. longRSI = rsi > ybuy
  166. shortRSI = rsi < ysell
  167.  
  168.  
  169.  
  170. // MACD Strategy
  171. fastLength12 = input(28, group="MACD")
  172. slowlength = input(274, group="MACD")
  173. MACDLength = input(23, group="MACD")
  174. MACD = ta.ema(close, fastLength12) - ta.ema(close, slowlength)
  175. aMACD = ta.ema(MACD, MACDLength)
  176. delta = MACD - aMACD
  177. macdLong = ta.crossover(delta, 0)
  178. macdShort = ta.crossunder(delta, 0)
  179.  
  180. if macdLong
  181. LONGMSG += "MACD "
  182. if macdShort
  183. SHORTMSG += "MACD "
  184. //plot(delta, title="Histogram", style=plot.style_columns, color=(delta>=0 ? (delta[1] < delta ? #26A69A : #B2DFDB) : (delta[1] < delta ? #FFCDD2 : #FF5252)))
  185.  
  186. // DMI
  187. lensig = input.int(55, title="ADX Smoothing", minval=1, group="DMI")
  188. len = input.int(40, minval=1, title="DI Length", group="DMI")
  189. up = ta.change(high)
  190. down = -ta.change(low)
  191. plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
  192. minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
  193. trur = ta.rma(ta.tr, len)
  194. plus = fixnan(100 * ta.rma(plusDM, len) / trur)
  195. minus = fixnan(100 * ta.rma(minusDM, len) / trur)
  196. sum = plus + minus
  197. adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)
  198. dmiLong = (ta.crossover(plus, minus) or minus > 30) and adx > minus
  199. dmiShort = (ta.crossover(minus, plus) or plus > 30) and adx > plus
  200.  
  201. if dmiLong
  202. LONGMSG += "DMI "
  203. if dmiShort
  204. SHORTMSG += "DMI "
  205.  
  206. // plot(plus, color=color.green, title="+DI")
  207. // plot(minus, color=color.red, title="-DI")
  208. // plot(adx, color=color.orange, title="ADX")
  209. // hlineup = hline(30, color=#787B86)
  210.  
  211. // Aroon
  212. aroonLength = input.int(134, minval=1, title="Aroon Length", group="Aroon")
  213. upper12 = 100 * (ta.highestbars(high, aroonLength+1) + aroonLength)/aroonLength
  214. lower12 = 100 * (ta.lowestbars(low, aroonLength+1) + aroonLength)/aroonLength
  215. lengthx = input.int(title="Length LSMA", defval=10, group="Aroon")
  216. offset = 0
  217. lsma = ta.linreg(close, lengthx, offset)
  218. aroonLong = ta.crossover(upper12,lower12) and close > lsma
  219. aroonShort = ta.crossunder(upper12,lower12) and close < lsma
  220.  
  221. if aroonLong
  222. LONGMSG += "AROON "
  223. if aroonShort
  224. SHORTMSG += "AROON "
  225. //longConditions = (stclong1 and supertrendLong) or (longRSI and buySignal)
  226. //shortConditions = sellSignal and shortRSI
  227. longConditions = macdLong or (buySignal and longRSI) or dmiLong or aroonLong
  228. shortConditions = macdShort or (sellSignal and shortRSI)or dmiShort or aroonShort
  229.  
  230.  
  231. // longConditions = GunzoLong2
  232. // shortConditions = GunzoShort1
  233.  
  234.  
  235.  
  236.  
  237.  
  238. if in_date_range and barstate.isconfirmed
  239. if longConditions
  240. strategy.entry('Long', strategy.long, comment = LONGMSG)
  241. if shortConditions
  242. strategy.entry('Short', strategy.short, comment = SHORTMSG)
  243.  
  244.  
  245.  
  246.  
  247.  
  248. // ======================================================
  249. // Cobra Table
  250. // ======================================================
  251. import EliCobra/CobraMetrics/4 as cobra
  252.  
  253. // PLOT DATA
  254. 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 = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  255. pos_table = input.string("Middle Right", "Table Position", options = ["Top Left", "Middle Left", "Bottom Left", "Top Right", "Middle Right", "Bottom Right", "Top Center", "Bottom Center"], group = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  256. type_table = input.string("Full", "Table Type", options = ["Full", "Simple", "None"], group = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  257. plot(cobra.curve(disp_ind))
  258. cobra.cobraTable(type_table, pos_table)
  259. //
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