Advertisement
NKactive

Jackomate Gussian MA BTC

Nov 17th, 2023
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 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 JACKOMATE
  3. // Original source from LeafAlgo
  4. //@version=5
  5.  
  6. strategy("Jackomate Gussian MA BTC", overlay=true, 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. //**
  18. // JACKOMATE GUASSIAN MOVING AVERAGE
  19. //
  20.  
  21. //inputs
  22. length = input.int(14, minval=1, title="Length",group="Gaussian")
  23. adaptive = input.bool(true, title="Adaptive Parameters",group="Gaussian")
  24. volatilityPeriod = input.int(20, minval=1, title="Volatility Period",group="Gaussian")
  25. timeframe=input.timeframe(defval ='1D', group = "Gaussian", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
  26.  
  27. // Calculate Gaussian Moving Average
  28. gma = 0.0
  29. sumOfWeights = 0.0
  30. sigma = adaptive ? ta.stdev(close, volatilityPeriod) : input.float(1.0, minval=0.1, title="Standard Deviation")
  31.  
  32. for i = 0 to length - 1
  33. weight = math.exp(-math.pow(((i - (length - 1)) / (2 * sigma)), 2) / 2)
  34. value = ta.highest(close, i + 1) + ta.lowest(close, i + 1)
  35. gma := gma + (value * weight)
  36. sumOfWeights := sumOfWeights + weight
  37.  
  38. gma := (gma / sumOfWeights) / 2
  39.  
  40. // Plots
  41. gmaColor = close >= gma ? color.lime : color.fuchsia
  42. plot(gma, color=gmaColor, linewidth=2, title="Gaussian Moving Average")
  43. barcolor(gmaColor)
  44.  
  45. // explaination of buy/sell calculation
  46. // if close >=gms
  47. // then gausBuy is true
  48. // else gausBuy is false
  49. gausBuy = close >=gma ? true : false
  50. gausSell = close < gma ? true : false
  51.  
  52. // Call combine signals and execute buy/sell positions within timeframe
  53. //.****************************************************************************************************************************************************************
  54. // Date Range To Include
  55. startDate = timestamp("2018-01-01T00:00")
  56. endDate = time
  57. // Check if the current timestamp is within the restricted range
  58. inRestrictedRange = time >= startDate and time <= endDate
  59. //
  60. // Buy Signals on overbought and oversold
  61. //
  62. if inRestrictedRange and gausBuy // ADD OTHER BUY SIGNAL BOOLS
  63. strategy.entry("My Long Entry Id", strategy.long, 100)
  64. if inRestrictedRange and gausSell // ADD OTHER BUY SIGNAL BOOLS
  65. strategy.entry("My Short Entry Id", strategy.short, 100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement