Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- study("guime v3", overlay=true)
- //{
- adx_len = input(14, minval=1, title="DI adx_length")
- adx_lensig = input(14, title="ADX Smoothing", minval=1, maxval=50)
- up = change(high)
- down = -change(low)
- trur = rma(tr, adx_len)
- plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, adx_len) / trur)
- minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, adx_len) / trur)
- sum = plus + minus
- adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adx_lensig)
- osob = input(40, title="Exhaustion Level for ADX, default = 40")
- col = adx <= 10 ? color.gray : adx > 10 and adx <= 20 and plus > minus ? #98FF98 :
- adx > 10 and adx <= 20 and plus < minus ? #E77471 :
- adx > 20 and adx <= osob and plus > minus ? color.lime :
- adx > 20 and adx <= osob and plus < minus ? color.red :
- adx > osob and plus > minus ? color.green :
- adx > osob and plus < minus ? color.maroon : color.white
- // barcolor(col)
- // plot(adx, color=col, title="ADX", style=plot.style_columns)
- // plot(0, title="0 Line", style=plot.style_line, linewidth=1, color=color.gray)
- // plot(10, title="10 Line", style=plot.style_circles, linewidth=1, color=color.gray)
- // plot(20, title="20 Line", style=plot.style_circles, linewidth=1, color=color.gray)
- // plot(osob, title="10 Line", style=plot.style_circles, linewidth=1, color=color.gray)
- //} --------------- ADX ---------------
- //{
- src = close,
- len = input(14, minval=1, title="RSI Length")
- len2 = input(12, minval=1, title="EMA of RSI Length")
- upp = rma(max(change(src), 0), len)
- downn = rma(-min(change(src), 0), len)
- rsi = downn == 0 ? 100 : upp == 0 ? 0 : 100 - (100 / (1 + upp / downn))
- emaRSI = ema(rsi,len2)
- // plot(rsi, title="RSI", style=plot.style_line, linewidth=2, color=color.black)
- // plot(emaRSI, title="EMA of RSI", style=plot.style_line, linewidth=2, color=color.red)
- // band1 = hline(80, title="uppper Line", linestyle=hline.style_dashed, linewidth=1, color=color.red)
- // band0 = hline(20, title="Lower Line", linestyle=hline.style_dashed, linewidth=1, color=color.lime)
- // band2 = hline(45, title="uppper Line", linestyle=hline.style_dashed, linewidth=1, color=color.gray)
- // band3 = hline(50, title="Lower Line", linestyle=hline.style_dashed, linewidth=1, color=color.black)
- // band4 = hline(55, title="Lower Line", linestyle=hline.style_dashed, linewidth=1, color=color.gray)
- //} --------------- EMA ---------------
- //{
- source = close
- useCurrentRes = input(true, title="Use Current Chart Resolution?")
- resCustom = input(title="Use Different Timeframe? Uncheck Box Above", type=input.resolution, defval="60")
- smd = input(true, title="Show MacD & Signal Line? Also Turn Off Dots Below")
- sd = input(true, title="Show Dots When MacD Crosses Signal Line?")
- sh = input(true, title="Show Histogram?")
- macd_colorChange = input(true, title="Change MacD Line Color-Signal Line Cross?")
- hist_colorChange = input(true, title="MacD Histogram 4 Colors?")
- res = useCurrentRes ? timeframe.period : resCustom
- fastLength = input(12, minval=1)
- slowLength = input(26, minval=1)
- signalLength = input(9, minval=1)
- fastMA = ema(source, fastLength)
- slowMA = ema(source, slowLength)
- macd = fastMA - slowMA
- signal = sma(macd, signalLength)
- hist = macd - signal
- outMacD = security(syminfo.tickerid, res, macd)
- outSignal = security(syminfo.tickerid, res, signal)
- outHist = security(syminfo.tickerid, res, hist)
- histA_IsUp = outHist > outHist[1] and outHist > 0
- histA_IsDown = outHist < outHist[1] and outHist > 0
- histB_IsDown = outHist < outHist[1] and outHist <= 0
- histB_IsUp = outHist > outHist[1] and outHist <= 0
- //MacD Color Definitions
- macd_IsAbove = outMacD >= outSignal
- macd_IsBelow = outMacD < outSignal
- plot_color = hist_colorChange ? histA_IsUp ? color.aqua : histA_IsDown ? color.blue :
- histB_IsDown ? color.red : histB_IsUp ? color.maroon : color.yellow : color.gray
- macd_color = macd_colorChange ? macd_IsAbove ? color.lime : color.red : color.red
- signal_color = macd_colorChange ? macd_IsAbove ? color.yellow : color.yellow : color.lime
- circleYPosition = outSignal
- // plot(smd and outMacD ? outMacD : na, title="MACD", color=macd_color, linewidth=4)
- // plot(smd and outSignal ? outSignal : na, title="Signal Line", color=signal_color, style=plot.style_line, linewidth=2)
- // plot(sh and outHist ? outHist : na, title="Histogram", color=plot_color, style=plot.style_histogram, linewidth=4)
- // plot(sd and cross(outMacD, outSignal) ? circleYPosition : na, title="Cross", style=plot.style_circles, linewidth=4, color=macd_color)
- // hline(0, '0 Line', linestyle=hline.style_solid, linewidth=2, color=color.black)
- //} --------------- MACD ---------------
- //{
- st_length = input(title="Supertrend ATR Period", type=input.integer, defval=1)
- mult = input(title="Supertrend ATR Multiplier", type=input.float, step=0.1, defval=10.0)
- atr = mult * atr(st_length)
- longStop = hl2 - atr
- longStopPrev = nz(longStop[1], longStop)
- longStop := close[1] > longStopPrev ? max(longStop, longStopPrev) : longStop
- shortStop = hl2 + atr
- shortStopPrev = nz(shortStop[1], shortStop)
- shortStop := close[1] < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop
- dir = 1
- dir := nz(dir[1], dir)
- dir := dir == -1 and close > shortStopPrev ? 1 : dir == 1 and close < longStopPrev ? -1 : dir
- longColor = color.blue
- shortColor = color.blue
- // //plot
- // plot(dir == 1 ? longStop : na, title="BuyLine", style=plot.style_linebr, linewidth=2, color=longColor)
- // plotshape(dir == 1 and dir[1] == -1 ? longStop : na, title="Buy", style=shape.labelup, location=location.absolute, size=size.normal, text="Buy", transp=0, textcolor = color.white, color=color.green, transp=0)
- // plot(dir == 1 ? na : shortStop, title="SellLine", style=plot.style_linebr, linewidth=2, color=shortColor)
- // plotshape(dir == -1 and dir[1] == 1 ? shortStop : na, title="Sell", style=shape.labeldown, location=location.absolute, size=size.normal, text="Sell", transp=0, textcolor = color.white, color=color.red, transp=0)
- // barcolor(dir == 1 ? color.green: color.red)
- // alertcondition(dir == 1 and dir[1] == -1 ? longStop : na, title="Buy", message="Buy!")
- // alertcondition(dir == 1 and dir[1] == -1 ? longStop : na, title="Buy", message="Buy!")
- // alertcondition(dir == 1 and dir[1] == -1 ? longStop : na, title="Buy", message="Buy!")
- // alertcondition(dir == -1 and dir[1] == 1 ? shortStop : na, title="Sell", message="Sell!")
- //} --------------- SUPERTREND ---------------
- //{
- squeeze_length = input(20, title="BB squeeze_length")
- squeeze_mult = input(2.0, title="BB squeeze_multFactor")
- squeeze_lengthKC = input(20, title="KC squeeze_length")
- squeeze_multKC = input(1.5, title="KC squeeze_multFactor")
- SignalPeriod = input(5, title="Signal squeeze_length")
- useTrueRange = input(true, title="Use TrueRange (KC)", type=input.bool)
- // Calculate BB
- squeeze_source = close
- basis = sma(squeeze_source, squeeze_length)
- dev = squeeze_multKC * stdev(squeeze_source, squeeze_length)
- upperBB = basis + dev
- lowerBB = basis - dev
- // Calculate KC
- ma = sma(squeeze_source, squeeze_lengthKC)
- range = useTrueRange ? tr : high - low
- rangema = sma(range, squeeze_lengthKC)
- upperKC = ma + rangema * squeeze_multKC
- lowerKC = ma - rangema * squeeze_multKC
- sqzOn = lowerBB > lowerKC and upperBB < upperKC
- sqzOff = lowerBB < lowerKC and upperBB > upperKC
- noSqz = sqzOn == false and sqzOff == false
- val = linreg(squeeze_source - avg(avg(highest(high, squeeze_lengthKC), lowest(low, squeeze_lengthKC)), sma(close, squeeze_lengthKC)), squeeze_lengthKC, 0)
- bcolor = iff(val > 0, iff(val > nz(val[1]), color.lime, color.green), iff(val < nz(val[1]), color.red, color.maroon))
- scolor = noSqz ? color.blue : sqzOn ? color.black : color.gray
- // plot(val, color=color.blue, linewidth=2)
- // plot(0, color=scolor, style=plot.style_cross, linewidth=2)
- // plot(sma(val, SignalPeriod), color=color.red, linewidth=2)
- //} --------------- SQUEEZE ---------------
- //{
- //1 master
- useADX = input(false, "Use ADX?")
- adx_threshold_buy = input(45, "ADX Greater Than Value (BUY)")
- adx_threshold_sell = input(45, "ADX Greater Than Value (SELL)")
- //2 master
- useRSI = input(false, "Use RSI?")
- rsi_threshold_buy = input(45, "RSI Greater Than Value (BUY)")
- rsi_threshold_sell = input(45, "RSI Less Than Value (SELL)")
- //3 master
- useEMA = input(false, "Use EMA of RSI?")
- emarsi_threshold_buy = input(45, "EMA of RSI Greater Than Value (BUY)")
- emarsi_threshold_sell = input(45, "EMA of RSI Less Than Value (SELL)")
- //4 individual
- useRSIEMA1 = input(false, "Use RSI Greater Than EMA (BUY)?")
- useRSIEMA2 = input(false, "Use RSI Less Than EMA (SELL)?")
- useRSIEMA3 = input(false, "Use RSI Crossing UP EMA (BUY)?")
- useRSIEMA4 = input(false, "Use RSI Crossing DOWN EMA (SELL)?")
- //5 individual
- useRSIup = input(false, "Use RSI Line Moving UP (value) % in n bars (BUY)")
- useRSIdown = input(false, "Use RSI Line Moving DOWN (value) % in n bars (SELL)")
- RSIup = input(45, "RSI Line Moving UP (value) % in n bars (BUY)", type=input.float)
- RSIdown = input(45, "RSI Line Moving DOWN (value) % in n bars (SELL)", type=input.float)
- rsi_bars = input(2, "Number of bars for RSI Line Movement")
- //6 master
- useMACD = input(false, "Use MACD?")
- macd_threshold_buy = input(45, "MACD Greater Than Value (BUY)", type=input.float)
- macd_threshold_sell = input(45, "MACD Less Than Value (SELL)", type=input.float)
- //7 master
- useMACDHistogram = input(false, "Use MACD Histogram?")
- macd_histogram_buy = input(45, "HISTOGRAM Greater Than Value (BUY)", type=input.float)
- macd_histogram_sell = input(45, "HISTOGRAM Less Than Value (SELL)", type=input.float)
- //8 individual
- useMACDsignal1 = input(false, "Use MACD Greater Than MACD Signal Line (BUY)?")
- useMACDsignal2 = input(false, "Use MACD Less Than MACD Signal Line (SELL)?")
- useMACDsignal3 = input(false, "Use MACD Crossing UP MACD Signal Line (BUY)?")
- useMACDsignal4 = input(false, "Use MACD Crossing DOWN MACD Signal Line (SELL)?")
- //9 individual
- useMACDup = input(false, "Use MACD Line Moving UP (value) % in n bars (BUY)")
- useMACDdown = input(false, "Use MACD Line Moving DOWN (value) % in n bars (SELL)")
- MACDup = input(0.01, "MACD Line Moving UP (value) % in n bars (BUY)", type=input.float)
- MACDdown = input(0.01, "MACD Line Moving DOWN (value) % in n bars (SELL)", type=input.float)
- macd_bars = input(2, "Number of bars for MACD Line Movement")
- //10 master
- useSupertrend = input(false, "Use Supertrend?")
- //11 master
- useSTline = input(true, "Use Supertrend Line?")
- STup = input(0.01, "Supertrend Line Moving UP (value) % in n bars (BUY)", type=input.float)
- STdown = input(0.01, "Supertrend Line Moving DOWN (value) % in n bars (SELL)", type=input.float)
- st_bars = input(2, "Number of bars for Supertrend Line Movement")
- //12 master
- useSqueeze = input(false, "Use Squeeze Momentum?")
- squeezeup = input(45, "PLOT-BUY Moving UP (value) % in n bars (BUY)", type=input.float)
- squeezedown = input(45, "PLOT-SELL Moving DOWN (value) % in n bars (SELL)", type=input.float)
- squeeze_bars = input(2, "Number of bars for PLOT Movement")
- //13 master
- useSqueezePlot = input(false, "Use Squeeze Plot-Buy x Plot-Sell?")
- //14 master
- useSqueezeValue = input(false, "Use Squeeze Momentum Value?")
- squeezeValueup = input(45, "PLOT-BUY Greater Than (value) (BUY)", type=input.float)
- squeezeValuedown = input(45, "PLOT-SELL Less Than (value) (SELL)", type=input.float)
- //} --------------- ALERT-SETTINGS ---------------
- //{
- //{
- supertrendButtonsOff = not useSupertrend and not useSTline
- buyButtonsOff = not useRSIEMA1 and not useRSIEMA3 and not useRSIup and not useMACDsignal1 and not useMACDsignal3 and not useMACDup
- individualSelectionBuy = (useRSIEMA1 ? rsi > emaRSI : false) or
- (useRSIEMA3 ? crossover(rsi, emaRSI) : false) or
- (useRSIup ? (rsi>rsi[rsi_bars]) and abs(change(rsi, rsi_bars))/abs(rsi[rsi_bars])*100 > RSIup : false) or
- (useMACDsignal1 ? outMacD > outSignal : false) or
- (useMACDsignal3 ? crossover(outMacD, outSignal) : false) or
- (useMACDup ? (outMacD>outMacD[macd_bars]) and abs(change(outMacD, macd_bars))/abs(outMacD[macd_bars])*100 > MACDup : false)
- combinedBuy = (useADX ? adx > adx_threshold_buy : true) and
- (useRSI ? rsi > rsi_threshold_buy : true) and
- (useEMA ? emaRSI > emarsi_threshold_buy : true) and
- (useMACD ? outMacD > macd_threshold_buy : true) and
- (useMACDHistogram ? outHist > macd_histogram_buy : true) and
- iff(supertrendButtonsOff,true,((useSupertrend ? dir == 1 and dir[1] == -1 : false) or
- (useSTline ?
- dir == 1 and dir[st_bars] == 1 ?
- (longStop > longStop[st_bars]) and abs(change(longStop, st_bars))/abs(longStop[st_bars])*100 > STup :
- false : false))) and
- (useSqueeze ? (val > val[squeeze_bars]) and abs(change(val, squeeze_bars))/abs(val[squeeze_bars])*100 > squeezeup : true) and
- (useSqueezePlot ? val > sma(val, SignalPeriod) : true) and
- (useSqueezeValue ? val > squeezeValueup : true) and
- iff(buyButtonsOff, true, individualSelectionBuy)
- //} BUY
- //{
- sellButtonsOff = not useRSIEMA2 and not useRSIEMA4 and not useRSIdown and not useMACDsignal2 and not useMACDsignal4 and not useMACDdown
- individualSelectionSell = (useRSIEMA2 ? rsi < emaRSI : false) or
- (useRSIEMA4 ? crossunder(rsi, emaRSI) : false) or
- (useRSIdown ? (rsi<rsi[rsi_bars]) and abs(change(rsi, rsi_bars))/abs(rsi[rsi_bars])*100 > RSIdown : false) or
- (useMACDsignal2 ? outMacD < outSignal : false) or
- (useMACDsignal4 ? crossunder(outMacD, outSignal) : false) or
- (useMACDdown ? (outMacD<outMacD[macd_bars]) and abs(change(outMacD, macd_bars))/abs(outMacD[macd_bars])*100 > MACDdown : false)
- combinedSell = (useADX ? adx > adx_threshold_sell : true) and
- (useRSI ? rsi < rsi_threshold_sell : true) and
- (useEMA ? emaRSI < emarsi_threshold_sell : true) and
- (useMACD ? outMacD < macd_threshold_sell : true) and
- (useMACDHistogram ? outHist < macd_histogram_sell : true) and
- iff(supertrendButtonsOff,true,((useSupertrend ? dir == -1 and dir[1] == 1 : false) or
- (useSTline ?
- dir == -1 and dir[st_bars] == -1 ?
- (shortStop < shortStop[st_bars]) and abs(change(shortStop, st_bars))/abs(shortStop[st_bars])*100 > STdown :
- false : false))) and
- (useSqueeze ? (val < val[squeeze_bars]) and abs(change(val, squeeze_bars))/abs(val[squeeze_bars])*100 > squeezedown : true) and
- (useSqueezePlot ? val < sma(val, SignalPeriod) : true) and
- (useSqueezeValue ? val < squeezeValuedown : true) and
- iff(sellButtonsOff, true, individualSelectionSell)
- //} SELL
- alertcondition(combinedBuy,"BUY","BUY")
- alertcondition(combinedSell,"SELL","SELL")
- alertcondition(combinedSell,"BUYSTOP","BUYSTOP")
- alertcondition(combinedBuy,"SELLSTOP","SELLSTOP")
- //} --------------- ALERT ---------------
- //{
- plotshape(combinedBuy,style=shape.triangleup,location=location.belowbar,title="BUY",text="BUY",color=color.green)
- plotshape(combinedSell,style=shape.triangledown,location=location.abovebar,title="SELL",text="SELL",color=color.red)
- plotshape(combinedSell,style=shape.triangleup,location=location.belowbar,title="BUYSTOP",text="BUYSTOP",color=color.black)
- plotshape(combinedBuy,style=shape.triangledown,location=location.abovebar,title="SELLSTOP",text="SELLSTOP",color=color.black)
- //} --------------- PLOTS ---------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement