Advertisement
NKactive

alter_mann Elder Ray Index BTC

Nov 17th, 2023
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 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 and alter_man
  3. //@version=5
  4.  
  5. strategy("alter_mann Elder Ray Index BTC", overlay=false, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, pyramiding=0, slippage=1)
  6.  
  7. import EliCobra/CobraMetrics/4 as cobra
  8. //// PLOT DATA
  9. 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 = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  10. 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 = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  11. type_table = input.string("None", "Table Type", options = ["Full", "Simple", "None"], group = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  12. plot(cobra.curve(disp_ind))
  13. cobra.cobraTable(type_table, pos_table)
  14. //
  15. // ****************************************************************************************************************************************************************
  16. // Elder Ray Index
  17. // ****************************************************************************************************************************************************************
  18.  
  19. // Inputs
  20. timeframe=input.timeframe(defval ='4D', group = "Elder Ray", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
  21. erLength = input(22, "ER Length", group = "Elder Ray")
  22. erSmooth = input(false, "Smooth ER", group = "Elder Ray")
  23. bullLimit = input(0, "Bull Limit", group = "Elder Ray", tooltip = "Increase to need more bulls to buy")
  24. bearLimit = input(0, "ER Length", group = "Elder Ray", tooltip = "decrease to need more bears to sell")
  25.  
  26.  
  27. // Request close from alternate timeframe
  28. altClose = request.security(syminfo.tickerid, timeframe, close)
  29. altHigh = request.security(syminfo.tickerid, timeframe, high)
  30. altLow = request.security(syminfo.tickerid, timeframe, low)
  31.  
  32. // Calculation
  33.  
  34. bullPower = erSmooth ? ta.ema(altHigh - ta.highest(altClose, erLength), erLength) : altHigh - ta.highest(altClose, erLength)
  35. bearPower = erSmooth ? ta.ema(altLow - ta.lowest(altClose, erLength), erLength) : altLow - ta.lowest(altClose, erLength)
  36.  
  37. bullBear = (bullPower+bearPower)/2
  38.  
  39. // Strategy logic
  40. //longElder = bullPower > 0
  41. //shortElder = bearPower < 0
  42.  
  43. //longElder = bullPower < bearPower
  44. //shortElder = bullPower > bearPower
  45.  
  46. longElder = bullBear >= bullLimit
  47. shortElder = bullBear < bearLimit
  48.  
  49.  
  50. // Plotting
  51. plot(bullPower, "Bull Power", color.green)
  52. plot(bearPower, "Bear Power", color.red)
  53. plot(bullBear, color=color.yellow)
  54. plot(0, color=color.gray)
  55.  
  56. // Use this code to select alternative timeframes
  57. // Get high and low from selected timeframe instead of the one on the chart
  58. // =request.security(syminfo.tickerid,timeframe , high)
  59.  
  60.  
  61.  
  62. // ****************************************************************************************************************************************************************
  63. // Call combine signals and execute buy/sell positions within timeframe
  64. //.****************************************************************************************************************************************************************
  65. // Date Range To Include
  66. startDate = timestamp("2018-01-01T00:00")
  67. endDate = time
  68. // Check if the current timestamp is within the restricted range
  69. inRestrictedRange = time >= startDate and time <= endDate
  70. //
  71. // Buy Signals on overbought and oversold
  72. //
  73. if inRestrictedRange and longElder // ADD OTHER BUY SIGNAL BOOLS
  74. strategy.entry("My Long Entry Id", strategy.long, 100)
  75. if inRestrictedRange and shortElder// ADD OTHER BUY SIGNAL BOOLS
  76. strategy.entry("My Short Entry Id", strategy.short, 100)
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement