Advertisement
NKactive

NEO Aroon BTC

Nov 17th, 2023
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.69 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 Neo
  4. // With timeframe
  5. //@version=5
  6.  
  7. strategy("NEO Aroon BTC", overlay=false, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, pyramiding=0, slippage=1)
  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. //Aroon Code
  18. // ****************************************************************************************************************************************************************
  19.  
  20. // Inputs
  21. timeframe=input.timeframe(defval ='3D', group = "Aroon", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
  22. aroonlength = input.int(13, "Aroon UP", group = "Aroon")
  23. lowerlength = input.int(18,"Aroon Down", group = "Aroon")
  24. aroonup = input.int(8, "AroonUP lvl", group = "Aroon")
  25. aroondn = input.int(23,"AroonDN lvl", group = "Aroon")
  26. smoothing1 = input.int(23, "Smooths Oscilator1", group = "Aroon")
  27. smoothing2 = input.int(75, "Smooths Oscilator", group = "Aroon")
  28.  
  29. // Get high and low from selected timeframe instead of the one on the chart
  30. TFHighBars=request.security(syminfo.tickerid,timeframe , high)
  31. TFLowBars=request.security(syminfo.tickerid,timeframe , low)
  32.  
  33. //Calculation
  34. upper = 100 * (ta.highestbars(TFHighBars, aroonlength+1) + aroonlength)/aroonlength
  35. lower = 100 * (ta.lowestbars(TFLowBars, lowerlength+1) + lowerlength)/lowerlength
  36. oscillator1 = upper - lower
  37. oscillator = ta.ema(oscillator1, smoothing1)
  38.  
  39. // ****************************************************************************************************************************************************************
  40. // Trading Condition
  41. // ****************************************************************************************************************************************************************
  42. aroonLong = false
  43. aroonShort = false
  44.  
  45. if upper > aroonup and lower < aroondn
  46. aroonLong := false
  47. aroonShort := false
  48. else
  49. aroonLong := upper > aroonup
  50. aroonShort := lower < aroondn and oscillator < smoothing2
  51. //
  52. // ****************************************************************************************************************************************************************
  53. // Plots
  54. // ****************************************************************************************************************************************************************
  55. //
  56. plot(upper, color=color.green, title = "upper")
  57. plot(lower, color=color.red, title = "lower")
  58. plot(aroonup, color=color.gray, title = "aroonup")
  59. plot(aroondn, color=color.gray, title = "aroondn")
  60. plot(smoothing2, color=color.blue, title="smoothing2")
  61. plot(oscillator, color=color.yellow, title = "oscillator")
  62. plot(oscillator1, color=color.orange, title = "oscillator1")
  63. plot(smoothing1, color=color.gray, title = "smoothing1")
  64.  
  65. //
  66. // ****************************************************************************************************************************************************************
  67. // Call combine signals and execute buy/sell positions within timeframe
  68. //.****************************************************************************************************************************************************************
  69. // Date Range To Include
  70. startDate = timestamp("2018-01-01T00:00")
  71. endDate = time
  72. // Check if the current timestamp is within the restricted range
  73. inRestrictedRange = time >= startDate and time <= endDate
  74. //
  75. // Buy Signals on overbought and oversold
  76. //
  77. if inRestrictedRange and aroonLong // ADD OTHER BUY SIGNAL BOOLS
  78. strategy.entry("My Long Entry Id", strategy.long, 100)
  79. if inRestrictedRange and aroonShort // ADD OTHER BUY SIGNAL BOOLS
  80. strategy.entry("My Short Entry Id", strategy.short, 100)
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement