Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- 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)
- len1 = input.int(14)
- len2 = input.int(28)
- src = close
- EMA1 = ta.ema(src, len1)
- EMA2 = ta.ema(src, len2)
- EMA1_Color = color.new(color.orange, 30)
- EMA2_Color = color.new(color.purple, 30)
- plot(EMA1, color=EMA1_Color)
- plot(EMA2, color=EMA2_Color)
- var bool longCondition = false
- var bool shortCondition = false
- if ta.crossover(EMA1, EMA2)
- longCondition := true
- else if ta.crossunder(EMA1, EMA2)
- shortCondition := true
- if longCondition
- strategy.entry("My EMA Long Entry", strategy.long)
- longCondition := false
- if shortCondition
- strategy.entry("My EMA Short Entry", strategy.short)
- shortCondition := false
- import EliCobra/CobraMetrics/4 as cobra
- //// PLOT DATA
- 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="🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
- 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="🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
- type_table = input.string("None", "Table Type", options=["Full", "Simple", "None"], group="🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
- plot(cobra.curve(disp_ind))
- cobra.cobraTable(type_table, pos_table)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement