Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- strategy("Second BTC", initial_capital=1000000, slippage=1, default_qty_value=100, pyramiding=0, default_qty_type=strategy.percent_of_equity,shorttitle = "2nd BTC Strat", process_orders_on_close=true, overlay=true)
- //DATE RANGE
- useDateFilter = input.bool(true, title="Range of Backtest", group="Backtest")
- backtestStartDate = input.time(timestamp("1 Jan 2018"), title="Start Date", group="Backtest Time Period")
- //Range Conditions
- inDateRange = not useDateFilter or (time >= backtestStartDate)
- //COBRA TABLE
- import EliCobra/CobraMetrics/4 as cobra
- disp_ind = input.string("Equity", 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 Right", "Table Position", options=["Top Left", "Middle Left", "Bottom Left", "Top Right", "Middle Right", "Bottom Right", "Top Center", "Bottom Center"], group="🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
- type_table = input.string("Full", "Table Type", options=["Full", "Simple", "None"], group="🐍 𝓒𝓸𝓫𝓻𝓪 𝓜𝓮𝓽𝓻𝓲𝓬𝓼 🐍")
- plot(cobra.curve(disp_ind))
- cobra.cobraTable(type_table, pos_table)
- import TradingView/ta/7 as ta
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- /// vii`dema supertrend
- subject = input.int (8, minval = 2 , group="Supertrend")
- mul = input.float(2, "Factor", step=0.05,group="Supertrend")
- demalen = input.int (11, "dema", group="Supertrend")
- dema = ta.dema(hlc3, demalen)
- vii_supertrend(mul, atrPeriod) =>
- src = dema
- atr = ta.atr(atrPeriod)
- u = src + mul * atr
- l = src - mul * atr
- pl = nz(l[1])
- pu = nz(u[1])
- l := l > pl or close[1] < pl ? l : pl
- u := u < pu or close[1] > pu ? u : pu
- int d = na
- float st = na
- pt = st[1]
- if na(atr[1])
- d := 1
- else if pt == pu
- d := close > u ? -1 : 1
- else
- d := close < l ? 1 : -1
- st := d == -1 ? l : u
- [st, d]
- [x, d] = vii_supertrend(mul, subject)
- L = d < 0
- S = d > 0
- var vii = 0
- if L and not S
- vii := 1
- if S
- vii := -1
- plot(dema, "x", color = vii == 1 ? color.rgb(0, 255, 187) : vii == -1 ? color.rgb(255, 0, 157) : color.gray, linewidth = 2)
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- // vii`DSMA
- len_sma = input.int(58, group = "DSMA")
- len_dsma = input.int(2, group = "DSMA")
- s = ta.sma(high, len_sma)
- ss = ta.sma(s, len_dsma)
- en_l = input.source(high, group = "entry")
- en_s = input.source(low, group = "entry")
- dsmal = en_l > ss
- dsmas = en_s < ss
- L2 = dsmal
- S2 = dsmas
- var vii2 = 0
- if L2 and not S2
- vii2 := 1
- if S2
- vii2 := -1
- plot(ta.hma(close, 45), "x", color = vii2 == 1 ? color.rgb(0, 255, 187) : vii2 == -1 ? color.rgb(255, 0, 157) : color.gray, linewidth = 2)
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- long_condition = L
- short_condition = S2
- if long_condition and inDateRange and barstate.isconfirmed
- strategy.entry("Long", strategy.long)
- if short_condition and inDateRange and barstate.isconfirmed
- strategy.entry("Short", strategy.short)
Advertisement