Guest User

Untitled

a guest
Feb 17th, 2024
80
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | Cryptocurrency | 0 0
  1.  
  2. //@version=5
  3. // This Pine Scriptโ„ข code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  4. // ยฉ rabiha_
  5.  
  6. //23.1 dran weiterarbeiten
  7.  
  8. import EliCobra/CobraMetrics/4 as cobra
  9.  
  10. //// PLOT DATA
  11. 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 = "๐Ÿ ๐“’๐“ธ๐“ซ๐“ป๐“ช ๐“œ๐“ฎ๐“ฝ๐“ป๐“ฒ๐“ฌ๐“ผ ๐Ÿ")
  12. 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 = "๐Ÿ ๐“’๐“ธ๐“ซ๐“ป๐“ช ๐“œ๐“ฎ๐“ฝ๐“ป๐“ฒ๐“ฌ๐“ผ ๐Ÿ")
  13. type_table = input.string("Full", "Table Type", options = ["Full", "Simple", "None"], group = "๐Ÿ ๐“’๐“ธ๐“ซ๐“ป๐“ช ๐“œ๐“ฎ๐“ฝ๐“ป๐“ฒ๐“ฌ๐“ผ ๐Ÿ")
  14.  
  15. plot(cobra.curve(disp_ind))
  16. cobra.cobraTable(type_table, pos_table)
  17.  
  18. strategy(title="MACD-BB", shorttitle="MACD-BB", format=format.price, precision=2, overlay = true, initial_capital = 100000, slippage = 1,pyramiding = 0, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)
  19.  
  20.  
  21. //Time Range
  22. startDate = input.time(defval = timestamp( "01 january 2018 00:00:00:00"), title= "Start Date", group = "Date period")
  23. //Enter long position/trade conditions, MACD is Base///
  24.  
  25. macdLong=ta.crossover(close, ta.ema(close,input.int(23)))
  26.  
  27. macdShort=ta.crossunder(close, ta.ema(close,input.int(171)))
  28.  
  29. ///////////////////////////////////////////
  30.  
  31. long_condition= macdLong and BBlong
  32.  
  33. short_condition= macdShort and BBshort
  34.  
  35. if (long_condition and time >= startDate and barstate.isconfirmed)
  36. strategy.entry("MACD long", strategy.long)
  37.  
  38.  
  39. if (short_condition and time >= startDate and barstate.isconfirmed)
  40. strategy.entry("MACD short", strategy.short)
  41.  
  42.  
  43. /////imputs//////
  44.  
  45. fastMACD = input.int(12, minval=1, group = "MACD", tooltip = "fastLength")
  46.  
  47. slowMACD = input.int(26, minval=1,group = "MACD", tooltip = "slowlength")
  48.  
  49. lenghtMACD = input.int(9, minval=1,group = "MACD", tooltip = "signal lenght")
  50.  
  51. /////Bollinger Bands/////////
  52.  
  53. length = input.int(20, minval=1)
  54. maType = input.string("SMA", "Basis MA Type", options = ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"])
  55. src = input(close, title="Source")
  56. mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev", tooltip = "StdDev")
  57.  
  58. ma(source, length, _type) =>
  59. switch _type
  60. "SMA" => ta.sma(source, length)
  61. "EMA" => ta.ema(source, length)
  62. "SMMA (RMA)" => ta.rma(source, length)
  63. "WMA" => ta.wma(source, length)
  64. "VWMA" => ta.vwma(source, length)
  65.  
  66. basis = ma(src, length, maType)
  67. dev = mult * ta.stdev(src, length)
  68.  
  69. upper = basis + dev
  70. lower = basis - dev
  71.  
  72. BBL= ta.crossover(close, upper)
  73.  
  74. BBS= ta.crossunder(close, lower)
  75.  
  76. BBlong= BBL and basis > basis [1]
  77.  
  78. BBshort= BBS and basis < basis [1]
  79.  
  80. offset = input.int(0, "Offset", minval = -500, maxval = 500)
  81. plot(basis, "Basis", color=#FF6D00, offset = offset)
  82. p1 = plot(upper, "Upper", color=#2962FF, offset = offset)
  83. p2 = plot(lower, "Lower", color=#2962FF, offset = offset)
  84. fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95))
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