Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- study(title="Zulu - Indi Combo v6", shorttitle="CV6", overlay=true)
- //
- //
- // Rhapsodyy's Combo Indicator v6
- //
- // 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.
- //
- // 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.
- //
- // Items Included:
- //
- // 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.
- //
- //
- // HINTS: Best trades tend to occur when price reversing bounce off outer band and
- // and outside Optional Bollinger Squeeze indication.
- //
- // References:
- // -----------
- // - https://www.forexstrategiesresources.com/scalping-forex-strategies-iii/337-bollinger-bands-and-chaos-awesome-scalping-system
- // - "Squeeze Momentum Indicator [LazyBear]"
- //
- //Inputs - Toggle on/off individual components.
- showSMA1 = input(title="SMA 1 - 10/50/80/200", type=input.bool, defval=true)
- showEMA1 = input(title="EMA 1 - 21/50/89/200/377", type=input.bool, defval=true)
- showBBEMA = input(title="Show BBEMA", type=input.bool, defval=true)
- showEMAR = input(title="EMAR", type=input.bool, defval=false)
- showPivHL = input(title="Pivots H/L", type=input.bool, defval=false)
- //
- //
- //Bollinger Band - Basis Line & Fast Ema Strategy with buy and sell signals.
- //Still to do: Tidy up code?
- // 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="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=showBBEMA ? break_down : na, title="Breakout Down", style=shape.arrowdown, location=location.abovebar, size=size.auto, text="Sell", color=color.red, transp=0)
- plotshape(series=showBBEMA ? 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")
- //
- //
- // Still to do for all EMA/SMA: Print Label of EMA/SMA value at end of line.
- // Print cross on certain crosses on certain time frames?
- // Alert conditions for those crosses
- //
- //SMA 1 - 20/50/80/100/200
- MA1 = input(10, minval=1, title="SMA 1 - 10")
- MA2 = input(30, minval=1, title="SMA 1 - 30")
- MA3 = input(50, minval=1, title="SMA 1 - 50")
- MA4 = input(80, minval=1, title="SMA 1 - 80")
- MA5 = input(200, minval=1, title="SMA 1 - 100")
- //
- xPrice = input(close, title="Source")
- //
- xMA1 = sma(xPrice, MA1)
- xMA2 = sma(xPrice, MA2)
- xMA3 = sma(xPrice, MA3)
- xMA4 = sma(xPrice, MA4)
- xMA5 = sma(xPrice, MA5)
- //
- plot(xMA1, color=iff(showSMA1, #8A2BE2, na), transp=0, linewidth=1, style=plot.style_line, title="SMA 1 - 10")
- plot(xMA2, color=iff(showSMA1, #00FFFF, na), transp=25, linewidth=1, style=plot.style_line, title="SMA 1 - 30")
- plot(xMA3, color=iff(showSMA1, #556B2F, na), transp=0, linewidth=1, style=plot.style_line, title="SMA 1 - 50")
- plot(xMA4, color=iff(showSMA1, #DAA520, na), transp=0, linewidth=1, style=plot.style_line, title="SMA 1 - 80")
- plot(xMA5, color=iff(showSMA1, #800000, na), transp=0, linewidth=1, style=plot.style_line, title="SMA 1 - 200")
- //
- //
- //EMA1 //
- EMA1 = input(21, minval=1, title="EMA 1 - 21")
- EMA2 = input(50, minval=1, title="EMA 1 - 50")
- EMA3 = input(89, minval=1, title="EMA 1 - 89")
- EMA4 = input(200, minval=1, title="EMA 1 - 200")
- EMA5 = input(377, minval=1, title="EMA 1 - 377")
- //
- xPrice6 = input(close, title="Source")
- //
- xEMA1 = ema(xPrice6, EMA1)
- xEMA2 = ema(xPrice6, EMA2)
- xEMA3 = ema(xPrice6, EMA3)
- xEMA4 = ema(xPrice6, EMA4)
- xEMA5 = ema(xPrice6, EMA5)
- //
- plot(xEMA1, color=iff(showEMA1, #4682B4, na), transp=10, linewidth=1, style=plot.style_line, title="EMA 1 - 21")
- plot(xEMA2, color=iff(showEMA1, color.lime, na), transp=10, linewidth=1, style=plot.style_line, title="EMA 1 - 50")
- plot(xEMA3, color=iff(showEMA1, color.yellow, na), transp=10, linewidth=1, style=plot.style_line, title="EMA 1 - 89")
- plot(xEMA4, color=iff(showEMA1, color.orange, na), transp=10, linewidth=1, style=plot.style_line, title="EMA 1 - 200")
- plot(xEMA5, color=iff(showEMA1, color.red, na), transp=20, linewidth=1, style=plot.style_line, title="EMA 1 - 377")
- //
- //
- //EMA Ribbon
- EMA10 = input(20, minval=1, title="EMAR - 20")
- EMA11 = input(25, minval=1, title="EMAR - 25")
- EMA12 = input(30, minval=1, title="EMAR - 30")
- EMA13 = input(35, minval=1, title="EMAR - 35")
- EMA14 = input(40, minval=1, title="EMAR - 40")
- EMA15 = input(45, minval=1, title="EMAR - 45")
- EMA16 = input(50, minval=1, title="EMAR - 50")
- EMA17 = input(55, minval=1, title="EMAR - 55")
- //
- xPrice7 = input(close, title="Source")
- //
- xEMA10 = ema(xPrice7, EMA10)
- xEMA11 = ema(xPrice7, EMA11)
- xEMA12 = ema(xPrice7, EMA12)
- xEMA13 = ema(xPrice7, EMA13)
- xEMA14 = ema(xPrice7, EMA14)
- xEMA15 = ema(xPrice7, EMA15)
- xEMA16 = ema(xPrice7, EMA16)
- xEMA17 = ema(xPrice7, EMA17)
- //
- plot(xEMA10, color=iff(showEMAR, #ffff00, na), transp=10, linewidth=1, style=plot.style_line, title="EMAR - 20")
- plot(xEMA11, color=iff(showEMAR, #f2d90d, na), transp=10, linewidth=1, style=plot.style_line, title="EMAR - 25")
- plot(xEMA12, color=iff(showEMAR, #f2c60d, na), transp=10, linewidth=1, style=plot.style_line, title="EMAR - 30")
- plot(xEMA13, color=iff(showEMAR, #fbae04, na), transp=10, linewidth=1, style=plot.style_line, title="EMAR - 35")
- plot(xEMA14, color=iff(showEMAR, #f27d0d, na), transp=20, linewidth=1, style=plot.style_line, title="EMAR - 40")
- plot(xEMA15, color=iff(showEMAR, #fd6202, na), transp=10, linewidth=1, style=plot.style_line, title="EMAR - 45")
- plot(xEMA16, color=iff(showEMAR, #f5470a, na), transp=10, linewidth=1, style=plot.style_line, title="EMAR - 50")
- plot(xEMA17, color=iff(showEMAR, #ff0000, na), transp=20, linewidth=1, style=plot.style_line, title="EMAR - 55")
- //
- //
- //Pivots High / Low
- //Still to do:
- 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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement