Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- // This Pine Scriptโข code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // ยฉ rabiha_
- //23.1 dran weiterarbeiten
- import EliCobra/CobraMetrics/4 as cobra
- //// PLOT DATA
- 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("Middle 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)
- strategy(title="MACD-BB", shorttitle="MACD-BB", format=format.price, precision=2, overlay = true, initial_capital = 100000, slippage = 1,pyramiding = 0, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)
- //Time Range
- startDate = input.time(defval = timestamp( "01 january 2018 00:00:00:00"), title= "Start Date", group = "Date period")
- //Enter long position/trade conditions, MACD is Base///
- macdLong=ta.crossover(close, ta.ema(close,input.int(23)))
- macdShort=ta.crossunder(close, ta.ema(close,input.int(171)))
- ///////////////////////////////////////////
- long_condition= macdLong and BBlong
- short_condition= macdShort and BBshort
- if (long_condition and time >= startDate and barstate.isconfirmed)
- strategy.entry("MACD long", strategy.long)
- if (short_condition and time >= startDate and barstate.isconfirmed)
- strategy.entry("MACD short", strategy.short)
- /////imputs//////
- fastMACD = input.int(12, minval=1, group = "MACD", tooltip = "fastLength")
- slowMACD = input.int(26, minval=1,group = "MACD", tooltip = "slowlength")
- lenghtMACD = input.int(9, minval=1,group = "MACD", tooltip = "signal lenght")
- /////Bollinger Bands/////////
- length = input.int(20, minval=1)
- maType = input.string("SMA", "Basis MA Type", options = ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"])
- src = input(close, title="Source")
- mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev", tooltip = "StdDev")
- ma(source, length, _type) =>
- switch _type
- "SMA" => ta.sma(source, length)
- "EMA" => ta.ema(source, length)
- "SMMA (RMA)" => ta.rma(source, length)
- "WMA" => ta.wma(source, length)
- "VWMA" => ta.vwma(source, length)
- basis = ma(src, length, maType)
- dev = mult * ta.stdev(src, length)
- upper = basis + dev
- lower = basis - dev
- BBL= ta.crossover(close, upper)
- BBS= ta.crossunder(close, lower)
- BBlong= BBL and basis > basis [1]
- BBshort= BBS and basis < basis [1]
- offset = input.int(0, "Offset", minval = -500, maxval = 500)
- plot(basis, "Basis", color=#FF6D00, offset = offset)
- p1 = plot(upper, "Upper", color=#2962FF, offset = offset)
- p2 = plot(lower, "Lower", color=#2962FF, offset = offset)
- fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95))
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