Advertisement
NKactive

Untitled

Nov 9th, 2023
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 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. //@version=5
  4.  
  5. strategy("NK RSI++ ", overlay=false, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, pyramiding=0, slippage=1)
  6. // Credit for original indicator to LazyBear
  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. lengthRSI = input(25)
  19. lengthROC = input(25)
  20. src = close
  21. overbought = input(0)
  22. oversold = input(0)
  23.  
  24. fastMACDLength = input(10)
  25. slowMACDLength = input(21)
  26. lengthCCI = input(50)
  27.  
  28. lengthStoch = input(14)
  29. smoothK = input(3)
  30.  
  31. macd(source, fastLength, slowLength) =>
  32. fastMA = ta.ema(source, fastLength)
  33. slowMA = ta.ema(source, slowLength)
  34. fastMA - slowMA
  35.  
  36. acc = (ta.rsi(src, lengthRSI) + ta.roc(src, lengthROC) + macd(src, fastMACDLength, slowMACDLength) + ta.cci(src, lengthCCI) + ta.sma(ta.stoch(close, high, low, lengthStoch), smoothK)) / 5.0
  37.  
  38. acc_ob = acc > overbought
  39. acc_os = acc < oversold
  40. plot(acc, color=acc_ob ? color.red : acc_os ? color.green : color.white, linewidth=1)
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48. // ****************************************************************************************************************************************************************
  49.  
  50.  
  51.  
  52.  
  53. // ****************************************************************************************************************************************************************
  54. // Call combine signals and execute buy/sell positions within timeframe
  55. //.****************************************************************************************************************************************************************
  56. // Date Range To Include
  57. startDate = timestamp("2018-01-01T00:00")
  58. endDate = time
  59. // Check if the current timestamp is within the restricted range
  60. inRestrictedRange = time >= startDate and time <= endDate
  61. //
  62. // Buy Signals on overbought and oversold
  63. //
  64. if inRestrictedRange and acc_os// ADD OTHER BUY SIGNAL BOOLS
  65. strategy.entry("My Long Entry Id", strategy.long, 100)
  66. if inRestrictedRange and acc_ob // ADD OTHER BUY SIGNAL BOOLS
  67. strategy.entry("My Short Entry Id", strategy.short, 100)
  68.  
  69.  
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement