//version=5 indicator ('Dhananjay and Ajay Support and Resistance', 'Dhananjay and Ajay Support and Resistance', overlay= true, max_boxes_count= 500, max_labels_count= 500, max_lines_count=500)
leftTip = "Look left for swing high/low in x number of bars to form pivot. The higher the number, the higher the script looks to the left for the highest/lowest point before drawing pivot" rightTip = "Look right for swing high/low in x number of bars to form pivot. The higher the number, the higher the script looks to the right for the highest/lowest point before drawing pivot" nPivTip = "This sets the array size, or the number of pivots to track at a time (x highs, and x number of lows)" atrLenTip = "Number of bars to average. ATR is used to standardize zone width between assets and timeframes" multTip = "ATR multiplier to set zone width. Default is half of one ATR from box bottom to box top" perTip = "Max zone size as a percent of price. Some assets can be too volatile at low prices creating an unreasonably sized zone" maxTip = "Number of boxes for candlestick patterns to track historically. Note: the higher the number the less pivot zones will be tracked when looking back in time due to the limitation on the number of box elements allowed at once" futTip = "Number of bars to offset labels for price levels" srcTip = "Source input for pivots. Default tracks the highest and lowest bodies of HA candles to average price action, which can result in a level that sits in the overlap of support and resistance" alignZonesTip = "Aligns recurring zones who's edges overlap an existing zone creating a zone that ages in time and intensifies visually" extendTip = "Extends current zones right" lLabTip = "Show labels for price levels extended off Key Levels"
dhighsTip = "Disabling will prevent highs from being tracked" dlowsTip = "Disabling will prevent lows from being tracked" detectBOTip = "Show points that price action breaks above all pivots. An arrow from below is displayed" detectBDTip = "Show points that price action breaks below all pivots. An arrow from above is displayed" breakUpTip = "Show points that price action breaks above resistance. An arrow from below is displayed" breakDnTip = "Show points that price action breaks below support. An arrow from above is displayed" falseBullTip = "Show points that price action initially breaks below support before reversing. False moves can lead to fast moves in the opposite direction (bear trap). A large arrow from below is displayed" falseBearTip = "Show points that price action initially breaks above resistance before reversing. False moves can lead to fast moves in the opposite direction (bull trap). A large arrow from above is displayed" supPushTip = "Show up candles that are detected within a support zone. Can show points support is being respected. A triangle from below is displayed" resPushTip = "Show down candles that are detected within a resistance zone. Can show points resistance is being respected. A triangle from above is displayed" curlTip = "Show Bjorgum TSI 'curl' when candles are detected in the range of a key zone. Can show momentum shift at Key Levels. (Correlates to Bjorgum TSI indicator)"
repaintTip = "Wait for candles end before detecting patterns. False will show potential patterns forming before they are confirmed." labelsTip = "Show a label for detected candle patterns" sBoxTip = "Show a box around detected candle patterns" dTip = "Detect Doji candle patterns" beTip = "Detect Engulfing patterns" hsTip = "Detect Hammers and Shooting Star patterns" dgTip = "Detect Dragonfly Doji and Gravestone Doji patterns" twTip = "Detect Tweezer Top and Tweezer Bottom patterns" stTip = "Detect Spinning Top patterns" pcTip = "Detect Piercing and Dark Cloud Cover patterns" bhTip = "Detect Harami candle patterns" lsTip = "Detect Long Upper Shadow and Long Lower Shadow patterns"
ecWickTip = "Determines if engulfing candles must engulf the wick or just the body of the preceding candle" colorMatchTip = "Determines if hammers must be up candles and shooting stars must be down candles" closeHalfTip = "Determines if Tweezer patterns must close beyond the half way point of the preceding candle" atrMaxTip = "Maximum size of setup candles (as a multiplier of the current ATR)" rejectWickTip = "The maximum wick size as a percentage of body size allowable for a rejection wick on the resolution candle of the pattern. 0 disables the filter" hammerFibTip = "The relationship of body to candle size for hammers and stars. (ie. body is 33% of total candle size)." hsShadowPercTip = "The maximum allowable opposing wick size as a percent of body size (ex. top wick for a hammer pattern etc.)" hammerSizeTip = "The minimum size of hammers, stars, or long shadows as a multiplier of ATR. (To filter out tiny setups)" dojiSizeTip = "The relationship of body to candle size (ie. body is 5% of total candle size)." dojiWickSizeTip = "Maximum wick size comparative to the opposite wick. (eg. 2 = bottom wick must be less than or equal to 2x the top wick)." luRatioTip = "A relationship of the upper wick to the overall candle size expressed as a percent."
lookbackTip = "Number of candles that can be included in a false break signal" swingTip = "Swing detection is used to filter signals on breakout type signals. A higher number will mean more significant points, but less of them" reflectTip = "Filter to ensure a setup is a significant swing point. Look back this far" offsetTip = "Candle pattern high/low distance from absolute swing high/low. Example: 0 would filter patterns that are only the highest/lowest, 1 filters second highest over the significant length, etc."
bullPivotTip = "Color of bullish Key Levels\n(border, background)" bearPivotTip = "Color of bearish Key Levels\n(border, background)" breakoutTip = "Color of breakout arrows\n(bull, bear,)" SnRTip = "Color of triangles for broken support or resistance\n(bull, bear)" falseBreakTip = "Color of arrows for false breaks\n(bull, bear, arrow max height in pixels)" moveTip = "Color of triangles for candles that are detected within zones\n(bull, bear)" patTip = "Color of boxes that wrap candestick patterns\nBackgrounds: (bull, neutral, bear)\nBorders: (bull, neutral, bear)" labTip = "Color of labels that mark candestick patterns\nText: (bull, neutral, bear)\nLabels: (bull, neutral, bear)" stratTip = "TSI speed control presets. Both speeds correlate to the Bjorgum TSI indicator"
var pivotHigh = array.new_box (nPiv) var pivotLows = array.new_box (nPiv) var highBull = array.new_bool (nPiv) var lowsBull = array.new_bool (nPiv) var boxes = array.new_box ()
_align(_x,_y) => for i = 0 to array.size (_x) -1 [_T, _B] = _getBox (_y, 0) [_t, _b] = _getBox (_x, i) if _T > _b and _T < _t or _B < _t and _B > _b or _T > _t and _B < _b or _B > _b and _T < _t box.set_top (array.get (_y, 0), _t) box.set_bottom (array.get (_y, 0), _b)
_color(_x, _y) => var int _track = nPiv for i = 0 to array.size (_x) -1 [t_, b_] = _getBox (_x, i) _isBull = array.get (_y, i) if close > t_ and not _isBull box.set_extend( array.get (_x, i), extend.none) array.set(_x, i, _box (sync , t_, sync, b_, bullBorder, bullBgCol, extrap)) array.set(_y, i, true) _track += 1 if close < b_ and _isBull box.set_extend( array.get (_x, i), extend.none) array.set(_x, i, _box (sync , t_, sync, b_, bearBorder, bearBgCol, extrap)) array.set(_y, i, false) _track -= 1 _track
_detect(_x,_y) => int _i = 0 bool _found = false bool _isBull = na while (not _found and _i < array.size (_x) ) [t_, b_] = _getBox (_x,_i) if low < t_ and high > b_ _isBull := array.get (_y,_i) _found := true _i += 1 [_found, _isBull]
_falseBreak(_l) => bool _d = false bool _u = false for i = 1 to lookback if _l < _l and _l[i+1] >= _l and _l[1] < _l _d := true if _l > _l and _l[i+1] <= _l and _l[1] > _l _u := true [_d, _u]
_numLevel(_x,_y) => int _above = 0 int _fill = 0 for i = 0 to array.size (_x)-1 _isBull = array.get (_x,i) if _isBull _above += 1 if not na(_isBull) _fill += 1 for i = 0 to array.size (_y)-1 _isBull = array.get (_y,i) if _isBull _above += 1 if not na(_isBull) _fill += 1 [_above, _fill]
_check(_src,_l) => bool _check = false for i = 0 to _l if _src _check := true _check
_count(_src, _l) => int _result = 0 for i = 0 to _l if _src > _src _result += 1 _result
_label(_x, _y, y, _s, _col1, _col2) => transp = math.min (color.t(_col1), color.t(_col2)) array.unshift (_x, label.new (sync+fut, y , text = str.tostring(math.round_to_mintick(y) ), color = color.new(_col1, transp) , style = _s , textcolor = color.white )) if not extend and fut > 0 array.unshift (_y, line.new (sync, y, sync+fut, y, color= color.new(_col1, transp)))
_level(_x, _y) => var label [] lab = array.new_label (nPiv) var line [] lines = array.new_line (nPiv) if barstate.islast and lLab _delLevels (lab, lines) for i = 0 to array.size (_x)-1 [_t, _b] = _getBox (_x,i) _isBull = array.get (_y,i) _col1 = _isBull ? bullBgCol : bearBgCol _col2 = _isBull ? bullBorder : bearBorder if close > _t _label (lab, lines, _t, labUp, _col1, _col2) if close < _b _label (lab, lines, _b, labDn, _col1, _col2) if close < _t and close > _b _label (lab, lines, _t, labDn, _col1, _col2) _label (lab, lines, _b, labUp, _col1, _col2)
_alert(_x, _y) => if _x alert (_y + timeframe.period + ' chart. Price is ' + str.tostring(close), alertMode)
bull = (fh or fl) and (hb or lb) bear = (fh or fl) and not (hb or lb)
bullCheck = not resBreak and not resBreak[1] and (fh or fl) and close > open and (hb or lb) bearCheck = not supBreak and not supBreak[1] and (fh or fl) and close < open and not (hb or lb)
dw = isBull1 and rp and d_ and atrMaxSize and bj.doji (dojiSize = dojiSize, dojiWickSize = dojiWickSize) db = isBear1 and rp and d_ and atrMaxSize and bj.doji (dojiSize = dojiSize, dojiWickSize = dojiWickSize) bew = isBull2 and rp and be_ and atrMaxSize and bj.bullEngulf (maxRejectWick = rejectWickMax, mustEngulfWick = ecWick) beb = isBear2 and rp and be_ and atrMaxSize and bj.bearEngulf (maxRejectWick = rejectWickMax, mustEngulfWick = ecWick) h = isBull1 and rp and hs_ and atrMaxSize and bj.hammer (ratio = hammerFib, shadowPercent = hsShadowPerc) and hsFilter and hMatch ss = isBear1 and rp and hs_ and atrMaxSize and bj.star (ratio = hammerFib, shadowPercent = hsShadowPerc) and hsFilter and sMatch dd = isBull1 and rp and dg_ and atrMaxSize and bj.dragonflyDoji () gd = isBear1 and rp and dg_ and atrMaxSize and bj.gravestoneDoji () tb = isBull2 and rp and tw_ and atrMaxSize and bj.tweezerBottom (closeUpperHalf = closeHalf) tt = isBear2 and rp and tw_ and atrMaxSize and bj.tweezerTop (closeLowerHalf = closeHalf) stw = isBull1 and rp and st_ and atrMaxSize and bj.spinningTop () stb = isBear1 and rp and st_ and atrMaxSize and bj.spinningTop () p = isBull1 and rp and pc_ and atrMaxSize and bj.piercing () dcc = isBear1 and rp and pc_ and atrMaxSize and bj.darkCloudCover () bhw = isBull1 and rp and bh_ and atrMaxSize and bj.haramiBull () bhb = isBear1 and rp and bh_ and atrMaxSize and bj.haramiBear () ll = isBull1 and rp and ls_ and atrMaxSize and bj.lls (ratio = luRatio) and hsFilter lu = isBear1 and rp and ls_ and atrMaxSize and bj.lus (ratio = luRatio) and hsFilter