Advertisement
NKactive

Untitled

Aug 3rd, 2023
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 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.  
  4. //@version=5
  5. strategy(title='[SHK] Schaff Trend Cycle (STC)', shorttitle='STC', overlay=false)
  6.  
  7. //Library
  8. import EliCobra/CobraMetrics/4 as cobra
  9. //// PConstruct Cobra Table
  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. EEEEEE = input(12, 'Length')
  17. BBBB = input(26, 'FastLength')
  18. BBBBB = input(50, 'SlowLength')
  19.  
  20. AAAA(BBB, BBBB, BBBBB) =>
  21. fastMA = ta.ema(BBB, BBBB)
  22. slowMA = ta.ema(BBB, BBBBB)
  23. AAAA = fastMA - slowMA
  24. AAAA
  25.  
  26. AAAAA(EEEEEE, BBBB, BBBBB) =>
  27. AAA = input(0.5)
  28. var CCCCC = 0.0
  29. var DDD = 0.0
  30. var DDDDDD = 0.0
  31. var EEEEE = 0.0
  32. BBBBBB = AAAA(close, BBBB, BBBBB)
  33. CCC = ta.lowest(BBBBBB, EEEEEE)
  34. CCCC = ta.highest(BBBBBB, EEEEEE) - CCC
  35. CCCCC := CCCC > 0 ? (BBBBBB - CCC) / CCCC * 100 : nz(CCCCC[1])
  36. DDD := na(DDD[1]) ? CCCCC : DDD[1] + AAA * (CCCCC - DDD[1])
  37. DDDD = ta.lowest(DDD, EEEEEE)
  38. DDDDD = ta.highest(DDD, EEEEEE) - DDDD
  39. DDDDDD := DDDDD > 0 ? (DDD - DDDD) / DDDDD * 100 : nz(DDDDDD[1])
  40. EEEEE := na(EEEEE[1]) ? DDDDDD : EEEEE[1] + AAA * (DDDDDD - EEEEE[1])
  41. EEEEE
  42.  
  43. mAAAAA = AAAAA(EEEEEE, BBBB, BBBBB)
  44. mColor = mAAAAA > mAAAAA[1] ? color.new(color.green, 20) : color.new(color.red, 20)
  45.  
  46. // logic NK.active for buy and sell
  47. BuySignal = mAAAAA >= mAAAAA[1]
  48. SellSignal = mAAAAA < mAAAAA[1]
  49.  
  50. if mAAAAA[3] <= mAAAAA[2] and mAAAAA[2] > mAAAAA[1] and mAAAAA > 75
  51. alert("Red", alert.freq_once_per_bar)
  52. if mAAAAA[3] >= mAAAAA[2] and mAAAAA[2] < mAAAAA[1] and mAAAAA < 25
  53. alert("Green", alert.freq_once_per_bar)
  54.  
  55.  
  56. plot(mAAAAA, color=mColor, title='STC', linewidth=2)
  57.  
  58. ul = plot(25, color=color.new(color.gray, 70))
  59. ll = plot(75, color=color.new(color.gray, 70))
  60. fill(ul, ll, color=color.new(color.gray, 90))
  61.  
  62.  
  63. if BuySignal
  64. strategy.entry("My Long Entry Id", strategy.long)
  65. if SellSignal
  66. strategy.entry("My Long Entry Id", strategy.short)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement