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 and alter_man
- //@version=5
- strategy("alter_mann Elder Ray Index 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)
- //
- // ****************************************************************************************************************************************************************
- // Elder Ray Index
- // ****************************************************************************************************************************************************************
- // Inputs
- timeframe=input.timeframe(defval ='4D', group = "Elder Ray", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
- erLength = input(22, "ER Length", group = "Elder Ray")
- erSmooth = input(false, "Smooth ER", group = "Elder Ray")
- bullLimit = input(0, "Bull Limit", group = "Elder Ray", tooltip = "Increase to need more bulls to buy")
- bearLimit = input(0, "ER Length", group = "Elder Ray", tooltip = "decrease to need more bears to sell")
- // Request close from alternate timeframe
- altClose = request.security(syminfo.tickerid, timeframe, close)
- altHigh = request.security(syminfo.tickerid, timeframe, high)
- altLow = request.security(syminfo.tickerid, timeframe, low)
- // Calculation
- bullPower = erSmooth ? ta.ema(altHigh - ta.highest(altClose, erLength), erLength) : altHigh - ta.highest(altClose, erLength)
- bearPower = erSmooth ? ta.ema(altLow - ta.lowest(altClose, erLength), erLength) : altLow - ta.lowest(altClose, erLength)
- bullBear = (bullPower+bearPower)/2
- // Strategy logic
- //longElder = bullPower > 0
- //shortElder = bearPower < 0
- //longElder = bullPower < bearPower
- //shortElder = bullPower > bearPower
- longElder = bullBear >= bullLimit
- shortElder = bullBear < bearLimit
- // Plotting
- plot(bullPower, "Bull Power", color.green)
- plot(bearPower, "Bear Power", color.red)
- plot(bullBear, color=color.yellow)
- plot(0, color=color.gray)
- // Use this code to select alternative timeframes
- // Get high and low from selected timeframe instead of the one on the chart
- // =request.security(syminfo.tickerid,timeframe , high)
- // ****************************************************************************************************************************************************************
- // 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 longElder // ADD OTHER BUY SIGNAL BOOLS
- strategy.entry("My Long Entry Id", strategy.long, 100)
- if inRestrictedRange and shortElder// ADD OTHER BUY SIGNAL BOOLS
- strategy.entry("My Short Entry Id", strategy.short, 100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement