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/
- // © Coff3eG
- //@version=5
- strategy(title='painn', shorttitle='painn', overlay=false,
- pyramiding = 0,
- initial_capital = 10000000000000000,
- default_qty_value = 100,
- default_qty_type = "percent_of_equity",calc_on_every_tick = true, process_orders_on_close = true,slippage = 0)//
- import TradingView/ta/5
- import IllllIIIIIIIllllIIIIIllll/AlphaDragonTA/2 as dragon_lib
- // Date
- start_date = input.int(title='Start Date', defval=1, minval=1, maxval=31, group='Date Range', inline='1')
- end_date = input.int(title='End Date', defval=1, minval=1, maxval=31, group='Date Range', inline='1')
- start_month = input.int(title='Start Month', defval=1, minval=1, maxval=12, group='Date Range', inline='2')
- end_month = input.int(title='End Month', defval=1, minval=1, maxval=12, group='Date Range', inline='2')
- start_year = input.int(title='Start Year', defval=2018, minval=1800, maxval=3000, group='Date Range', inline='3')
- end_year = input.int(title='End Year', defval=2099, minval=1800, maxval=3000, group='Date Range', inline='3')
- in_date_range = time >= timestamp(syminfo.timezone, start_year, start_month, start_date, 0, 0) and
- time < timestamp(syminfo.timezone, end_year, end_month, end_date, 0, 0)
- // Non-Repainting function
- res = input.timeframe(title='Timeframe NoRepainting', defval='D')
- // Create non-repainting security function
- rp_security(_symbol, _res, _src) =>
- request.security(_symbol, _res, _src[barstate.isrealtime ? 1 : 0])
- // Get HTF (high time frame) price data
- htfHigh = rp_security(syminfo.tickerid, res, high)
- htfLow = rp_security(syminfo.tickerid, res, low)
- //// TRUNCATE FUNCTION
- truncate(number, decimals) =>
- factor = math.pow(10, decimals)
- int(number * factor) / factor
- // STC
- EEEEEE = input(39, 'LengthSTC', group="STC")
- BBBB = input(51, 'FastLengthSTC', group="STC")
- BBBBB = input(685, 'SlowLengthSTC', group="STC")
- AAA = input.float(0.57, title="STC Factor", group="STC", step = 0.01)
- AAAA(BBB, BBBB, BBBBB) =>
- fastMA = ta.ema(BBB, BBBB)
- slowMA = ta.ema(BBB, BBBBB)
- AAAA = fastMA - slowMA
- AAAA
- AAAAA(EEEEEE, BBBB, BBBBB) =>
- var CCCCC = 0.0
- var DDD = 0.0
- var DDDDDD = 0.0
- var EEEEE = 0.0
- BBBBBB = AAAA(close, BBBB, BBBBB)
- CCC = ta.lowest(BBBBBB, EEEEEE)
- CCCC = ta.highest(BBBBBB, EEEEEE) - CCC
- CCCCC := CCCC > 0 ? (BBBBBB - CCC) / CCCC * 100 : nz(CCCCC[1])
- DDD := na(DDD[1]) ? CCCCC : DDD[1] + AAA * (CCCCC - DDD[1])
- DDDD = ta.lowest(DDD, EEEEEE)
- DDDDD = ta.highest(DDD, EEEEEE) - DDDD
- DDDDDD := DDDDD > 0 ? (DDD - DDDD) / DDDDD * 100 : nz(DDDDDD[1])
- EEEEE := na(EEEEE[1]) ? DDDDDD : EEEEE[1] + AAA * (DDDDDD - EEEEE[1])
- EEEEE
- mAAAAA = AAAAA(EEEEEE, BBBB, BBBBB)
- mColor = mAAAAA > mAAAAA[1] ? color.new(color.green, 20) : color.new(color.red, 20)
- fastMA = ta.ema(close, BBBB)
- slowMA = ta.ema(close, BBBBB)
- stc_low = mAAAAA < 50
- stc_high = mAAAAA > 50
- stc_long = mAAAAA > mAAAAA[1]
- stc_short = mAAAAA < mAAAAA[1]
- // idk wtf is gg on here but AlphaDragon helped me out here to plot some shit
- stc_value = dragon_lib.stc_v2(close, EEEEEE, BBBB, BBBBB)
- [diff_power, diff_power_color, diff_close_value, diff_close_color] = dragon_lib.source_comparition(fastMA, slowMA)
- // plot_my_plot = input.bool(true,"plot it NOW")
- // plot(plot_my_plot ? diff_power : na, "diff_power", color = diff_power_color )
- // Filtering shit
- some_ma_len = input.int(200)
- crazy_ma_filter = dragon_lib.butterworth_filter(close,some_ma_len)
- // Old STC Short
- short1 = stc_short and stc_high and diff_power >= -1
- // STC Long and Short conditions
- stclong1 = stc_long and stc_low
- stcshort2 = short1 and close > crazy_ma_filter
- fastLength = input(title='MACD Fast Length', defval=9)
- slowLength = input(title='MACD Slow Length', defval=34)
- cycleLength = input(title='Cycle Length', defval=11)
- d1Length = input(title='1st %D Length', defval=1)
- d2Length = input(title='2nd %D Length', defval=4)
- src = close
- upper1 = 75
- lower1 = 25
- macd = ta.ema(src, fastLength) - ta.ema(src, slowLength)
- k = nz(fixnan(ta.stoch(macd, macd, macd, cycleLength)))
- d1 = ta.ema(k, d1Length)
- kd = nz(fixnan(ta.stoch(d1, d1, d1, cycleLength)))
- stc = ta.ema(kd, d2Length)
- stc := math.max(math.min(stc, 100), 0)
- buySignal = ta.crossover(stc, lower1)
- sellSignal = ta.crossunder(stc, upper1)
- LONGMSG = ""
- SHORTMSG = ""
- if stclong1
- LONGMSG += 'stclong1, '
- if stcshort2
- SHORTMSG += 'stcshort2, '
- if buySignal
- LONGMSG+="NEOSTC"
- if sellSignal
- SHORTMSG+="NEOSTC"
- src12= input.source(hlcc4, group= 'rsi')
- rsiLength= input.int(17, group= 'rsi')
- rsi = ta.rsi(src12, rsiLength)
- ysell= input.int(61)
- ybuy= input.int(54)
- longRSI = rsi > ybuy
- shortRSI = rsi < ysell
- // MACD Strategy
- fastLength12 = input(28, group="MACD")
- slowlength = input(274, group="MACD")
- MACDLength = input(23, group="MACD")
- MACD = ta.ema(close, fastLength12) - ta.ema(close, slowlength)
- aMACD = ta.ema(MACD, MACDLength)
- delta = MACD - aMACD
- macdLong = ta.crossover(delta, 0)
- macdShort = ta.crossunder(delta, 0)
- if macdLong
- LONGMSG += "MACD "
- if macdShort
- SHORTMSG += "MACD "
- //plot(delta, title="Histogram", style=plot.style_columns, color=(delta>=0 ? (delta[1] < delta ? #26A69A : #B2DFDB) : (delta[1] < delta ? #FFCDD2 : #FF5252)))
- // DMI
- lensig = input.int(55, title="ADX Smoothing", minval=1, group="DMI")
- len = input.int(40, minval=1, title="DI Length", group="DMI")
- up = ta.change(high)
- down = -ta.change(low)
- plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
- minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
- trur = ta.rma(ta.tr, len)
- plus = fixnan(100 * ta.rma(plusDM, len) / trur)
- minus = fixnan(100 * ta.rma(minusDM, len) / trur)
- sum = plus + minus
- adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)
- dmiLong = (ta.crossover(plus, minus) or minus > 30) and adx > minus
- dmiShort = (ta.crossover(minus, plus) or plus > 30) and adx > plus
- if dmiLong
- LONGMSG += "DMI "
- if dmiShort
- SHORTMSG += "DMI "
- // plot(plus, color=color.green, title="+DI")
- // plot(minus, color=color.red, title="-DI")
- // plot(adx, color=color.orange, title="ADX")
- // hlineup = hline(30, color=#787B86)
- // Aroon
- aroonLength = input.int(134, minval=1, title="Aroon Length", group="Aroon")
- upper12 = 100 * (ta.highestbars(high, aroonLength+1) + aroonLength)/aroonLength
- lower12 = 100 * (ta.lowestbars(low, aroonLength+1) + aroonLength)/aroonLength
- lengthx = input.int(title="Length LSMA", defval=10, group="Aroon")
- offset = 0
- lsma = ta.linreg(close, lengthx, offset)
- aroonLong = ta.crossover(upper12,lower12) and close > lsma
- aroonShort = ta.crossunder(upper12,lower12) and close < lsma
- if aroonLong
- LONGMSG += "AROON "
- if aroonShort
- SHORTMSG += "AROON "
- //longConditions = (stclong1 and supertrendLong) or (longRSI and buySignal)
- //shortConditions = sellSignal and shortRSI
- longConditions = macdLong or (buySignal and longRSI) or dmiLong or aroonLong
- shortConditions = macdShort or (sellSignal and shortRSI)or dmiShort or aroonShort
- // longConditions = GunzoLong2
- // shortConditions = GunzoShort1
- if in_date_range and barstate.isconfirmed
- if longConditions
- strategy.entry('Long', strategy.long, comment = LONGMSG)
- if shortConditions
- strategy.entry('Short', strategy.short, comment = SHORTMSG)
- // ======================================================
- // Cobra Table
- // ======================================================
- 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 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)
- //
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