Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=3
- study("MACD-DEMA Trendless Indıcator Series-2")
- maperiod=input(9)
- ema=ema(close,maperiod)
- fastmacd = input(12,title='MACD Fast Line Length')
- slowmacd = input(48,title='MACD Slow Line Length')
- signalmacd = input(9,title='Signal Line Length')
- macdslowline1 = ema(ema,slowmacd)
- macdslowline2 = ema(macdslowline1,slowmacd)
- DEMAslow = ((2 * macdslowline1) - macdslowline2 )
- macdfastline1 = ema(ema,fastmacd)
- macdfastline2 = ema(macdfastline1,fastmacd)
- DEMAfast = ((2 * macdfastline1) - macdfastline2)
- MACDLine = (DEMAfast - DEMAslow)
- SignalLine1 = ema(MACDLine, signalmacd)
- SignalLine2 = ema(SignalLine1, signalmacd)
- SignalLine = ((2 * SignalLine1) - SignalLine2 )
- MACDSignal = MACDLine-SignalLine
- colorbar= MACDSignal>0?green:red
- plot(MACDSignal,color=colorbar,style=columns,title='Histogram',histbase=0)
- p1 = plot(MACDLine,color=blue,title='MACDLine')
- p2=plot(SignalLine,color=red,title="SignalLine")
- fill(p1,p2,color=blue)
- upper = SignalLine
- lower = MACDLine
- // DIVS code
- piv = input(false,"Hide pivots?")
- shrt = input(false,"Shorter labels?")
- xbars = input(20, "period", integer, minval=1)
- hb = abs(highestbars(upper, xbars))
- lb = abs(lowestbars(lower, xbars))
- max = na
- max_upper = na
- min = na
- min_lower = na
- pivoth = na
- pivotl = na
- max := hb == 0 ? close : na(max[1]) ? close : max[1]
- max_upper := hb == 0 ? upper : na(max_upper[1]) ? upper : max_upper[1]
- min := lb == 0 ? close : na(min[1]) ? close : min[1]
- min_lower := lb == 0 ? lower : na(min_lower[1]) ? lower : min_lower[1]
- if close > max
- max := close
- if upper > max_upper
- max_upper := upper
- if close < min_lower
- min_lower := lower
- if lower < min_lower
- min_lower := lower
- // Finds pivot point with at least 2 right candles with lower value
- pivoth := (max_upper == max_upper[2]) and (max_upper[2] != max_upper[3]) ? true : na
- pivotl := (min_lower == min_lower[2]) and (min_lower[2] != min_lower[3]) ? true : na
- plotshape(piv ? na : shrt ? na : pivoth ? max_upper + 2 : na, location=location.absolute, style=shape.labeldown, color=red, size=size.tiny, text="Pivot", textcolor=white, transp=0, offset=0)
- plotshape(piv ? na : shrt ? na : pivotl ? min_lower - 2 : na, location=location.absolute, style=shape.labelup, color=blue, size=size.tiny, text="Pivot", textcolor=white, transp=0, offset=0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement