Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- study(title = "Picker, TD, Stoch", shorttitle="Picker, TD, Stoch",overlay=true)
- //------------------------------------------------------------------------------------------------Picker
- //study(title = "lastbattles nose picker", shorttitle="Nose Picker",overlay=true)
- // Inputs
- rsiPeriod = input(14, title="RSI period")
- //atrPeriod = input(20, title="ATR period")
- overbought = input(67, title="Overbought Signal", minval=1, maxval=100)
- oversold = input(35, title="Oversold Signal", minval=1, maxval=100)
- volatilitymultiplier = input(1, title="Volatility multiplier", minval=0, maxval=5)
- //atrTimeframe = input(defval="7", title="ATR Timeframe", type=resolution)
- rsiTimeframe1 = input(defval="1", title="RSI Timeframe 1", type=resolution)
- rsiTimeframe2 = input(defval="3", title="RSI Timeframe 2", type=resolution)
- rsiTimeframe3 = input(defval="5", title="RSI Timeframe 3", type=resolution)
- rsiTimeframe4 = input(defval="15", title="RSI Timeframe 4", type=resolution)
- rsiTimeframe5 = input(defval="1", title="RSI Timeframe 5", type=resolution)
- rsiTimeframe6 = input(defval="1", title="RSI Timeframe 6", type=resolution)
- // Functions
- isSellSignal(rsi1, rsi2, rsi3, rsi4, rsi5, rsi6, overbought) => (rsi1 >= overbought and rsi2 >= overbought and rsi3 >= overbought and rsi4 >= overbought and rsi5 >= overbought and rsi6 >= overbought)
- isBuySignal(rsi1, rsi2, rsi3, rsi4, rsi5, rsi6, oversold) => (rsi1 <= oversold and rsi2 <= oversold and rsi3 <= oversold and rsi4 <= oversold and rsi5 <= oversold and rsi6 <= oversold)
- // RSI values
- rsi1 = security(tickerid,rsiTimeframe1, rsi(close, rsiPeriod))
- rsi2 = security(tickerid,rsiTimeframe2, rsi(close, rsiPeriod))
- rsi3 = security(tickerid,rsiTimeframe3, rsi(close, rsiPeriod))
- rsi4 = security(tickerid,rsiTimeframe4, rsi(close, rsiPeriod))
- rsi5 = security(tickerid,rsiTimeframe5, rsi(close, rsiPeriod))
- rsi6 = security(tickerid,rsiTimeframe6, rsi(close, rsiPeriod))
- // ATR values in percentage wise
- //atr = security(tickerid,atrTimeframe, ema(tr*100/close[1], atrPeriod))
- //atr_percentagePrice = close[1] * 0.01 * atr
- //multiplier_atr = abs(1 / (2 - atr_percentagePrice)) // absolute value of multiplier
- // volatility switch
- dr= security(tickerid,"60", roc(close,1)) / security(tickerid,"60", sma(close,2))
- vola14=stdev(dr, 14)
- vswitch14=((vola14[1] <= vola14 ) + (vola14[2] <= vola14 ) + (vola14[3] <= vola14 ) +
- (vola14[4] <= vola14 ) + (vola14[5] <= vola14 ) + (vola14[6] <= vola14 ) +
- (vola14[7] <= vola14 ) + (vola14[8] <= vola14 ) + (vola14[9] <= vola14 ) +
- (vola14[10] <= vola14 ) + (vola14[11] <= vola14 ) + (vola14[12] <= vola14 ) +
- (vola14[13] <= vola14 ) + 1) / 14
- volatility_multiplier = abs(1 / (volatilitymultiplier - vswitch14))
- //plot(multiplier_atr + close, style=line, linewidth=2, color=#FF0000)
- //plot(atr_percentagePrice, style=line, linewidth=2, color=#FF0000)
- //plot(rsi1, style=line, linewidth=2, color=#FF0000)
- //plot(rsi2, style=line, linewidth=2, color=#FF8000)
- //plot(rsi3, style=line, linewidth=2, color=#FFFF00)
- //plot(rsi4, style=line, linewidth=2, color=#80FF00)
- //plot(rsi5, style=line, linewidth=2, color=#00FFFF)
- //plot(volatility_multiplier * 2 + close, color=red, linewidth=2, title="VOLSWITCH_21")
- sellsignal = isSellSignal(rsi1, rsi2, rsi3, rsi4, rsi5, rsi6, overbought + volatility_multiplier)
- buysignal = isBuySignal(rsi1, rsi2, rsi3, rsi4, rsi5, rsi6, oversold - (volatility_multiplier / 2))
- spartasellsignal = isSellSignal(rsi1, rsi2, rsi3, rsi4, rsi5, rsi6, 80)
- spartabuysignal = isBuySignal(rsi1, rsi2, rsi3, rsi4, rsi5, rsi6, 20)
- // regular signals
- plot(interval == 15 and sellsignal ? low : na, title="caution sell", color=red, style=columns, transp=50 , linewidth=7)
- plot(interval == 15 and buysignal ? low : na, title="caution buy", color=green, style=columns, transp=50, linewidth=7)
- // super signals! spartaaa
- plot(interval == 15 and spartasellsignal ? low : na, title="super caution sell", color=red, style=columns, transp=0 , linewidth=7)
- plot(interval == 15 and spartabuysignal ? low : na, title="super caution buy", color=green, style=columns, transp=0, linewidth=7)
- // regular signals
- plotchar(interval == 15 and sellsignal ? close : na, title="caution sell", color=red, charstyle="*", size=size.tiny, transp=50 , linewidth=7)
- plotchar(interval == 15 and buysignal ? close : na, title="caution buy", color=green, charstyle="*", size=size.tiny, transp=50, linewidth=7)
- // super signals! spartaaa
- plotchar(interval == 15 and spartasellsignal ? close : na, title="super caution sell", color=red, charstyle="*", size=size.tiny, transp=0 , linewidth=7)
- plotchar(interval == 15 and spartabuysignal ? close : na, title="super caution buy", color=green, charstyle="*", size=size.tiny, transp=0, linewidth=7)
- //plotchar(isSellSignal(rsi1, rsi2, rsi3, rsi4, rsi5, overbought), char='S')
- //plotchar(isBuySignal(rsi1, rsi2, rsi3, rsi4, rsi5, oversold), char='B')
- //h1 = hline(0)
- //h2 = hline(100)
- //fill(h1, h2)
- //------------------------------------------------------------------------------------------------TD
- ////@version=2
- //study("Demark TD Sequential Alerts (Simplified)", shorttitle="TD", overlay=true)
- // With thanks to the scripts by glaz, bioharz and stripykitteh
- // But mostly this page, which explains it beautifully: https://tradetrekker.wordpress.com/tdsequential/
- show_sigs = input(title="Only 9s & 13s", type=bool, defval=false)
- Count=close>close[4]?1:0
- Count1=Count==1?nz(Count1[1])==0?1:Count1[1]==1?2:Count1[1]==2?3:Count1[1]==3?4:Count1[1]==4?5:Count1[1]==5?6:Count1[1]==6?7:Count1[1]==7?8:Count1[1]==8?9:0:0
- Counta=close<close[4]?1:0
- Count2=Counta==1?nz(Count2[1])==0?1:Count2[1]==1?2:Count2[1]==2?3:Count2[1]==3?4:Count2[1]==4?5:Count2[1]==5?6:Count2[1]==6?7:Count2[1]==7?8:Count2[1]==8?9:0:0
- piepb=Count1==9 and piepb[1]==0?1:piepb[1]>0?piep2[1]==13?0:nz(piepb[1])+1:0
- piep2=piepb>0 and close>high[2] and close>high[1]?piep2[1]==13?0:nz(piep2[1])+1:piep2[1]==13?0:piep2[1]
- piepa=Count2==9 and piepa[1]==0?1:piepa[1]>0?piep[1]==13?0:nz(piepa[1])+1:0
- piep=piepa>0 and close<low[2] and close<low[1]?piep[1]==13?0:nz(piep[1])+1:piep[1]==13?0:piep[1]
- col_green = color(maroon, 0)
- col_red = color(green, 0)
- // quick fox
- plotshape(Count1==1, title='1', text='1', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=red, offset=0)
- plotshape(Count1==2, title='2', text='2', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=red, offset=0)
- plotshape(Count1==3, title='3', text='3', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=red, offset=0)
- plotshape(Count1==4, title='4', text='4', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=red, offset=0)
- plotshape(Count1==5, title='5', text='5', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=red, offset=0)
- plotshape(Count1==6, title='6', text='6', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=red, offset=0)
- plotshape(Count1==7, title='7', text='7', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=white, offset=0)
- plotshape(Count1==8, title='8', text='8', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=white, offset=0)
- //plotchar(Count1==9,char='9', color=col_green)
- plotshape(Count1==9, title='9', text='9', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=white, offset=0)
- plotshape(Count2==1, title='1', text='1', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=green, offset=0)
- plotshape(Count2==2, title='2', text='2', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=green, offset=0)
- plotshape(Count2==3, title='3', text='3', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=green, offset=0)
- plotshape(Count2==4, title='4', text='4', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=green, offset=0)
- plotshape(Count2==5, title='5', text='5', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=green, offset=0)
- plotshape(Count2==6, title='6', text='6', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=green, offset=0)
- plotshape(Count2==7, title='7', text='7', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=white, offset=0)
- plotshape(Count2==8, title='8', text='8', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=white, offset=0)
- //plotchar(Count2==9,char='9', color=col_red)
- plotshape(Count2==9, title='9', text='9', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=white, offset=0)
- // when you want to plot same two items plotshape(piep==13 and piep[1]==12?low*0.85: na, text='13', location=location.absolute, style=shape.triangledown, color=lime)
- plotshape(piep2==11 and piep2[1]==10?1 and not show_sigs: na, title='11', text='11', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=red, offset=0)
- plotshape(piep2==12 and piep2[1]==11?1 and not show_sigs: na, title='12', text='12', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=red, offset=0)
- //plotshape(piep2==13 and piep2[1]==12?1: na, text='13', location=location.belowbar, style=shape.triangleup, color=col_green)
- plotshape(piep2==13 and piep2[1]==12?1: na, title='13', text='13', style=shape.labeldown, location=location.abovebar, color=col_green, textcolor=white, offset=0)
- plotshape(piep==11 and piep[1]==10?1 and not show_sigs: na, title='11', text='11', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=green, offset=0)
- plotshape(piep==12 and piep[1]==11?1 and not show_sigs: na, title='12', text='12', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=green, offset=0)
- //plotshape(piep==13 and piep[1]==12?1: na, text='13', location=location.belowbar, style=shape.triangledown, color=col_red)
- plotshape(piep==13 and piep[1]==12?1: na, title='13', text='13', style=shape.labelup, location=location.belowbar, color=col_red, textcolor=white, offset=0)
- alertcondition(Count2==9, title='TD: Buy 9', message='TD Buy 9: ')
- alertcondition(Count1==9, title='TD: Sell 9', message='TD Sell 9: ')
- alertcondition(piep==13 and piep[1]==12, title='TD: Buy 13', message='TD Buy 13: ')
- alertcondition(piep2==13 and piep2[1]==12, title='TD: Sell 13', message='TD Sell 13: ')
- //------------------------------------------------------------------------------------------------Stoch Highlight
- ////Created by ChrisMoody on October 23, 2014 by user request - belgusinc
- //Changes Barcolor when Stochastic is Overbought Oversold.
- //Necessary for Highlight Bars
- //Only Necessary if you want you want Stochastic Croses
- //study(title="CM_Stochastic_Highlight Bars", shorttitle="Stoch Highlight", overlay=true)
- len = input(5, minval=1, title="Length for Stochastic")
- smoothK = input(5, minval=1, title="SmoothK for Stochastic")
- smoothD = input(5, minval=1, title="SmoothD for Stochastic")
- upLine = input(80, minval=50, maxval=90, title="Upper Line Value?")
- lowLine = input(20, minval=10, maxval=50, title="Lower Line Value?")
- //Not Necessary, In Inputs Tab, capability to turn On/Off Highlight Bars, and Both Crosses
- //These are all checkboxes in inputs tab....Show Barcolor Highlights, Show Background Hghlight, Plot B and S for Buy Sell
- sbc = input(true, title="Show Price Bar highlight When Stoch is Above/Below High/Low Lines?")
- sbh = input(false, title="Show Background highlight When Stoch is Above/Below High/Low Lines?")
- sch = input(false, title="Show Back Ground Highlights When Stoch Cross - Strict Criteria - K Greater/LesThan High/Low Line - Crosses D ?")
- sl = input(false, title="Show 'B' and 'S' Letters When Stoch Crosses High/Low Line & D?")
- sac = input(false, title="Show Back Ground Highlights When Stoch Cross - Any Cross?")
- sacl = input(false, title="Show 'B' and 'S' Letters When Stoch Crosses - Any Cross?")
- //Necessary for Highlight Bars
- //Stoch formula
- k = sma(stoch(close, high, low, len), smoothK)
- d = sma(k, smoothD)
- //Necessary for Highlight Bars
- //aboveline = OverBought, belowline = Oversold Definitions
- aboveLine = k > upLine ? 1 : 0
- belowLine = k < lowLine ? 1 : 0
- //Only Necessary if you want you want Stochastic Croses
- //Definition for Cross when Above High-Low lines
- crossUp = (k[1] < d[1] and k[1] < lowLine[1]) and (k > d) ? 1 : 0
- crossDn = (k[1] > d[1] and k[1] > upLine[1]) and (k < d) ? 1 : 0
- //Only Necessary if you want you want Stochastic Croses
- //Definition for Cross that doesn't have to be above or below High and Low line.
- crossUpAll = (k[1] < d[1] and k > d) ? 1 : 0
- crossDownAll = (k[1] > d[1] and k < d) ? 1 : 0
- //Only Necessary if you want background Highlighting also - Take out the sbh/sbc and part
- //BackGround Highlights based on Above/Below Lines, Strict Cross Up/Down
- //BackGroound Color Plots
- bgcolor(sbh and aboveLine ? red : na, transp=70)
- bgcolor(sbh and belowLine ? lime : na, transp=70)
- bgcolor(sch and crossUp ? lime : na, transp=40)
- bgcolor(sch and crossDn ? red : na, transp=40)
- //Only Necessary if you want background Highlighting also
- //plots bgcolor Cross with no filter
- bgcolor(sac and crossUpAll ? lime : na, transp=40)
- bgcolor(sac and crossDownAll ? red : na, transp=40)
- //Necessary for Highlight Bars
- //Highlight Bar Definitions
- overBought() => sbc and aboveLine
- overSold() => sbc and belowLine
- //Necessary for Highlight Bars
- //Highlight Bar Plot Statement based on Above Definitions
- barcolor(overBought() ? orange : overSold() ? fuchsia : na)
- //Not Necessary if you just want Highlight Bars - Extra Feature
- //These are just the Letters B and Sell Based on Crosses
- plotchar(sl and crossUp ? crossUp : na, title="Buy Signal Strict Criteria", char='B', size=size.tiny, location=location.belowbar, color=lime, transp=0, offset=0)
- plotchar(sl and crossDn ? crossDn : na, title="Sell Signal Strict Criteria", char='S', size=size.tiny, location=location.abovebar, color=red, transp=0, offset=0)
- plotchar(sacl and crossUpAll ? crossUpAll : na, title="Buy Signal Any Cross Up", char='B', size=size.tiny, location=location.belowbar, color=lime, transp=0, offset=0)
- plotchar(sacl and crossDownAll ? crossDownAll : na, title="Sell Signal Any Cross Down", char='S', size=size.tiny, location=location.abovebar, color=red, transp=0, offset=0)
- //------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement