Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © NKactive
- // Original code from Specialist
- //@version=5
- strategy("Specialist VZO BTC", overlay=false, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, pyramiding=0, slippage=1)
- 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)
- //
- // ****************************************************************************************************************************************************************
- //
- //VZO
- // inputs
- src0 = input.source(high, 'Source', group="VZO")
- len = input.float(17.25, 'VZO Length', minval=1, step=0.5, group="VZO")
- flen = input.float(4, 'Fisher Length', minval=1, step=0.5, group="VZO")
- ud = input.int(12, 'Updown val', group="VZO")
- var VZO_Intraday = input.bool(true, 'Smoothing', group="VZO")
- var repaint = input.bool(false, 'Allow Repainting', group="VZO")
- timeframe=input.timeframe(defval ='1D', group="VZO", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
- // Sauce
- get_close = request.security(syminfo.tickerid,timeframe , close[repaint ? 0 : 1])
- get_vol = request.security(syminfo.tickerid,timeframe , volume[repaint ? 0 : 1])
- sym = syminfo.tickerid
- VZO(length, get_close, vol) =>
- Volume_Direction = get_close > get_close[3] ? vol : -vol
- VZO_volume = request.security(syminfo.tickerid,timeframe , ta.linreg(Volume_Direction, int(length), 0))
- Total_volume = request.security(syminfo.tickerid,timeframe , ta.linreg(vol, int(length), 0))
- 100 * VZO_volume / Total_volume
- VZO_ = VZO(len, get_close, get_vol)
- if VZO_Intraday
- VZO_ := ta.ema(VZO_, 9)
- // Fish
- fsrc = VZO_
- MaxH = request.security(syminfo.tickerid,timeframe , ta.highest(fsrc, int(flen)))
- MinL = request.security(syminfo.tickerid,timeframe , ta.lowest(fsrc, int(flen)))
- var nValue1 = 0.0
- var nFish = 0.0
- nValue1 := 0.33 * 2 * ((fsrc - MinL) / (MaxH - MinL) - 0.5) + 0.67 * nz(nValue1[1])
- nValue2 = (nValue1 > 0.99 ? 0.999 : (nValue1 < -0.99 ? -0.999 : nValue1))
- nFish := 0.5 * math.log((1 + nValue2) / (1 - nValue2)) + 0.5 * nz(nFish[1])
- f1 = nFish
- f2 = nz(nFish[1])
- stat = 0
- fzvzo_up = f1 > f2
- fzvzo_down = f1 < f2
- // Can use stat or fzvzoshort and fzvzoshort for firing buy/sell signals
- fzvzoshort = request.security(syminfo.tickerid,timeframe , ta.crossunder(f1, f2))
- fzvzolong = request.security(syminfo.tickerid,timeframe , ta.crossover(f1, f2))
- if fzvzolong
- stat := 1
- if fzvzoshort
- stat := -1
- //PLOT
- plot(f1, color=color.blue) // blue over yellow -1
- plot(f2, color=color.yellow) // yellow over blue 1
- plot(stat, color=color.green) // this is 1, 0 or -1 when you get a crossover
- // ****************************************************************************************************************************************************************
- // Call combine signals and execute buy/sell positions within timeframe
- //.****************************************************************************************************************************************************************
- // Date Range To Include
- startDate = timestamp("2018-01-01T00:00")
- endDate = time
- // Check if the current timestamp is within the restricted range
- inRestrictedRange = time >= startDate and time <= endDate
- //
- // Buy Signals on overbought and oversold
- //
- if inRestrictedRange and fzvzo_up// ADD OTHER BUY SIGNAL BOOLS
- strategy.entry("My Long Entry Id", strategy.long, 100)
- if inRestrictedRange and fzvzo_down // ADD OTHER BUY SIGNAL BOOLS
- strategy.entry("My Short Entry Id", strategy.short, 100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement