Advertisement
NKactive

NEO MACD FAST LENGTH BTC

Nov 17th, 2023
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 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. // Based on code provided by NEO
  4. //@version=5
  5.  
  6. strategy("NEO MACD FAST LENGTH BTC", overlay=false, initial_capital=1000, 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. //MACD
  18. // ****************************************************************************************************************************************************************
  19.  
  20. // Inputs
  21. FastLength = input(title="MACD Fast Length", group="MACD", defval=44)
  22. Slowlength = input(title="MACD Slow Length", group="MACD", defval=95)
  23. MACDLength = input(title="MACD Signal Length", group="MACD", defval=28)
  24. thresholdMACD = input.int(title="MACD Threshold", group="MACD", defval=0)
  25. timeframe=input.timeframe(defval ='1D', group = "MACD", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
  26.  
  27. MACD = request.security(syminfo.tickerid,timeframe , ta.ema(close, FastLength)) - request.security(syminfo.tickerid,timeframe , ta.ema(close, Slowlength))
  28. aMACD = request.security(syminfo.tickerid,timeframe , ta.ema(MACD, MACDLength))
  29. delta = MACD - aMACD
  30.  
  31. // Testing plots
  32. //plot(MACD, color = color.blue)
  33. //plot(aMACD, color = color.red)
  34. plot(thresholdMACD, color = color.gray)
  35. plot(delta, color = color.green)
  36.  
  37. // Calculate Buy/Sell orders intermittently
  38. //LongMACD = ta.crossover(delta, thresholdMACD)
  39. //ShortMACD = ta.crossunder(delta, thresholdMACD)
  40.  
  41. // Calculate Buy/Sell orders intermittently
  42. LongMACD = delta > thresholdMACD ? true : false
  43. ShortMACD = delta < thresholdMACD ? true : false
  44.  
  45.  
  46. // ****************************************************************************************************************************************************************
  47. // Call combine signals and execute buy/sell positions within timeframe
  48. //.****************************************************************************************************************************************************************
  49. // Date Range To Include
  50. startDate = timestamp("2018-01-01T00:00")
  51. endDate = time
  52. // Check if the current timestamp is within the restricted range
  53. inRestrictedRange = time >= startDate and time <= endDate
  54. //
  55. // Buy Signals on overbought and oversold
  56. //
  57. if inRestrictedRange and LongMACD// ADD OTHER BUY SIGNAL BOOLS
  58. strategy.entry("My Long Entry Id", strategy.long, 100)
  59. if inRestrictedRange and ShortMACD // ADD OTHER BUY SIGNAL BOOLS
  60. strategy.entry ("My Short Entry Id", strategy.short, 100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement