Untitled

 avatar
unknown
plain_text
2 years ago
1.7 kB
11
Indexable
//AK MACD BB 

// Updated for Richard C. , June 1 , 2018 



study("AK MACD BB v 1.00")

length = input(10, minval=1, title="BB Periods")
dev = input(1, minval=0.0001, title="Deviations")

//MACD
fastLength = input(12, minval=1) 
slowLength=input(26,minval=1)
signalLength=input(9,minval=1)
fastMA = ema(close, fastLength)
slowMA = ema(close, slowLength)
macd = fastMA - slowMA

//BollingerBands

Std = stdev(macd, length)
Upper = (Std * dev + (sma(macd, length)))
Lower = ((sma(macd, length)) - (Std * dev))

Band1 = plot(Upper, color=green, style=line, linewidth=2)
Band2 = plot(Lower, color=red, style=line, linewidth=2)
fill(Band1, Band2, color=blue, transp=75,title="Fill")

mc = macd > Upper ? lime:na or macd < Lower ? red:na or macd < Upper or macd > Lower ? yellow:na



// Threshold

//t1 = input(-40, minval=-200,title ="low threshold")
//t2 = input(40, minval=0,title ="high threshold")


// Indicator

plot(macd, color=mc, style =circles,linewidth = 3, title = "MACD dot colors")



zeroline = 0 

//plot(t1,color = lime, style = line, linewidth = 2,title ="low threshold")
//plot(t2,color = lime, style = line, linewidth = 2,title ="high threshold")

plot(zeroline,color= white,linewidth= 2)

//buy//
barcolor(macd > Upper ? lime:na)
//short//
barcolor(macd < Lower ? red:na)
// in between
barcolor(macd < Upper ? yellow:na, editable = false)
barcolor(macd > Lower ? yellow:na, editable = false)

alertcondition(macd > Upper, title='Alert:Green Dot', message='Green Dot Generated')
alertcondition(macd < Lower, title='Alert:Red Dot', message='Red Dot Generated')
alertcondition(macd < Upper and macd > Lower, title='Alert:yellow Dot', message='Yellow Dot Generated')

Editor is loading...