Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- strategy("THE MATRIX KILLER2", overlay=true, pyramiding = 0, slippage = 1, initial_capital = 100, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)
- // Plot Cobra Metrics Table
- import EliCobra/CobraMetrics/4 as cobra
- disp_ind = input.string ("Equity" , 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("Bottom Right", "Table Position", options = ["Top Left", "Middle Left", "Bottom Left", "Top Right", "Middle Right", "Bottom Right", "Top Center", "Bottom Center"], group = "๐ ๐๐ธ๐ซ๐ป๐ช ๐๐ฎ๐ฝ๐ป๐ฒ๐ฌ๐ผ ๐")
- type_table = input.string("Full", "Table Type", options = ["Full", "Simple", "None"], group = "๐ ๐๐ธ๐ซ๐ป๐ช ๐๐ฎ๐ฝ๐ป๐ฒ๐ฌ๐ผ ๐")
- plot(cobra.curve(disp_ind))
- cobra.cobraTable(type_table, pos_table)
- // Time Range
- startTime = input.time(defval = timestamp("01 January 2018"), title = "Start Date")
- isInTimeRange = time >= startTime
- // rsi
- rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
- rsiSourceInput = input.source(close, group="RSI Settings")
- uprsi = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
- downrsi = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
- rsi = downrsi == 0 ? 100 : uprsi == 0 ? 0 : 100 - (100 / (1 + uprsi / downrsi))
- rsi2 = ta.rsi(close, 21)
- RSI_long = rsi2 > 50
- RSI_short = rsi2 < 50
- // RSI_long = ta.crossover(rsi2, 50)
- // RSI_short = ta.crossunder(rsi2, 50)
- // ***************************************************************************************************************************************************************
- // VR
- volatilityLower = input.float(title = "Lower Range", defval= -39, group = "VRG")
- volatilityHigher = input.float(title = "Higher Range", defval= 9)
- volatilityLength = 58
- volatilityRange = ta.sma(close - open, volatilityLength)
- //VR PARAMETERS
- VRL = volatilityRange > volatilityLower
- VRS = volatilityRange < volatilityHigher
- // Inputs
- timeframeAlgo=input.timeframe(defval ='1D', group = "Algo", tooltip = "Select a different timeframe for this series") // Use Alternative timeframe
- sensitivity = input.float(2.5, "โโSensitivity (0.5 - 10)", 0.5, 10, step=0.1, group = "Algo")
- emaEnergy = input.bool(true, "EMA Energy", group = "Algo")
- keltner_length = input(10, "Keltner Channel Length", group = "Algo")
- atrPeriod = input(10, "ATR Length", group = "Algo")
- factor = input.float(3.5, "Factor", step = 0.01, group = "Algo")
- // =request.security(syminfo.tickerid,timeframe, high)
- // Keltner Channel function
- keltner_channel(src, length) =>
- ma = request.security(syminfo.tickerid,timeframeAlgo,ta.sma(src, length))
- rangec = request.security(syminfo.tickerid,timeframeAlgo, high) - request.security(syminfo.tickerid,timeframeAlgo, low)
- upper = ma + rangec
- lower = ma - rangec
- [upper, lower]
- // Modified Supertrend function using Keltner Channel
- supertrend(_src, factor, atrLen, kel_length) =>
- [upperKeltner, lowerKeltner] = keltner_channel(_src, kel_length)
- rangec = upperKeltner - lowerKeltner
- upperBand = _src + factor * rangec
- lowerBand = _src - factor * rangec
- prevLowerBand = nz(lowerBand[1])
- prevUpperBand = nz(upperBand[1])
- lowerBand := lowerBand > prevLowerBand or request.security(syminfo.tickerid,timeframeAlgo,close[1]) < prevLowerBand ? lowerBand : prevLowerBand
- upperBand := upperBand < prevUpperBand or request.security(syminfo.tickerid,timeframeAlgo,close[1]) > prevUpperBand ? upperBand : prevUpperBand
- int direction = na
- float superTrend = na
- prevSuperTrend = superTrend[1]
- if na(rangec[1])
- direction := 1
- else if prevSuperTrend == prevUpperBand
- direction := close > upperBand ? -1 : 1
- else
- direction := close < lowerBand ? 1 : -1
- superTrend := direction == -1 ? lowerBand : upperBand
- [superTrend, direction]
- // Get Components
- ema1 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 9))
- ema2 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 12))
- ema3 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 15))
- ema4 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 18))
- ema5 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 21))
- ema6 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 24))
- ema7 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 27))
- ema8 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 30))
- ema9 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 33))
- ema10 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 36))
- ema11 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 39))
- ema12 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 42))
- ema13 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 45))
- ema14 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 48))
- ema15 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(high, 51))
- // Colors
- green = #2BBC4D, red = #C51D0B
- emaEnergyColor(ma) => emaEnergy ? (close >= ma ? green : red) : na
- // Plots
- plot(ema1, "", emaEnergyColor(ema1), editable=false)
- plot(ema2, "", emaEnergyColor(ema2), editable=false)
- plot(ema3, "", emaEnergyColor(ema3), editable=false)
- plot(ema4, "", emaEnergyColor(ema4), editable=false)
- plot(ema5, "", emaEnergyColor(ema5), editable=false)
- plot(ema6, "", emaEnergyColor(ema6), editable=false)
- plot(ema7, "", emaEnergyColor(ema7), editable=false)
- plot(ema8, "", emaEnergyColor(ema8), editable=false)
- plot(ema9, "", emaEnergyColor(ema9), editable=false)
- plot(ema10, "", emaEnergyColor(ema10), editable=false)
- plot(ema11, "", emaEnergyColor(ema11), editable=false)
- plot(ema12, "", emaEnergyColor(ema12), editable=false)
- plot(ema13, "", emaEnergyColor(ema13), editable=false)
- plot(ema14, "", emaEnergyColor(ema14), editable=false)
- plot(ema15, "", emaEnergyColor(ema15), editable=false)
- [supertrend, direction] = request.security(syminfo.tickerid,timeframeAlgo,supertrend(close, sensitivity, 11, keltner_length))
- bull = request.security(syminfo.tickerid,timeframeAlgo,ta.crossover(close, supertrend))
- bear = request.security(syminfo.tickerid,timeframeAlgo,ta.crossunder(close, supertrend))
- y1 = request.security(syminfo.tickerid,timeframeAlgo,low) - (ta.atr(30) * 2)
- y2 = request.security(syminfo.tickerid,timeframeAlgo,high) + (ta.atr(30) * 2)
- buy = bull ? label.new(bar_index, y1, "BUY", xloc.bar_index, yloc.price, green, label.style_label_up, color.white, size.normal) : na
- sell = bear ? label.new(bar_index, y2, "SELL", xloc.bar_index, yloc.price, red, label.style_label_down, color.white, size.normal) : na
- [supertrends, directions] = ta.supertrend(factor, atrPeriod)
- bodyMiddle = plot((open + close) / 2, display=display.none)
- // Trend Catcher Indicator (Example)
- ema100 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(close, 10))
- ema200 = request.security(syminfo.tickerid,timeframeAlgo,ta.ema(close, 20))
- trendCatcher = request.security(syminfo.tickerid,timeframeAlgo,ta.crossover(ema100, ema200)) ? 1 : request.security(syminfo.tickerid,timeframeAlgo,ta.crossunder(ema100, ema200)) ? -1 : 0
- trendColor = trendCatcher == 1 ? color.rgb(90, 23, 102) : na
- barcolor(trendColor)
- // Colored candles
- barcolor(color = close > supertrends ? color.rgb(102, 255, 0) : color.rgb(255, 0, 0))
- //alertcondition(bull, title="Buy", message="Buy!")
- //alertcondition(bear, title="Sell", message="Sell!")
- /////////
- longCondition = bull and VRL and RSI_long
- //stc ,vrl
- //stc , vrs
- shortCondition = bear and VRS and RSI_short
- if barstate.isconfirmed and isInTimeRange and longCondition
- strategy.entry("Long", strategy.long)
- if barstate.isconfirmed and isInTimeRange and shortCondition
- strategy.entry("Short", strategy.short)
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