Guest User

Untitled

a guest
Aug 2nd, 2024
147
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. //@version=5
  2. strategy("Second BTC", initial_capital=1000000, slippage=1, default_qty_value=100, pyramiding=0, default_qty_type=strategy.percent_of_equity,shorttitle = "2nd BTC Strat", process_orders_on_close=true, overlay=true)
  3.  
  4. //DATE RANGE
  5. useDateFilter = input.bool(true, title="Range of Backtest", group="Backtest")
  6. backtestStartDate = input.time(timestamp("1 Jan 2018"), title="Start Date", group="Backtest Time Period")
  7.  
  8. //Range Conditions
  9. inDateRange = not useDateFilter or (time >= backtestStartDate)
  10.  
  11. //COBRA TABLE
  12. import EliCobra/CobraMetrics/4 as cobra
  13. 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="🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  14. 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="🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  15. type_table = input.string("Full", "Table Type", options=["Full", "Simple", "None"], group="🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  16. plot(cobra.curve(disp_ind))
  17. cobra.cobraTable(type_table, pos_table)
  18.  
  19. import TradingView/ta/7 as ta
  20.  
  21.  
  22. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  23.  
  24. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  25.  
  26. /// vii`dema supertrend
  27. subject = input.int (8, minval = 2 , group="Supertrend")
  28. mul = input.float(2, "Factor", step=0.05,group="Supertrend")
  29. demalen = input.int (11, "dema", group="Supertrend")
  30. dema = ta.dema(hlc3, demalen)
  31.  
  32. vii_supertrend(mul, atrPeriod) =>
  33. src = dema
  34. atr = ta.atr(atrPeriod)
  35. u = src + mul * atr
  36. l = src - mul * atr
  37. pl = nz(l[1])
  38. pu = nz(u[1])
  39.  
  40. l := l > pl or close[1] < pl ? l : pl
  41. u := u < pu or close[1] > pu ? u : pu
  42. int d = na
  43. float st = na
  44. pt = st[1]
  45. if na(atr[1])
  46. d := 1
  47. else if pt == pu
  48. d := close > u ? -1 : 1
  49. else
  50. d := close < l ? 1 : -1
  51. st := d == -1 ? l : u
  52. [st, d]
  53.  
  54. [x, d] = vii_supertrend(mul, subject)
  55.  
  56. L = d < 0
  57. S = d > 0
  58.  
  59. var vii = 0
  60.  
  61. if L and not S
  62. vii := 1
  63.  
  64. if S
  65. vii := -1
  66.  
  67. plot(dema, "x", color = vii == 1 ? color.rgb(0, 255, 187) : vii == -1 ? color.rgb(255, 0, 157) : color.gray, linewidth = 2)
  68.  
  69. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  70. // vii`DSMA
  71. len_sma = input.int(58, group = "DSMA")
  72. len_dsma = input.int(2, group = "DSMA")
  73. s = ta.sma(high, len_sma)
  74. ss = ta.sma(s, len_dsma)
  75.  
  76. en_l = input.source(high, group = "entry")
  77. en_s = input.source(low, group = "entry")
  78.  
  79. dsmal = en_l > ss
  80. dsmas = en_s < ss
  81.  
  82. L2 = dsmal
  83. S2 = dsmas
  84.  
  85. var vii2 = 0
  86.  
  87. if L2 and not S2
  88. vii2 := 1
  89.  
  90. if S2
  91. vii2 := -1
  92.  
  93. plot(ta.hma(close, 45), "x", color = vii2 == 1 ? color.rgb(0, 255, 187) : vii2 == -1 ? color.rgb(255, 0, 157) : color.gray, linewidth = 2)
  94. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  95.  
  96.  
  97. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  98. long_condition = L
  99. short_condition = S2
  100. if long_condition and inDateRange and barstate.isconfirmed
  101. strategy.entry("Long", strategy.long)
  102. if short_condition and inDateRange and barstate.isconfirmed
  103. strategy.entry("Short", strategy.short)
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