Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- // Rhapsodyy's Combo Indicator v12
- // So to get around the indicator limit built within trading view i've combined
- // a bunch of the things i use to save on the indicator count. If you have any suggestions feel free to pass them on.
- //
- //
- // I should think there's neater ways to write some of the code and there may be old code ive
- // left in and havn't cleaned up but everything should work as intended.
- // Donations if you should so feel inclined: 3Ec8FaLMr2surCWNkTaZWs4jH7UijX8CHT//
- //
- // Items Included : SMA's & EMA's with Painted Labels / Bollinger Bands / Pivots H/L / EMA Ribbon
- // 50EMA/200EMA & 10SMA/21EMA Golden & Death Crosses on Current Timeframe & Alerts
- // Daily 50EMA/200EMA & 10SMA/21EMA Golden & Death Crosses overlayed onto Current Timeframe & Alerts
- // Buy and Sell Signals for Bollinger Basis Line & Fast EMA Strategy
- // Buy and Sell Signals for Golden Shower EMA Behaviour Strategy - FOR 4h TIMEFRAME! For most viable results.
- //
- // Have listed color codes also.
- //
- // Simple Moving Averages (SMA):
- // These can be changed to any figures or colors you may prefer to use.
- // And can be individually or as a whole group turned on and off through settings.
- // 10 - Purple - #8A2BE2
- // 30 - Cyan - #00FFFF
- // 50 - Olive - #556B2F
- // 80 - Gold - #DAA520
- // 200 - Maroon - #800000
- //
- // Exponential Moving Averages (EMA):
- // These can be changed to any figures you may prefer to use.
- // And can be individually or as a whole group turned on and off through settings.
- // 21 - Blue - #4682B4
- // 50 - Green - #00FF00
- // 89 - Yellow - #FFFF00
- // 200 - Orange - #FF7F00
- // 377 - Red - #FF0000
- //
- // EMA Ribbon:
- // These can be changed to any figures or colors you may prefer to use.
- // And can be individually or as a whole group turned on and off through settings.
- //
- // 20 - #ffff00
- // 25 - #f2d90d
- // 30 - #f2c60d
- // 35 - #fbae04
- // 40 - f27d0d
- // 45 - #fd6202
- // 50 - #f5470a
- // 55 - #ff0000
- //
- // Bollinger Bands - With Included Buy and Sell Signals Following the Below Strategy
- //
- // Description:
- // ============
- // This indicator is an implementation of the Bollinger Band and EMA system.
- // Id say have a look at it on the chart and see how it performs on different timeframes
- // and you'll start to get the idea how it works. Then i start to include signals from MA/EMA's to look for targets or other factors.
- //
- // Here's the strategy:
- // --------------------
- // Going LONG:
- // Enter a long position when the black 3 EMA has crossed up through the Bollinger red
- // middle band MA.This is indicated by "Buy" alert.
- //
- // Going SHORT:
- // Enter a short position when the black 3 EMA has crossed down through the Bollinger red
- // middle band MA.This is indicated by the "Sell" Alert.
- //
- // Stop Loss Ideas:
- // The Low (Long) or High (Short) of the candle that printed a buy or sell signal, or the previous candle.
- // This could depend on how tight the price action was and how much risk you wanted to take.
- // Possible to make a Trailing Stop loss? Or move Stop loss up if first targets hit?
- //
- // Take Profit Ideas:
- // Basic % target, this may be more viable on higher time frames.
- // After a signal, targeting a MA/EMA, BB Band.
- // As entry and exit signals wont catch exact tops and bottoms, being able to refine the exit signal to fire
- // of another input than this Bollinger Strat may be more beneficial.
- //
- // Increasing Position Size:
- // Example: On a Long Entry If candle following signal decreased in price but remained above stop loss at close,
- // Could increase position size.
- //
- // 4hr Golden Shower Strategy
- // Based on EMA Behaviour - ONLY to be used on the 4hr for most reliable signals. Credit to CryptoMF
- //
- // References:
- // -----------
- // - https://www.forexstrategiesresources.com/scalping-forex-strategies-iii/337-bollinger-bands-and-chaos-awesome-scalping-system
- // - "Squeeze Momentum Indicator [LazyBear]"
- study(title="RhapsCombo v12", shorttitle="RCv12", overlay=true)
- showSMA1 = input(title="SMA's- 10/30/50/80/200", defval=false)
- showEMA1 = input(title="EMA's - 21/50/89/200/377", defval=true)
- showTFGDX = input(title='Current TF 50/200 EMA G&D X', defval=false)
- showTFGDX2 = input(title='Current TF 10SMA/21EMA G&D X', defval=false)
- showDGDX = input(title='Daily 10SMA/21EMA G&D X', defval=false)
- showDGDX2 = input(title='Daily 50EMA/200EMA G&D X', defval=false)
- showSMA1Labels = input(title="SMA Labels", defval=true)
- showEMA1Labels = input(title="EMA Labels", defval=true)
- showEMAR = input(title="EMA Ribbon", defval=false)
- showPivHL = input(title="Pivots H/L", defval=false)
- showBBEMA = input(title="Bollinger Bands", defval=false)
- showBBEMABS = input(title="B.Bands Buy/Sell", defval=false)
- show4HGS = input(title="4hr Golden Shower Buy/Sell",defval=false)
- //Simple Moving Averages: 10/30/50/80/200
- sma10 = sma(close, 10)
- sma30 = sma(close, 30)
- sma50 = sma(close, 50)
- sma80 = sma(close, 80)
- sma200 = sma(close, 200)
- plot(showSMA1 == true ? sma10 : na, color=#8A2BE2, transp=0, linewidth=1, title='SMA 10')
- plot(showSMA1 == true ? sma30 : na, color=#00FFFF, transp=0, linewidth=1, title='SMA 30')
- plot(showSMA1 == true ? sma50 : na, color=#556B2F, transp=0, linewidth=1, title='SMA 50')
- plot(showSMA1 == true ? sma80 : na, color=#DAA520, transp=0, linewidth=1, title='SMA 80')
- plot(showSMA1 == true ? sma200 : na, color=#800000, transp=0, linewidth=1, title='SMA 200')
- // SMA Labels
- plotshape(showSMA1 == true and showSMA1Labels == true ? sma10 : na, style=shape.diamond, location=location.absolute, show_last=1, color=#8A2BE2, transp=0, text="SMA 10\n**Example**", title='SMA 10', offset=10)
- plotshape(showSMA1 == true and showSMA1Labels == true ? sma30 : na, style=shape.diamond, location=location.absolute, show_last=1, color=#00FFFF, transp=0, text='SMA 30', title='SMA 30', offset=10)
- plotshape(showSMA1 == true and showSMA1Labels == true ? sma50 : na, style=shape.diamond, location=location.absolute, show_last=1, color=#556B2F, transp=0, text='SMA 50', title='SMA 50', offset=10)
- plotshape(showSMA1 == true and showSMA1Labels == true ? sma80 : na, style=shape.diamond, location=location.absolute, show_last=1, color=#DAA520, transp=0, text='SMA 80', title='SMA 80', offset=10)
- plotshape(showSMA1 == true and showSMA1Labels == true ? sma200 : na, style=shape.diamond, location=location.absolute, show_last=1, color=#800000, transp=0, text='SMA 200', title='SMA 200', offset=10)
- //Exponential Moving Averages: 21/50/89/200/377
- ema21 = ema(close, 21)
- ema50 = ema(close, 50)
- ema89 = ema(close, 89)
- ema200 = ema(close, 200)
- ema377 = ema(close, 377)
- plot(showEMA1 == true ? ema21 : na, color=#4682B4, transp=0, linewidth=1, title='EMA 21')
- plot(showEMA1 == true ? ema50 : na, color=#00FF00, transp=0, linewidth=1, title='EMA 50')
- plot(showEMA1 == true ? ema89 : na, color=#FFFF00, transp=0, linewidth=1, title='EMA 89')
- plot(showEMA1 == true ? ema200 : na, color=#FF7F00, transp=0, linewidth=1, title='EMA 200')
- plot(showEMA1 == true ? ema377 : na, color=#FF0000, transp=0, linewidth=1, title='EMA 377')
- //EMA Labels
- plotshape(showEMA1 == true and showEMA1Labels == true ? ema21 : na, style=shape.diamond, location=location.absolute, show_last=1, color=#4682B4, transp=0, text='EMA 21', title='EMA 21', offset=10)
- plotshape(showEMA1 == true and showEMA1Labels == true ? ema50 : na, style=shape.diamond, location=location.absolute, show_last=1, color=#00FF00, transp=0, text='EMA 50', title='EMA 50', offset=10)
- plotshape(showEMA1 == true and showEMA1Labels == true ? ema89 : na, style=shape.diamond, location=location.absolute, show_last=1, color=#FFFF00, transp=0, text='EMA 89', title='EMA 89', offset=10)
- plotshape(showEMA1 == true and showEMA1Labels == true ? ema200 : na, style=shape.diamond, location=location.absolute, show_last=1, color=#FF7F00, transp=0, text='EMA 200', title='EMA 200', offset=10)
- plotshape(showEMA1 == true and showEMA1Labels == true ? ema377 : na, style=shape.diamond, location=location.absolute, show_last=1, color=#FF0000, transp=0, text='EMA 377', title='EMA 377', offset=10)
- //Current TF Golden & Death Cross: 50EMA & 200EMA
- goldenx = crossover(ema50, ema200) and not timeframe.isweekly and not timeframe.ismonthly
- deathx = crossunder(ema50, ema200) and not timeframe.isweekly and not timeframe.ismonthly
- plotshape(showTFGDX == true ? goldenx : na, style=shape.xcross, location=location.belowbar, color=#00ff00, transp=0, text='GX EMA\n50/200', title='50/200 EMA Golden X', show_last=500, size=size.small)
- plotshape(showTFGDX == true ? deathx : na, style=shape.xcross, location=location.abovebar, color=#ff9200, transp=0, text='DX EMA\n50/200', title='50/200 EMA Death X', show_last=500, size=size.small)
- alertcondition(goldenx, title='50/200 EMA Golden X', message='50/200 EMA Golden X')
- alertcondition(deathx, title='50/200 EMA Death X', message='50/200 EMA Death X')
- //Current TF Golden & Death Cross: 10SMA & 21 EMA
- goldenx2 = crossover(sma10, ema21) and not timeframe.isweekly and not timeframe.ismonthly
- deathx2 = crossunder(sma10, ema21) and not timeframe.isweekly and not timeframe.ismonthly
- plotshape(showTFGDX2 == true ? goldenx2 : na, style=shape.xcross, location=location.belowbar, color=#00ff00, transp=0, text='GX SEMA\n10/21', title='10SMA/21EMA Golden X', show_last=500, size=size.small)
- plotshape(showTFGDX2 == true ? deathx2 : na, style=shape.xcross, location=location.abovebar, color=#ff9200, transp=0, text='DX SEMA\n10/21', title='SMA10/EMA21 Death X', show_last=500, size=size.small)
- alertcondition(goldenx2, title='SMA10/EMA21 Golden X', message='SMA10/EMA21 Golden X')
- alertcondition(deathx2, title='SMA10/EMA21 Death X', message='SMA10/EMA21 Death X')
- //Daily Golden & Death Cross: 10SMA & 21 EMA#00ff00
- sma10_1d = security(syminfo.tickerid, 'D', sma10)
- ema21_1d = security(syminfo.tickerid, 'D', ema21)
- sgoldenx_1d = crossover(sma10_1d, ema21_1d) and not timeframe.isweekly and not timeframe.ismonthly
- sdeathx_1d = crossunder(sma10_1d, ema21_1d) and not timeframe.isweekly and not timeframe.ismonthly
- plotshape(showDGDX == true ? sgoldenx_1d : na, style=shape.xcross, location=location.belowbar, color=#ffe500, transp=0, text='1DGX\n10/21', title='1D 10SMA/21EMA Golden X', show_last=300, size=size.normal)
- plotshape(showDGDX == true ? sdeathx_1d : na, style=shape.xcross, location=location.abovebar, color=#ff0000, transp=0, text='1DDX\n10/21', title='1D 10SMA/21EMA Death X', show_last=300, size=size.normal)
- alertcondition(sgoldenx_1d, title='1D 10SMA/21EMA Golden X', message='1D 10SMA/21EMA Golden X')
- alertcondition(sdeathx_1d, title='1D 10SMA/21EMA Death X', message='1D 10SMA/21EMA Death X')
- //Daily Golden & Death Cross: 50EMA & 200EMA
- ema50_1d = security(syminfo.tickerid, 'D', sma50)
- ema200_1d = security(syminfo.tickerid, 'D', ema200)
- sgoldenx_1db = crossover(ema50_1d, ema200_1d) and not timeframe.isweekly and not timeframe.ismonthly
- sdeathx_1db = crossunder(ema50_1d, ema200_1d) and not timeframe.isweekly and not timeframe.ismonthly
- plotshape(showDGDX2 == true ? sgoldenx_1db : na, style=shape.xcross, location=location.belowbar, color=#ffe500, transp=0, text='1DGX EMA\n50/200', title='1D 50EMA/200EMA Golden X', show_last=300, size=size.normal)
- plotshape(showDGDX2 == true ? sdeathx_1db : na, style=shape.xcross, location=location.abovebar, color=#ff0000, transp=0, text='1DDX EMA\n50/200', title='1D 50EMA/200EMA Death X', show_last=300, size=size.normal)
- alertcondition(sgoldenx_1db, title='1D 10SMA/21EMA Golden X', message='1D 10SMA/21EMA Golden X')
- alertcondition(sdeathx_1db, title='1D 10SMA/21EMA Death X', message='1D 10SMA/21EMA Death X')
- //Exponential Moving Average Ribbon: 20/25/30/35/40/45/50/55
- emar20 = ema(close, 20)
- emar25 = ema(close, 25)
- emar30 = ema(close, 30)
- emar35 = ema(close, 35)
- emar40 = ema(close, 40)
- emar45 = ema(close, 45)
- emar50 = ema(close, 50)
- emar55 = ema(close, 55)
- plot(showEMAR == true ? emar20 : na, color=#ffff00, transp=0, linewidth=1, title='EMAR 20')
- plot(showEMAR == true ? emar25 : na, color=#f2d90d, transp=0, linewidth=1, title='EMAR 25')
- plot(showEMAR == true ? emar30 : na, color=#f2c60d, transp=0, linewidth=1, title='EMAR 30')
- plot(showEMAR == true ? emar35 : na, color=#fbae04, transp=0, linewidth=1, title='EMAR 35')
- plot(showEMAR == true ? emar40 : na, color=#f27d0d, transp=0, linewidth=1, title='EMAR 40')
- plot(showEMAR == true ? emar45 : na, color=#fd6202, transp=0, linewidth=1, title='EMAR 45')
- plot(showEMAR == true ? emar50 : na, color=#f5470a, transp=0, linewidth=1, title='EMAR 50')
- plot(showEMAR == true ? emar55 : na, color=#ff0000, transp=0, linewidth=1, title='EMAR 55')
- //Pivots High/Low
- lenH = input(title="Pivot High", type=input.integer, defval=10, minval=1)
- lenL = input(title="Pivot Low", type=input.integer, defval=10, minval=1)
- ph = pivothigh(high, lenH, lenH)
- if ph and showPivHL
- label.new(bar_index[lenH], ph, tostring(ph), style = label.style_labeldown, yloc = yloc.abovebar, color = #f0ffcc, size = size.small)
- pl = pivotlow(low, lenL, lenL)
- if pl and showPivHL
- label.new(bar_index[lenL], pl, tostring(pl), style = label.style_labelup, yloc = yloc.belowbar, color = #f0ffcc, size = size.small)
- //Bollinger Bands & Buy/Sell Signals
- // Bollinger Bands Inputs
- bb_use_ema = input(false, title="Use EMA for Bollinger Band")
- bb_length = input(20, minval=1, title="Bollinger Length")
- bb_source = input(close, title="Bollinger Source")
- bb_mult = input(2.0, title="Bollinger Base Multiplier", minval=0.5, maxval=10)
- // EMA inputs
- fast_ma_len = input(3, title="Fast EMA length", minval=2)
- // Awesome Inputs
- nLengthSlow = input(34, minval=1, title="Awesome Length Slow")
- nLengthFast = input(5, minval=1, title="Awesome Length Fast")
- // === SERIES ===
- // Breakout Indicator Inputs
- ema_1 = ema(bb_source, bb_length)
- sma_1 = sma(bb_source, bb_length)
- bb_basis = bb_use_ema ? ema_1 : sma_1
- fast_ma = ema(bb_source, fast_ma_len)
- // Deviation
- // * I'm sure there's a way I could write some of this cleaner, but meh.
- dev = stdev(bb_source, bb_length)
- bb_dev_inner = bb_mult * dev
- // Upper bands
- inner_high = bb_basis + bb_dev_inner
- // Lower Bands
- inner_low = bb_basis - bb_dev_inner
- // Calculate Awesome Oscillator
- xSMA1_hl2 = sma(hl2, nLengthFast)
- xSMA2_hl2 = sma(hl2, nLengthSlow)
- xSMA1_SMA2 = xSMA1_hl2 - xSMA2_hl2
- // Calculate direction of AO
- AO = xSMA1_SMA2 >= 0 ? xSMA1_SMA2 > xSMA1_SMA2[1] ? 1 : 2 :
- xSMA1_SMA2 > xSMA1_SMA2[1] ? -1 : -2
- // === PLOTTING ===
- // plot BB upper bands
- ubi = plot(series=showBBEMA ? inner_high : na, title="Upper Band Inner", color=#20B2AA, transp=10, linewidth=1)
- // plot BB basis
- plot(series=showBBEMA ? bb_basis : na, title="Basis Line", color=#8B4513, transp=10, linewidth=1)
- // plot BB lower bands
- lbi = plot(series=showBBEMA ? inner_low : na, title="Lower Band Inner", color=#20B2AA, transp=10, linewidth=1)
- // center BB channel fill
- fill(ubi, lbi, title="Center Channel Fill", color=color.silver, transp=98)
- // plot fast ma
- plot(series=showBBEMA ? fast_ma : na, title="Fast EMA", color=#A52A2A, transp=10, linewidth=1)
- // Calc breakouts
- break_down = crossunder(fast_ma, bb_basis) and close < bb_basis
- break_up = crossover(fast_ma, bb_basis) and close > bb_basis
- break_All = crossunder(fast_ma, bb_basis) and close < bb_basis or
- crossover(fast_ma, bb_basis) and close > bb_basis
- // Show Break Alerts
- plotshape(series=showBBEMABS ? break_down : na, title="Breakout Down", style=shape.arrowdown, location=location.abovebar, size=size.auto, text="Sell", color=color.red, transp=0)
- plotshape(series=showBBEMABS ? break_up : na, title="Breakout Up", style=shape.arrowup, location=location.belowbar, size=size.auto, text="Buy", color=color.green, transp=0)
- // Send alert to TV alarm sub-system
- alertcondition(break_down or break_up, title="BBEMA_Alert", message="BBEMA_Alert")
- alertcondition(break_up, title="BBEMA: Break Up", message="BBEMA: Break Up")
- alertcondition(break_down, title="BBEMA: Break Down", message="BBEMA: Break Down")
- //Golden Shower 4hr Buy/Sell
- // Credit to CryptoMF
- // Get inputs and stuff
- emaLength = input(defval=21, title="Golden.S EMA Length", minval=1)
- trendLength = input(defval=120, title="Golden.S Trend Length", minval=1)
- trigger = input(defval=10, title="Golden.S Sensitivity", minval=1)
- // Calc dat moving everage
- close4h = security(syminfo.tickerid, '240', close)
- ema = ema(close4h, emaLength)
- trend = ema(close4h, trendLength)
- // Calculate candle types
- wasLongEntryCandle() =>
- rising(ema[1], trigger) and close[1] > trend
- wasShortEntryCandle() =>
- falling(ema[1], trigger) and close[1] < trend
- wasLongExitCandle() =>
- falling(ema[1], trigger) and close[1] > trend
- wasShortExitCandle() =>
- rising(ema[1], trigger) and close[1] < trend
- isLongEntryCandle() =>
- rising(ema, trigger) and close > trend and barssince(wasLongEntryCandle()) > 5
- isShortEntryCandle() =>
- falling(ema, trigger) and close < trend and barssince(wasShortEntryCandle()) > 5
- isLongExitCandle() =>
- falling(ema, trigger) and close > trend and not wasLongExitCandle() and
- not wasShortEntryCandle()
- isShortExitCandle() =>
- rising(ema, trigger) and close < trend and not wasShortExitCandle() and
- not wasLongEntryCandle()
- isLong() =>
- barssince(wasLongEntryCandle()) < barssince(wasLongExitCandle()) and
- barssince(wasLongEntryCandle()) < barssince(wasShortExitCandle()) and
- barssince(wasLongEntryCandle()) < barssince(wasShortEntryCandle())
- isShort() =>
- barssince(wasShortEntryCandle()) < barssince(wasLongExitCandle()) and
- barssince(wasShortEntryCandle()) < barssince(wasShortExitCandle()) and
- barssince(wasShortEntryCandle()) < barssince(wasLongEntryCandle())
- isFlat() =>
- not(isLong() or isShort())
- // Determine long and short entries and exits
- longEntry = (isFlat() or isShort()) and isLongEntryCandle()
- shortEntry = (isFlat() or isLong()) and isShortEntryCandle()
- longExit = isLong() and isLongExitCandle()
- shortExit = isShort() and isShortExitCandle()
- // Some manual plots done on chart without using strategy engine
- plotshape(show4HGS == true ? longEntry : na, location=location.belowbar, style=shape.arrowup, text='Long Entry', color=color.lime, textcolor=color.lime, transp=0)
- plotshape(show4HGS == true ? shortEntry : na, style=shape.arrowdown, text='Short Entry', color=color.red, textcolor=#ff001a, transp=0)
- plotshape(show4HGS == true ? longExit : na, style=shape.arrowdown, text='Long Exit', color=color.fuchsia, textcolor=color.fuchsia, transp=0)
- plotshape(show4HGS == true ? shortExit : na, location=location.belowbar, style=shape.arrowup, text='Short Exit', color=color.fuchsia, textcolor=color.fuchsia, transp=0)
- // Trade Alert
- alertcondition(longEntry, title="Long Entry", message="Golden Shower: Open Long Position")
- alertcondition(longExit, title="Long Exit", message="Golden Shower: Exit Long Position")
- alertcondition(shortEntry, title="Short Entry", message="Golden Shower: Open Short Position")
- alertcondition(shortExit, title="Short Exit", message="Golden Shower: Exit Short Position")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement