//@version=4 study("Mod MACD QMP", shorttitle="Mod MACD", overlay=true) // MACD Programming // The MACD portion of this script was created by TradingView's RafaelZioni. The // script is titled "Zero Lag MACD Free". It is his/her work. I adapted it by // removing some inputs, removing some code that was not needed for my trading // style, and modified the colors. src10 = close smooth = 5 Length = 21 normalize(series) => h = highest(series, Length) l = lowest(series, Length) res = (series - l)/(h - l) len = 5 ma3 = wma(src10*volume, len) / wma(volume, len) result1 = normalize(ma3) m1 = sma(result1, smooth) m2 = sma(result1*100, smooth) source = close fastLength = 12 slowLength = 26 signalLength = 9 MacdEmaLength = 9 // Fast line ma1= ema(source, fastLength) ma2 = ema(ma1,fastLength) zerolagEMA = ((2 * ma1) - ma2) // Slow line mas1= ema(source , slowLength) mas2 = ema(mas1 , slowLength) zerolagslowMA = ((2 * mas1) - mas2) // MACD line blueMACD = zerolagEMA - zerolagslowMA // Signal line emasig1 = ema(blueMACD, signalLength) emasig2 = ema(emasig1, signalLength) orgMACD = (2 * emasig1) - emasig2 hist = blueMACD - orgMACD circleYPosition = orgMACD*1 dotColor = hist > 0 ? color.aqua : #ff0000 ///////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////// // QQE Programming RSIPeriod = 8 SF = 1 WP = input (3.0, step = 0.01) WildersPeriod = RSIPeriod * 2 - 1 rsi = rsi (close, RSIPeriod) // The basic RSI code RsiMa = ema (rsi, SF) // plot (RsiMa, color = color.blue) // The smoothed RSI using an EMA to smooth it AtrRsi = abs (RsiMa[1] - RsiMa) // The absolute difference between the smoothed RSI's, bar by bar MaAtrRsi = ema (AtrRsi, WildersPeriod) // The smoothed AtrRsi using an EMA dar = ema (MaAtrRsi, WildersPeriod) * WP, // A smoothed, smoothed AtrRsi then multiplied by the WP newShortBand = RsiMa + dar rsi0 = 0.0 rsi0 := RsiMa[1] < rsi0[1] and RsiMa < rsi0[1] ? min (rsi0[1], newShortBand) : newShortBand newLongBand = RsiMa - dar rsi1 = 0.0 rsi1 := RsiMa[1] > rsi1[1] and RsiMa > rsi1[1] ? max (rsi1[1], newLongBand) : newLongBand trend = 0.0 trend := cross (RsiMa , rsi0[1]) ? 1 : cross (RsiMa, rsi1[1]) ? -1 : nz (trend[1], 1) secondRSILine = trend == 1 ? rsi1 : rsi0 // plot (secondRSILine, color = color.orange, linewidth = 2) // hline (50) ///////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////// // Signals on price chart (Jim Brown's QMP Filter) longSituation = barssince(crossover(blueMACD,orgMACD)) < barssince(crossunder(blueMACD,orgMACD)) and RsiMa > secondRSILine shortSituation = barssince(crossover(blueMACD,orgMACD)) > barssince(crossunder(blueMACD,orgMACD)) and RsiMa < secondRSILine upSwitch = longSituation and barssince(longSituation)[1] > barssince(shortSituation)[1] and barstate.isconfirmed plotchar(upSwitch, char="●", color=#39ff14, size=size.tiny, transp=0, location=location.belowbar) downSwitch = shortSituation and barssince(shortSituation)[1] > barssince(longSituation)[1] and barstate.isconfirmed plotchar(downSwitch, char="●", color=#ff0000, size=size.tiny, transp=0, location=location.abovebar) ///////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////// // EMA's sma25 = sma(close, 25) wma240 = wma(close, 240) plot(sma25, color = #FF4500, linewidth=2, transp=0, title = "25 SMA") plot(wma240, color = #000080, linewidth=3, transp=0, title = "240 LWMA") ///////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////// alertcondition (upSwitch, title = "QMP Buy", message = "BUY") alertcondition (downSwitch, title = "QMP Sell", message = "SELL") /////////////////////////////////////////////////////////////////////////////////////////////