Advertisement
NKactive

Specialist VZO ETH

Nov 10th, 2023 (edited)
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 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 ETH", 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. src0 = input.source(high, 'Source')
  21. len = input.float(28.5, 'VZO Length', minval=1, step=0.5)
  22. flen = input.float(4.0, 'Fisher Length', minval=1, step=0.5)
  23. ud = input.int(8, 'Updown val')
  24. var VZO_Intraday = input.bool(true, 'Smoothing')
  25. var repaint = input.bool(false, 'Allow Repainting')
  26. // Sauce
  27. get_close = close[repaint ? 0 : 1]
  28. get_vol = volume[repaint ? 0 : 1]
  29. sym = syminfo.tickerid
  30. VZO(length, get_close, vol) =>
  31. Volume_Direction = get_close > get_close[3] ? vol : -vol
  32. VZO_volume = ta.linreg(Volume_Direction, int(length), 0)
  33. Total_volume = ta.linreg(vol, int(length), 0)
  34. 100 * VZO_volume / Total_volume
  35.  
  36. VZO_ = VZO(len, get_close, get_vol)
  37. if VZO_Intraday
  38. VZO_ := ta.ema(VZO_, 9)
  39.  
  40. // Fish
  41. fsrc = VZO_
  42. MaxH = ta.highest(fsrc, int(flen))
  43. MinL = ta.lowest(fsrc, int(flen))
  44. var nValue1 = 0.0
  45. var nFish = 0.0
  46. nValue1 := 0.33 * 2 * ((fsrc - MinL) / (MaxH - MinL) - 0.5) + 0.67 * nz(nValue1[1])
  47. nValue2 = (nValue1 > 0.99 ? 0.999 : (nValue1 < -0.99 ? -0.999 : nValue1))
  48. nFish := 0.5 * math.log((1 + nValue2) / (1 - nValue2)) + 0.5 * nz(nFish[1])
  49. f1 = nFish
  50. f2 = nz(nFish[1])
  51. stat = 0
  52. fzvzo_up = f1 > f2
  53. fzvzo_down = f1 < f2
  54. // Can use stat or fzvzoshort and fzvzoshort for firing buy/sell signals
  55. fzvzoshort = ta.crossunder(f1, f2)
  56. fzvzolong = ta.crossover(f1, f2)
  57. if fzvzolong
  58. stat := 1
  59. if fzvzoshort
  60. stat := -1
  61.  
  62. //PLOT
  63. plot(f1, color=color.blue)
  64. plot(f2, color=color.yellow)
  65. plot(stat, color=color.green)
  66.  
  67. // ****************************************************************************************************************************************************************
  68.  
  69.  
  70.  
  71.  
  72. // ****************************************************************************************************************************************************************
  73. // Call combine signals and execute buy/sell positions within timeframe
  74. //.****************************************************************************************************************************************************************
  75. // Date Range To Include
  76. startDate = timestamp("2018-01-01T00:00")
  77. endDate = time
  78. // Check if the current timestamp is within the restricted range
  79. inRestrictedRange = time >= startDate and time <= endDate
  80. //
  81. // Buy Signals on overbought and oversold
  82. //
  83. if inRestrictedRange and fzvzo_up// ADD OTHER BUY SIGNAL BOOLS
  84. strategy.entry("My Long Entry Id", strategy.long, 100)
  85. if inRestrictedRange and fzvzo_down // ADD OTHER BUY SIGNAL BOOLS
  86. strategy.entry("My Short Entry Id", strategy.short, 100)
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement