Advertisement
NKactive

Alter_mann FSVO BTC

Nov 17th, 2023
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 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. // Original code from Alter_mann
  4. //@version=5
  5.  
  6. strategy("Alter_mann FSVO BTC", overlay=true, 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. //
  18. // FSVO (Fourteen Steps Variable Offset)
  19.  
  20. // Inputs
  21. timeframe=input.timeframe(defval ='4D', group = "FSVO", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
  22. fsvoLength = input(9, title="FSVO Length", group = "FSVO")
  23. fsvoMultiplier = input.float(2.75, title="FSVO Multiplier", group = "FSVO")
  24. //buyOffset = input(0.1, "Buy Offset", group = "FSVO")
  25. //sellOffset = input(0.1, "Sell Offset", group = "FSVO")
  26.  
  27. // Calculation
  28. FsvoClose=request.security(syminfo.tickerid, timeframe, close)
  29. FsvoPastClose = request.security(syminfo.tickerid, timeframe, close)[fsvoLength]
  30. fsvo = FsvoClose - FsvoPastClose
  31. //fsvoOffset = ta.sma(fsvo, fsvoLength) * fsvoMultiplier
  32. fsvoOffset=request.security(syminfo.tickerid, timeframe, ta.sma(fsvo, fsvoLength)) * fsvoMultiplier
  33.  
  34. // Plot FSVO series
  35. plot(fsvo, color=color.red)
  36. plot(fsvoOffset, color=color.blue)
  37. //plot(buyOffset, color=color.gray)
  38. //plot(sellOffset, color=color.gray)
  39.  
  40.  
  41. // Calculate buy/sell conditions
  42. //FSVObuy = ta.crossover(fsvoOffset, buyOffset)
  43. //FSVOsell = ta.crossunder(fsvoOffset, sellOffset)
  44. FSVObuy = ta.crossunder(fsvoOffset, fsvo)
  45. FSVOsell = ta.crossover(fsvoOffset, fsvo)
  46.  
  47. //FSVObuy = close > fsvoOffset + buyOffset
  48. //FSVOsell = close < fsvoOffset - sellOffset
  49.  
  50. // ****************************************************************************************************************************************************************
  51. // Call combine signals and execute buy/sell positions within timeframe
  52. //.****************************************************************************************************************************************************************
  53. // Date Range To Include
  54. startDate = timestamp("2018-01-01T00:00")
  55. endDate = time
  56. // Check if the current timestamp is within the restricted range
  57. inRestrictedRange = time >= startDate and time <= endDate
  58. //
  59. // Buy Signals on overbought and oversold
  60. //
  61. if inRestrictedRange and FSVObuy// ADD OTHER BUY SIGNAL BOOLS
  62. strategy.entry("My Long Entry Id", strategy.long, 100)
  63. if inRestrictedRange and FSVOsell // ADD OTHER BUY SIGNAL BOOLS
  64. strategy.entry("My Short Entry Id", strategy.short, 100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement