Advertisement
NKactive

Specialist VR

Nov 10th, 2023 (edited)
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 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 source from Specialist
  4. //@version=5
  5.  
  6. strategy("Specialist VR ", overlay=false, initial_capital=10000, 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. // Inputs
  20. timeframeVR=input.timeframe(defval ='4D', group = "VR", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
  21. volatilityLower = input.float(title = "Lower Range", defval= -39, group = "VR")
  22. volatilityHigher = input.float(title = "Higher Range", defval= 9, group="VR")
  23. volatilityLength = input.int(defval = 58, title = "VR Length", group="VR")
  24.  
  25. // VR
  26. volatilityRange = request.security(syminfo.tickerid,timeframeVR, ta.sma(close - open, volatilityLength))
  27.  
  28. //PLOT VR
  29. plot(volatilityRange, color=color.yellow)
  30. plot(volatilityHigher, color=color.gray)
  31. plot(volatilityLower, color=color.gray)
  32.  
  33. //VR PARAMETERS
  34. longVR = volatilityRange > volatilityHigher
  35. shortVR = volatilityRange < volatilityLower
  36.  
  37. // ****************************************************************************************************************************************************************
  38. // Call combine signals and execute buy/sell positions within timeframe
  39. //.****************************************************************************************************************************************************************
  40. // Date Range To Include
  41. startDate = timestamp("2018-01-01T00:00")
  42. endDate = time
  43. // Check if the current timestamp is within the restricted range
  44. inRestrictedRange = time >= startDate and time <= endDate
  45. //
  46. // Buy Signals on overbought and oversold
  47. //
  48. if inRestrictedRange and longVR// ADD OTHER BUY SIGNAL BOOLS
  49. strategy.entry("My Long Entry Id", strategy.long, 100)
  50. if inRestrictedRange and shortVR // ADD OTHER BUY SIGNAL BOOLS
  51. strategy.entry("My Short Entry Id", strategy.short, 100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement