Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fastMA = input(title="MACD Fast moving average", type = integer, defval = 12, minval = 7)
- slowMA = input(title="MACD Slow moving average", type = integer, defval = 26, minval = 7)
- lastColor = yellow
- [currMacd,_,_] = macd(close[0], fastMA, slowMA, 9)
- [prevMacd,_,_] = macd(close[1], fastMA, slowMA, 9)
- signalLength=input(9,minval=1, title="MACD Signal Length")
- signal = sma(currMacd, signalLength)
- //alertcondition(currMacd > 0 and prevMacd < 0, title = "Cross Upwards", message = "Macd Upwards")
- //alertcondition(currMacd < 0 and prevMacd > 0, title = "Cross Downwards", message = "Macd Downwards")
- //alertcondition((currMacd > 0 and currMacd < prevMacd) or (currMacd < 0 and currMacd > prevMacd) , title = "Direction Change", message = "Macd Change")
- //alertcondition(currMacd < 0 and ( prevMacd > 0, title = "Cross Downwards", message = "Macd Downwards")
- plotColor = currMacd > 0 ? currMacd > prevMacd ? lime : green : currMacd < prevMacd ? maroon : red
- //plot(currMacd, style = columns, transp=20, color = plotColor, linewidth = 3)
- //plot(0, title = "Zero line", linewidth = 1, color = gray)
- //plot(signal, color=white, transp=0, title="Signal")
- //stoch
- smoothK = input(3, minval=1, title="Stoch RSI K")
- smoothD = input(3, minval=1, title="Stoch RSI D")
- lengthRSI = input(7, minval=1, title="Stoch RSI Length")
- lengthStoch = input(7, minval=1,title="Stock Length")
- src4 = input(close, title="Stoch RSI Source")
- rsi1 = rsi(src4, lengthRSI)
- k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
- d = sma(k, smoothD)
- //plot(k)
- //plot(d)
- //RSI
- length = input( 14, title="RSI Length" )
- overSold = input( 35 , title="RSI Oversold")
- overBought = input( 80,title="RSI Overbought" )
- price = close
- vrsi = rsi(price, length)
- //plot(vrsi)
- //BB
- source = close
- bblength = input(20, title= "BB Length", minval=1)
- mult = input(2.0, minval=0.001, maxval=50, title="BB Mult")
- bbmin = input(0.2, title="BB Min range")
- bbmax = input(1.0, title="BB MMax range")
- basis = sma(source, bblength)
- dev = mult * stdev(source, bblength)
- upper = basis + dev
- lower = basis - dev
- bbpercentage = (close - lower) / (upper - lower)
- //plot(bbpercentage)
- volpercentageinc = input(5, title="Volume Percentage Increase") / 100
- barssincesignal = input(5, title="Bars Since Signal")
- volumeup = volume[0] > volume[1] * (1 + volpercentageinc) and volume[1] > volume[2] * (1 + volpercentageinc)
- buy = crossover(k,d) and vrsi < overSold and bbpercentage <= bbmin
- sell = bbpercentage >= bbmax and crossover(d,k)
- volupinrange = volumeup and barssince(buy) < barssincesignal
- //sell = bbpercentage >= bbmax and crossover(d,k)
- //conditionmet = k >
- //colorbg =(currMacd < 0) and (slow_percentD > percentD) and(vrsi >= 70) ? red : (currMacd > 0) and (slow_percentD < percentD) and (vrsi <= 30) ? green:na
- //plotshape(conditionmet, style=shape.arrowup)
- alertcondition(buy, title = "Conditions Met", message = "Conditions Met")
- alertcondition(sell, title = "Sell", message = "Sell")
- alertcondition(volupinrange, title = "Buy", message = "Buy")
- //colorbg = buy ? green : sell ? red : na
- plotshape(buy,style=shape.arrowup, color=black, size = size.huge)
- plotshape(sell,style=shape.arrowdown, color=red, size = size.huge)
- plotshape(volupinrange,style=shape.arrowup, color=green, size = size.huge)
- //plotshape(volumeup,style=shape.arrowup, color=orange)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement