Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=2
- study(title="MACD Histogram Direction Evaluator Alerts")
- //src = security(tickerid, "1W", close)
- src = close
- fastLength = input(20, minval=1)
- slowLength=input(52,minval=1)
- signalLength=input(9,minval=1)
- fastMA = ema(src, fastLength)
- slowMA = ema(src, slowLength)
- macd = fastMA - slowMA
- signal = sma(macd, signalLength)
- hist = macd - signal
- pos_hist = max(0, hist)
- neg_hist = min(0, hist)
- plot(pos_hist, color=green, style=histogram, linewidth=2, title='')
- plot(neg_hist, color=red, style=histogram, linewidth=2, title='')
- oscMins= neg_hist > neg_hist[1] and neg_hist[1] < neg_hist[2] // this line identifies bottoms
- oscMax = pos_hist < pos_hist[1] and pos_hist[1] > pos_hist[2] // this line identifies tops
- plot(oscMax ? hist : na, title="Top", style=circles, linewidth=2, color=maroon)
- plot(oscMins ? hist : na, title="Bottom", style=circles, linewidth=2, color=green)
- // Only trade in the direction of the overall trend. IMPORTANT! If uptrend is true then it's an upward trend.
- uptrend = if hist > 0
- true
- else
- false
- //plot(uptrend)
- //plot(macd, color=teal)
- //plot(signal, color=orange)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement