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 Neo
- // With timeframe
- //@version=5
- strategy("NEO Aroon 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)
- //
- // ****************************************************************************************************************************************************************
- //Aroon Code
- // ****************************************************************************************************************************************************************
- // Inputs
- timeframe=input.timeframe(defval ='3D', group = "Aroon", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
- aroonlength = input.int(13, "Aroon UP", group = "Aroon")
- lowerlength = input.int(18,"Aroon Down", group = "Aroon")
- aroonup = input.int(8, "AroonUP lvl", group = "Aroon")
- aroondn = input.int(23,"AroonDN lvl", group = "Aroon")
- smoothing1 = input.int(23, "Smooths Oscilator1", group = "Aroon")
- smoothing2 = input.int(75, "Smooths Oscilator", group = "Aroon")
- // Get high and low from selected timeframe instead of the one on the chart
- TFHighBars=request.security(syminfo.tickerid,timeframe , high)
- TFLowBars=request.security(syminfo.tickerid,timeframe , low)
- //Calculation
- upper = 100 * (ta.highestbars(TFHighBars, aroonlength+1) + aroonlength)/aroonlength
- lower = 100 * (ta.lowestbars(TFLowBars, lowerlength+1) + lowerlength)/lowerlength
- oscillator1 = upper - lower
- oscillator = ta.ema(oscillator1, smoothing1)
- // ****************************************************************************************************************************************************************
- // Trading Condition
- // ****************************************************************************************************************************************************************
- aroonLong = false
- aroonShort = false
- if upper > aroonup and lower < aroondn
- aroonLong := false
- aroonShort := false
- else
- aroonLong := upper > aroonup
- aroonShort := lower < aroondn and oscillator < smoothing2
- //
- // ****************************************************************************************************************************************************************
- // Plots
- // ****************************************************************************************************************************************************************
- //
- plot(upper, color=color.green, title = "upper")
- plot(lower, color=color.red, title = "lower")
- plot(aroonup, color=color.gray, title = "aroonup")
- plot(aroondn, color=color.gray, title = "aroondn")
- plot(smoothing2, color=color.blue, title="smoothing2")
- plot(oscillator, color=color.yellow, title = "oscillator")
- plot(oscillator1, color=color.orange, title = "oscillator1")
- plot(smoothing1, color=color.gray, title = "smoothing1")
- //
- // ****************************************************************************************************************************************************************
- // 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 aroonLong // ADD OTHER BUY SIGNAL BOOLS
- strategy.entry("My Long Entry Id", strategy.long, 100)
- if inRestrictedRange and aroonShort // ADD OTHER BUY SIGNAL BOOLS
- strategy.entry("My Short Entry Id", strategy.short, 100)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement