Advertisement
NKactive

STRATEGY TEMPLATE

Nov 20th, 2023 (edited)
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 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 (replace with your name)
  3. // Original template from NKactive
  4. // (credit other original code writers)
  5. //@version=5
  6.  
  7. //strategy(" STRATEGY TEMPLATE ", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, pyramiding=0, slippage=1)
  8.  
  9. import EliCobra/CobraMetrics/4 as cobra
  10. //// PLOT DATA
  11. 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 = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  12. 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 = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  13. type_table = input.string("None", "Table Type", options = ["Full", "Simple", "None"], group = "🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  14. plot(cobra.curve(disp_ind))
  15. cobra.cobraTable(type_table, pos_table)
  16. //
  17. //***********************************************************************************************************************
  18. // NAMEOFSTRAT
  19. // ************************************************************************************************************************
  20. // Inputs
  21.  
  22. // Calculations
  23.  
  24. // Plots
  25. //*************************************************************************************************************************
  26. // Call combine signals and execute buy/sell positions within timeframe
  27. //.************************************************************************************************************************// Set Buy/Sell Condition
  28.  
  29. goLong = false // add your conditions here or nothing fires
  30. goShort = false // add your conditions here or nothing fires
  31.  
  32. // Date Range To Include
  33. startDate = timestamp("2018-01-01T00:00")
  34. endDate = time
  35. // Check if the current timestamp is within the restricted range
  36. inRestrictedRange = time >= startDate and time <= endDate
  37. //
  38. // Buy Signals on overbought and oversold
  39. //
  40. if inRestrictedRange and goLong
  41. strategy.entry("My Long Entry Id", strategy.long, 100)
  42. if inRestrictedRange and goShort
  43. strategy.entry("My Short Entry Id", strategy.short, 100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement