Advertisement
danucante

Untitled

Oct 29th, 2023
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. //@version=5
  2. strategy(title="Exponential Moving Average", shorttitle="EMA", overlay=false, margin_long=100, margin_short=100, initial_capital=10000, default_qty_type=strategy.percent_of_equity, pyramiding=0, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.3, slippage=1, calc_on_every_tick=true, calc_on_order_fills=true)
  3.  
  4. len1 = input.int(14)
  5. len2 = input.int(28)
  6. src = close
  7. EMA1 = ta.ema(src, len1)
  8. EMA2 = ta.ema(src, len2)
  9.  
  10. EMA1_Color = color.new(color.orange, 30)
  11. EMA2_Color = color.new(color.purple, 30)
  12.  
  13. plot(EMA1, color=EMA1_Color)
  14. plot(EMA2, color=EMA2_Color)
  15.  
  16. var bool longCondition = false
  17. var bool shortCondition = false
  18.  
  19. if ta.crossover(EMA1, EMA2)
  20. longCondition := true
  21. else if ta.crossunder(EMA1, EMA2)
  22. shortCondition := true
  23.  
  24. if longCondition
  25. strategy.entry("My EMA Long Entry", strategy.long)
  26. longCondition := false
  27.  
  28. if shortCondition
  29. strategy.entry("My EMA Short Entry", strategy.short)
  30. shortCondition := false
  31.  
  32. import EliCobra/CobraMetrics/4 as cobra
  33.  
  34. //// PLOT DATA
  35.  
  36. 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="🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  37. 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="🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  38. type_table = input.string("None", "Table Type", options=["Full", "Simple", "None"], group="🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  39.  
  40. plot(cobra.curve(disp_ind))
  41. cobra.cobraTable(type_table, pos_table)
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement