Advertisement
NKactive

Specialist VZO BTC

Nov 17th, 2023
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.35 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. // © NKactive
  3. // Original code from Specialist
  4. //@version=5
  5.  
  6. strategy("Specialist VZO BTC", overlay=false, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, pyramiding=0, slippage=1)
  7.  
  8. import EliCobra/CobraMetrics/4 as cobra
  9. //// PLOT DATA
  10. 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 = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  11. 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 = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  12. type_table = input.string("None", "Table Type", options = ["Full", "Simple", "None"], group = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  13. plot(cobra.curve(disp_ind))
  14. cobra.cobraTable(type_table, pos_table)
  15. //
  16. // ****************************************************************************************************************************************************************
  17. //
  18.  
  19. //VZO
  20. // inputs
  21. src0 = input.source(high, 'Source', group="VZO")
  22. len = input.float(17.25, 'VZO Length', minval=1, step=0.5, group="VZO")
  23. flen = input.float(4, 'Fisher Length', minval=1, step=0.5, group="VZO")
  24. ud = input.int(12, 'Updown val', group="VZO")
  25. var VZO_Intraday = input.bool(true, 'Smoothing', group="VZO")
  26. var repaint = input.bool(false, 'Allow Repainting', group="VZO")
  27. timeframe=input.timeframe(defval ='1D', group="VZO", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
  28.  
  29. // Sauce
  30. get_close = request.security(syminfo.tickerid,timeframe , close[repaint ? 0 : 1])
  31. get_vol = request.security(syminfo.tickerid,timeframe , volume[repaint ? 0 : 1])
  32. sym = syminfo.tickerid
  33. VZO(length, get_close, vol) =>
  34. Volume_Direction = get_close > get_close[3] ? vol : -vol
  35. VZO_volume = request.security(syminfo.tickerid,timeframe , ta.linreg(Volume_Direction, int(length), 0))
  36. Total_volume = request.security(syminfo.tickerid,timeframe , ta.linreg(vol, int(length), 0))
  37. 100 * VZO_volume / Total_volume
  38.  
  39. VZO_ = VZO(len, get_close, get_vol)
  40. if VZO_Intraday
  41. VZO_ := ta.ema(VZO_, 9)
  42.  
  43. // Fish
  44. fsrc = VZO_
  45. MaxH = request.security(syminfo.tickerid,timeframe , ta.highest(fsrc, int(flen)))
  46. MinL = request.security(syminfo.tickerid,timeframe , ta.lowest(fsrc, int(flen)))
  47. var nValue1 = 0.0
  48. var nFish = 0.0
  49. nValue1 := 0.33 * 2 * ((fsrc - MinL) / (MaxH - MinL) - 0.5) + 0.67 * nz(nValue1[1])
  50. nValue2 = (nValue1 > 0.99 ? 0.999 : (nValue1 < -0.99 ? -0.999 : nValue1))
  51. nFish := 0.5 * math.log((1 + nValue2) / (1 - nValue2)) + 0.5 * nz(nFish[1])
  52. f1 = nFish
  53. f2 = nz(nFish[1])
  54. stat = 0
  55. fzvzo_up = f1 > f2
  56. fzvzo_down = f1 < f2
  57. // Can use stat or fzvzoshort and fzvzoshort for firing buy/sell signals
  58. fzvzoshort = request.security(syminfo.tickerid,timeframe , ta.crossunder(f1, f2))
  59. fzvzolong = request.security(syminfo.tickerid,timeframe , ta.crossover(f1, f2))
  60. if fzvzolong
  61. stat := 1
  62. if fzvzoshort
  63. stat := -1
  64.  
  65. //PLOT
  66. plot(f1, color=color.blue) // blue over yellow -1
  67. plot(f2, color=color.yellow) // yellow over blue 1
  68. plot(stat, color=color.green) // this is 1, 0 or -1 when you get a crossover
  69.  
  70. // ****************************************************************************************************************************************************************
  71. // Call combine signals and execute buy/sell positions within timeframe
  72. //.****************************************************************************************************************************************************************
  73. // Date Range To Include
  74. startDate = timestamp("2018-01-01T00:00")
  75. endDate = time
  76. // Check if the current timestamp is within the restricted range
  77. inRestrictedRange = time >= startDate and time <= endDate
  78. //
  79. // Buy Signals on overbought and oversold
  80. //
  81. if inRestrictedRange and fzvzo_up// ADD OTHER BUY SIGNAL BOOLS
  82. strategy.entry("My Long Entry Id", strategy.long, 100)
  83. if inRestrictedRange and fzvzo_down // ADD OTHER BUY SIGNAL BOOLS
  84. strategy.entry("My Short Entry Id", strategy.short, 100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement