Advertisement
NKactive

NEO STC

Nov 17th, 2023
96
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 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 Neo
  3. // Original source from NEO
  4. //@version=5
  5.  
  6. strategy("NEO STC", 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. // NEO STC
  18. // ****************************************************************************************************************************************************************
  19.  
  20. //Inputs
  21. timeframeSTC=input.timeframe(defval ='1D', group = "STC", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
  22. EEEEEE = input.int(defval = 13, step = 1, title = "STC Length", group = "STC")
  23. BBBB = input.int(defval = 31, step = 1, title = "STC Fast Length", group = "STC")
  24. BBBBB = input.int(defval = 70, step = 1, title = "STC Slow Length", group = "STC")
  25.  
  26. //Functions
  27. AAAA(BBB, BBBB, BBBBB) =>
  28. fastMA = ta.ema(BBB, BBBB)
  29. slowMA = ta.ema(BBB, BBBBB)
  30. AAAA = fastMA - slowMA
  31. AAAA
  32.  
  33. AAAAA(EEEEEE, BBBB, BBBBB) =>
  34. AAA = 0.5
  35. var CCCCC = 0.0
  36. var DDD = 0.0
  37. var DDDDDD = 0.0
  38. var EEEEE = 0.0
  39. BBBBBB = AAAA(close, BBBB, BBBBB)
  40. CCC = ta.lowest(BBBBBB, EEEEEE)
  41. CCCC = ta.highest(BBBBBB, EEEEEE) - CCC
  42. CCCCC := CCCC > 0 ? (BBBBBB - CCC) / CCCC * 100 : nz(CCCCC[1])
  43. DDD := na(DDD[1]) ? CCCCC : DDD[1] + AAA * (CCCCC - DDD[1])
  44. DDDD = ta.lowest(DDD, EEEEEE)
  45. DDDDD = ta.highest(DDD, EEEEEE) - DDDD
  46. DDDDDD := DDDDD > 0 ? (DDD - DDDD) / DDDDD * 100 : nz(DDDDDD[1])
  47. EEEEE := na(EEEEE[1]) ? DDDDDD : EEEEE[1] + AAA * (DDDDDD - EEEEE[1])
  48. EEEEE
  49.  
  50. // Calculation
  51. mAAAAA = AAAAA(EEEEEE, BBBB, BBBBB)
  52. mColor = mAAAAA > mAAAAA[1] ? color.new(color.green, 20) : color.new(color.red, 20)
  53.  
  54. STClong = mAAAAA > mAAAAA[1]
  55. STCshort = mAAAAA < mAAAAA[1]
  56.  
  57. longSTC = request.security(syminfo.tickerid,timeframeSTC, STClong)
  58. shortSTC = request.security(syminfo.tickerid,timeframeSTC, STCshort)
  59.  
  60. // plot
  61. plot(mAAAAA, color=color.blue)
  62. plot(mAAAAA[1], color=color.yellow)
  63.  
  64. // ****************************************************************************************************************************************************************
  65. // Call combine signals and execute buy/sell positions within timeframe
  66. //.****************************************************************************************************************************************************************
  67. // Date Range To Include
  68. startDate = timestamp("2018-01-01T00:00")
  69. endDate = time
  70. // Check if the current timestamp is within the restricted range
  71. inRestrictedRange = time >= startDate and time <= endDate
  72. //
  73. // Buy Signals on overbought and oversold
  74. //
  75. if inRestrictedRange and longSTC // ADD OTHER BUY SIGNAL BOOLS
  76. strategy.entry("My Long Entry Id", strategy.long, 100)
  77. if inRestrictedRange and shortSTC // ADD OTHER BUY SIGNAL BOOLS
  78. strategy.entry("My Short Entry Id", strategy.short, 100)
Advertisement
Comments
  • # text 0.12 KB | 0 0
    1. download all types of premium tradingview indicators codes available on telegram - https://t.me/tradingview_premium_indicator
Add Comment
Please, Sign In to add comment
Advertisement