Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Hello tradeurs, ChasinAlts here with a script you've DEFINITELY never seen before. Hope everyone is well. Ok, so heres the low-down...When a wick's
- // % size is abvoe the threshold set by the user it is plotted with light blue (these aren't really the significant ones) and are put into an array.
- // These large wick lines are great S&R lines but we're looking to filter out to only the best ones. So, after all the large wicks are recorded for the
- // chart and lines drawn, it then calculates the area between each of these lines in % (you can think of the lines as the upper and lower lines to a box
- // if youd like...ie. it is one of the ways to view the final BEST S&R lines). What we are want is the largest of ALL the % areas between lines and to
- // use these as our ultimate S&R Areas. Depending on the Min % Wick size that is chosen, you will find price usually either bouncing between these levels or
- // that price will keep bouncing off of the same level until a large spike (up or down) occurs in price and the price will finally breach the level its been
- // testing over and over. Once this DOES occur the level that was just broken many times will be the furthest point back for the retest. Now, as stated
- // before there are 2 ways to view the output data. Either way it will show the largest % area between the lines as it is developing down the line of
- // progressing bars on the chart (that means it WILL change but usually a portion of the previous area/box will be used for the newer smaller box or that
- // the area/box will jump back and forth between the same few areas every now and again). Viewing it as a box will show the updated largest box
- // (as stated twice now) but viewing it in it's S&R Line form will draw a new S&R line at the top and bottom of where the box would be if it was selected
- // EXCEPT that these lines will persist across bars and you will continuously see how these levels will continue to be revisted and constantly used
- // as S&R Lines as time progresses. (SO box only show the largest area and lines draws line at the top and bottom of box and persists across bars).
- // There is not repainting that can occur. I hope you all enjoy this as I've found it EXTREMELY beneficial bc it's rare that when price first gets to a
- // printed S&R level that it wil shooot through it so you can depend on it bouncing off the the levels often multiple times. I've included comments in all
- // of the code for your convenience. Also, the higher subscription plan you have (thus the more bars/data you have access to...the more S&R Lines will be drawn).
- // Wish you all the best in your endevors and may the force be with your trades, and as ALWAYS...peace and love people....peace and love. ChasinAlts out.
- //@version=5
- indicator("Wicked Good S&R Zones", overlay=true, max_lines_count=500)
- wkPmin = input.float(2.5, step=.25, title="Minimum (%) Wick Size to use as Line")
- draw = input.string("Boxes", title="Draw Support & Resistance _____", options=["Boxes", "Lines"])
- showLines = input.bool(true, title="Show Large Wick Lines?"), tooltip="These are not the 'Wicked Good S&R Lines' but rather the lines that derive thems"
- wickLnCol = input.color(color.new(#0095ff,75), title="Large Wicks Line Color")
- boxCol = input.color(color.new(#ffff00,60), title="Supp & Res Box Color")
- //== FUNCTIONS ==\\
- f_SuppReme_Wick_lines(_open,_high,_low,_close,_time,_timeclose) =>
- //== FUNCTION INITIALIZATIONS ==\\
- var allLnArr=array.new_float(0), topArr=array.new_float(0), botArr=array.new_float(0), diffArr=array.new_float(0), diffCopy=array.new_float(0), var SnRarr=array.new_float(0), var SnRLinesArr=array.new_line(0), var boxArr=array.new_box(0), var bx=box(na), var bot=0.0, var top=0.0
- //== MAIN LOGIC ==\\
- grn = _close > _open
- red = _close < _open
- uw = (math.abs(_high-(grn?_close:_open))/_close)*100 >= wkPmin // upper and lower wick size calculations
- lw = (math.abs((red?_close:_open)-_low)/_close)*100 >= wkPmin // upper and lower wick size calculations
- hilo = uw ? _high : _low
- if uw or lw
- array.push(allLnArr, hilo) // pushes wicks above the % size threshold into an array
- if showLines // If user selects to view all Large Wick Lines...
- line.new(_time[1], hilo, _time, hilo,
- xloc = xloc.bar_time,
- extend = extend.right,
- color = wickLnCol,
- style = line.style_solid) // Plots all lines in array for visualization
- array.sort(allLnArr,order.ascending) // Sorts all lines in array by price
- if array.size(allLnArr)>0
- for [i,val] in allLnArr // This 'for...in' loop creates a sort of fake box with upper/lower boundaries being the lines in array that were sorted to get size between each set of lines in array
- top := bot, array.push(topArr,top)
- bot := val, array.push(botArr,bot)
- array.push(diffArr, ((top-bot)/bot)*100) // This line specifically gets the size of the area (in %) between all the lines in the array
- diffCopy := array.copy(diffArr) // Creates copy of % Size between Lines Array to sort
- array.sort(diffCopy,order.ascending) // Sorts % Size Arr
- idx = array.indexof(diffArr,array.get(diffCopy,0)) // uses the first entry in the Sorted Area Size(in %) Array to get the index of the Upper/Lower Lines (that belong to the Largest % Area) from the original Line Array in the beginning of script
- Top = array.get(topArr,idx) // Gets top line in Arr and...
- Bot = array.get(botArr,idx) // Gets bottom line in Arr and...
- if draw=="Lines" // View S&R Lines
- if not array.includes(SnRarr,Top) // Tests if S&R Arr already includes the line
- array.push(SnRarr,Top) // If not, pushes it into S&R Arr for end result
- array.push(SnRLinesArr, line.new(_time[1], Top, _time, Top,
- xloc = xloc.bar_time,
- extend = extend.right,
- color = _close>=Top ? #00FF00 : #FF0000,
- style = line.style_solid)) // Plots line if not already included in Arr
- if not array.includes(SnRarr,Bot) // Tests if S&R Arr already includes the line
- array.push(SnRarr,Bot) // If not, pushes it into S&R Arr for end result
- array.push(SnRLinesArr, line.new(_time[1], Bot, _time, Bot,
- xloc = xloc.bar_time,
- extend = extend.right,
- color = _close<=Bot ? #FF0000 : #00FF00,
- style = line.style_solid)) // Plots line if not already included in Arr
- for ln in SnRLinesArr
- line.set_color(ln, _close>=line.get_y2(ln) ? #00FF00 : #FF0000) // Changes S&R Lines Color to be green if below price and red if above price
- if draw=="Boxes" // To view S&R Box
- box.set_right(bx,time) // Extends current box to current bar
- if Top!=Top[1] or Bot!=Bot[1]
- bx := box.new(time[1], Top, time, Bot,
- border_color = boxCol,
- bgcolor = boxCol,
- border_style = line.style_solid,
- extend = extend.none,
- xloc = xloc.bar_time) // Plots new Box if the Largest % Gap between lines changes (if the largest box on the chart changes)
- array.unshift(boxArr,bx)
- f_SuppReme_Wick_lines(open,high,low,close,time,time_close) // Call to Main Function(created a function for this to use in a "Market Overview" Scanner much like many of my other scripts)
Advertisement
Add Comment
Please, Sign In to add comment