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 LazyBear
- //@version=5
- strategy("NKCoralTrendBTC", overlay=true, 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)
- //
- // ****************************************************************************************************************************************************************
- // Coral Trend
- // ****************************************************************************************************************************************************************
- //
- // Inputs
- sm =input(21, title="Smoothing Period", group = "CoralTrend")
- cd = input(0.6, title="Constant D", group = "CoralTrend")
- ribm=input(false, title="Ribbon Mode", group = "CoralTrend")
- timeframe=input.timeframe(defval ='1D', group = "CoralTrend")
- //initialise vars
- var float i1 = na
- var float i2 = na
- var float i3 = na
- var float i4 = na
- var float i5 = na
- var float i6 = na
- src=request.security(syminfo.tickerid,timeframe, close)
- di = (sm - 1.0) / 2.0 + 1.0
- c1 = 2 / (di + 1.0)
- c2 = 1 - c1
- c3 = 3.0 * (cd * cd + cd * cd * cd)
- c4 = -3.0 * (2.0 * cd * cd + cd + cd * cd * cd)
- c5 = 3.0 * cd + 1.0 + cd * cd * cd + 3.0 * cd * cd
- i1 := c1*src + c2*nz(i1[1])
- i2 := c1*i1 + c2*nz(i2[1])
- i3 := c1*i2 + c2*nz(i3[1])
- i4 := c1*i3 + c2*nz(i4[1])
- i5 := c1*i4 + c2*nz(i5[1])
- i6 := c1*i5 + c2*nz(i6[1])
- bfr = -cd*cd*cd*i6 + c3*(i5) + c4*(i4) + c5*(i3)
- CoralLong = bfr > nz(bfr[1])?true:false
- CoralShort = bfr < nz(bfr[1])?true:false
- // --------------------------------------------------------------------------
- // Plots arrows above/below price to show whene it fires
- // --------------------------------------------------------------------------
- plotshape(series=ribm ? na : (CoralLong ? bfr : na), title="Trend Up", style=shape.triangleup, location=location.belowbar,color=color.green)
- plotshape(series=ribm ? na : (CoralShort ? bfr : na), title="Trend Down", style=shape.triangledown, location=location.abovebar, color=color.red)
- //
- CoralLong := request.security(syminfo.tickerid,timeframe, CoralLong)
- CoralShort := request.security(syminfo.tickerid,timeframe,CoralShort)
- //
- // ****************************************************************************************************************************************************************
- // 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 CoralLong // ADD OTHER BUY SIGNAL BOOLS
- strategy.entry("My Long Entry Id", strategy.long, 100)
- if inRestrictedRange and CoralShort // ADD OTHER BUY SIGNAL BOOLS
- strategy.entry("My Short Entry Id", strategy.short, 100)
Advertisement
Comments
-
- download all types of premium tradingview indicators codes available on telegram - https://t.me/tradingview_premium_indicator
Add Comment
Please, Sign In to add comment
Advertisement