Advertisement
NKactive

NEO RTI BTC

Nov 17th, 2023
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.04 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 NEO
  4. //@version=5
  5.  
  6. strategy("NEO RTI BTC", 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. // RTI
  18. // ****************************************************************************************************************************************************************
  19.  
  20. // Inputs
  21. timeframeRTI = input.timeframe(defval ='1D', group = "RTI", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
  22. trend_data_count = input.int(113, step=4, minval=10, title="Trend Length", inline = "RTI", group="RTI")
  23. trend_sensitivity_percentage = input.int(95, step=1,minval=50, maxval=98,title='Sensitivity', inline = "RTI", group="RTI")
  24. ThreshholdRTI = input.int(50, step=1, group="RTI")
  25.  
  26. // Calculation
  27. upper_trend = request.security(syminfo.tickerid,timeframeRTI,close) + request.security(syminfo.tickerid,timeframeRTI,ta.stdev(close, 2))
  28. lower_trend = request.security(syminfo.tickerid,timeframeRTI,close) - request.security(syminfo.tickerid,timeframeRTI,ta.stdev(close, 2))
  29.  
  30. upper_array = array.new<float>(0)
  31. lower_array = array.new<float>(0)
  32. for i = 0 to trend_data_count - 1
  33. upper_array.push(upper_trend[i])
  34. lower_array.push(lower_trend[i])
  35. upper_array.sort()
  36. lower_array.sort()
  37.  
  38. upper_index = math.round(trend_sensitivity_percentage / 100 * trend_data_count) - 1
  39. lower_index = math.round((100 - trend_sensitivity_percentage) / 100 * trend_data_count) - 1
  40. UpperTrend = upper_array.get(upper_index)
  41. LowerTrend = lower_array.get(lower_index)
  42. RelativeTrendIndex = ((request.security(syminfo.tickerid,timeframeRTI,close) - LowerTrend) / (UpperTrend - LowerTrend))*100
  43.  
  44. // Plots
  45. plot (ThreshholdRTI, color = color.gray)
  46. plot (RelativeTrendIndex, color = color.yellow)
  47.  
  48. // Intermittenat Signal
  49. // RTIlong = ta.crossover(RelativeTrendIndex, 50)
  50. // RTIshort = ta.crossunder(RelativeTrendIndex, 50)
  51.  
  52. // Constant Signal
  53. RTIlong = RelativeTrendIndex > ThreshholdRTI
  54. RTIshort = RelativeTrendIndex < ThreshholdRTI
  55.  
  56. // ****************************************************************************************************************************************************************
  57. // Call combine signals and execute buy/sell positions within timeframe
  58. //.****************************************************************************************************************************************************************
  59. // Date Range To Include
  60. startDate = timestamp("2018-01-01T00:00")
  61. endDate = time
  62. // Check if the current timestamp is within the restricted range
  63. inRestrictedRange = time >= startDate and time <= endDate
  64. //
  65. // Buy Signals
  66. //
  67. if inRestrictedRange and RTIlong // ADD OTHER BUY SIGNAL BOOLS
  68. strategy.entry("My Long Entry Id", strategy.long, 100)
  69. if inRestrictedRange and RTIshort // ADD OTHER BUY SIGNAL BOOLS
  70. strategy.entry("My Short Entry Id", strategy.short, 100)
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement