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 source from NEO
- //@version=5
- strategy("NEO RTI BTC", overlay=false, initial_capital=10000, 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)
- //
- // ****************************************************************************************************************************************************************
- // RTI
- // ****************************************************************************************************************************************************************
- // Inputs
- timeframeRTI = input.timeframe(defval ='1D', group = "RTI", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
- trend_data_count = input.int(113, step=4, minval=10, title="Trend Length", inline = "RTI", group="RTI")
- trend_sensitivity_percentage = input.int(95, step=1,minval=50, maxval=98,title='Sensitivity', inline = "RTI", group="RTI")
- ThreshholdRTI = input.int(50, step=1, group="RTI")
- // Calculation
- upper_trend = request.security(syminfo.tickerid,timeframeRTI,close) + request.security(syminfo.tickerid,timeframeRTI,ta.stdev(close, 2))
- lower_trend = request.security(syminfo.tickerid,timeframeRTI,close) - request.security(syminfo.tickerid,timeframeRTI,ta.stdev(close, 2))
- upper_array = array.new<float>(0)
- lower_array = array.new<float>(0)
- for i = 0 to trend_data_count - 1
- upper_array.push(upper_trend[i])
- lower_array.push(lower_trend[i])
- upper_array.sort()
- lower_array.sort()
- upper_index = math.round(trend_sensitivity_percentage / 100 * trend_data_count) - 1
- lower_index = math.round((100 - trend_sensitivity_percentage) / 100 * trend_data_count) - 1
- UpperTrend = upper_array.get(upper_index)
- LowerTrend = lower_array.get(lower_index)
- RelativeTrendIndex = ((request.security(syminfo.tickerid,timeframeRTI,close) - LowerTrend) / (UpperTrend - LowerTrend))*100
- // Plots
- plot (ThreshholdRTI, color = color.gray)
- plot (RelativeTrendIndex, color = color.yellow)
- // Intermittenat Signal
- // RTIlong = ta.crossover(RelativeTrendIndex, 50)
- // RTIshort = ta.crossunder(RelativeTrendIndex, 50)
- // Constant Signal
- RTIlong = RelativeTrendIndex > ThreshholdRTI
- RTIshort = RelativeTrendIndex < ThreshholdRTI
- // ****************************************************************************************************************************************************************
- // 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
- //
- if inRestrictedRange and RTIlong // ADD OTHER BUY SIGNAL BOOLS
- strategy.entry("My Long Entry Id", strategy.long, 100)
- if inRestrictedRange and RTIshort // ADD OTHER BUY SIGNAL BOOLS
- strategy.entry("My Short Entry Id", strategy.short, 100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement