Advertisement
danucante

Untitled

Oct 29th, 2023
115
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. plotshape(ta.crossover(EMA1, EMA2), size=size.small, color=EMA1_Color)
  17. plotshape(ta.crossunder(EMA1, EMA2), size=size.small, color=EMA2_Color)
  18.  
  19. longCondition = ta.crossover(EMA1, EMA2)
  20. shortCondition = ta.crossunder(EMA1, EMA2)
  21.  
  22. if (longCondition)
  23. strategy.entry("My EMA Long Entry", strategy.long)
  24. else if (shortCondition)
  25. strategy.entry("My EMA Short Entry", strategy.short)
  26.  
  27. import EliCobra/CobraMetrics/4 as cobra
  28.  
  29. //// PLOT DATA
  30.  
  31. 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="🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  32. 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="🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  33. type_table = input.string("None", "Table Type", options=["Full", "Simple", "None"], group="🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
  34.  
  35. plot(cobra.curve(disp_ind))
  36. cobra.cobraTable(type_table, pos_table)
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement