Untitled

 avatar
unknown
plain_text
a year ago
50 kB
24
Indexable
Gokmen:
//@version=5 indicator("Razzere ", overlay=true, max_labels_count=500, max_lines_count = 500, max_boxes_count = 500, max_bars_back = 1000) // Ayarlanabilir Kullanıcı Girdileri showBuySell = input(true, "Show Buy & Sell", group="BUY & SELL SIGNALS") hassasiyet = input.float(3, "Hassasiyet (1-6)", 0.1, 99999, group="BUY & SELL SIGNALS") percentStop = input.float(1, "Stop Loss % (0 to Disable)", 0, group="BUY & SELL SIGNALS") offsetSignal = input.float(5, "Signals Offset", 0, group="BUY & SELL SIGNALS") showRibbon = input(true, "Show Trend Ribbon", group="TREND RIBBON") smooth1 = input.int(5, "Smoothing 1", 1, group="TREND RIBBON") smooth2 = input.int(8, "Smoothing 2", 1, group="TREND RIBBON") showreversal = input(true, "Show Reversals", group="REVERSAL SIGNALS") showPdHlc = input(false, "Show P.D H/L/C", group="PREVIOUS DAY HIGH LOW CLOSE") lineColor = input.color(color.yellow, "Line Colors", group="PREVIOUS DAY HIGH LOW CLOSE") lineWidth = input.int(1, "Width Lines", group="PREVIOUS DAY HIGH LOW CLOSE") lineStyle = input.string("Solid", "Line Style", ["Solid", "Dashed", "Dotted"]) labelSize = input.string("normal", "Label Text Size", ["small", "normal", "large"]) labelColor = input.color(color.yellow, "Label Text Colors") showEmas = input(false, "Show EMAs", group="EMA") srcEma1 = input(close, "Source EMA 1") lenEma1 = input.int(7, "Length EMA 1", 1) srcEma2 = input(close, "Source EMA 2") lenEma2 = input.int(21, "Length EMA 2", 1) srcEma3 = input(close, "Source EMA 3") lenEma3 = input.int(144, "Length EMA 3", 1) showSwing = input(false, "Show Swing Points", group="SWING POINTS") prdSwing = input.int(10, "Swing Point Period", 2, group="SWING POINTS") colorPos = input(color.new(color.green, 50), "Positive Swing Color") colorNeg = input(color.new(color.red, 50), "Negative Swing Color") showDashboard = input(true, "Show Dashboard", group="TREND DASHBOARD") locationDashboard = input.string("Middle Right", "Table Location", ["Top Right", "Middle Right", "Bottom Right", "Top Center", "Middle Center", "Bottom Center", "Top Left", "Middle Left", "Bottom Left"], group="TREND DASHBOARD") tableTextColor = input(color.white, "Table Text Color", group="TREND DASHBOARD") tableBgColor = input(#2A2A2A, "Table Background Color", group="TREND DASHBOARD") sizeDashboard = input.string("Tiny", "Table Size", ["Large", "Normal", "Small", "Tiny"], group="TREND DASHBOARD") showRevBands = input.bool(true, "Show Reversal Bands", group="REVERSAL BANDS") lenRevBands = input.int(30, "Length", group="REVERSAL BANDS") // Fonksiyonlar smoothrng(x, t, m) => wper = t * 2 - 1 avrng = ta.ema(math.abs(x - x[1]), t) smoothrng = ta.ema(avrng, wper) * m rngfilt(x, r) => rngfilt = x rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r : x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r percWidth(len, perc) => (ta.highest(len) - ta.lowest(len)) * perc / 100 securityNoRep(sym, res, src) => request.security(sym, res, src, barmerge.gaps_off, barmerge.lookahead_on) swingPoints(prd) => pivHi = ta.pivothigh(prd, prd) pivLo = ta.pivotlow (prd, prd) last_pivHi = ta.valuewhen(pivHi, pivHi, 1) last_pivLo = ta.valuewhen(pivLo, pivLo, 1) hh = pivHi and pivHi > last_pivHi ? pivHi : na lh = pivHi and pivHi < last_pivHi ? pivHi : na hl = pivLo and pivLo > last_pivLo ? pivLo : na ll = pivLo and pivLo < last_pivLo ? pivLo : na [hh, lh, hl, ll] f_chartTfInMinutes() => float _resInMinutes = timeframe.multiplier * ( timeframe.isseconds ? 1 : timeframe.isminutes ? 1. : timeframe.isdaily ? 60. * 24 : timeframe.isweekly ? 60. * 24 * 7 : timeframe.ismonthly ? 60. * 24 * 30.4375 : na) f_kc(src, len, hassasiyet) => basis = ta.sma(src, len) span = ta.atr(len) [basis + span * hassasiyet, basis - span * hassasiyet] wavetrend(src, chlLen, avgLen) => esa = ta.ema(src, chlLen) d = ta.ema(math.abs(src - esa), chlLen) ci = (src - esa) / (0.015 * d) wt1 = ta.ema(ci, avgLen) wt2 = ta.sma(wt1, 3) [wt1, wt2] f_top_fractal(src) => src[4] < src[2] and src[3] < src[2] and src[2] > src[1] and src[2] > src[0] f_bot_fractal(src) => src[4] > src[2] and src[3] > src[2] and src[2] <

src[1] and src[2] < src[0] f_fractalize (src) => f_top_fractal(src) ? 1 : f_bot_fractal(src) ? -1 : 0 f_findDivs(src, topLimit, botLimit) => fractalTop = f_fractalize(src) > 0 and src[2] >= topLimit ? src[2] : na fractalBot = f_fractalize(src) < 0 and src[2] <= botLimit ? src[2] : na highPrev = ta.valuewhen(fractalTop, src[2], 0)[2] highPrice = ta.valuewhen(fractalTop, high[2], 0)[2] lowPrev = ta.valuewhen(fractalBot, src[2], 0)[2] lowPrice = ta.valuewhen(fractalBot, low[2], 0)[2] bearSignal = fractalTop and high[2] > highPrice and src[2] < highPrev bullSignal = fractalBot and low[2] < lowPrice and src[2] > lowPrev [bearSignal, bullSignal] // Bileşen... source = close smrng1 = smoothrng(source, 27, 1.5) smrng2 = smoothrng(source, 55, hassasiyet) smrng = (smrng1 + smrng2) / 2 filt = rngfilt(source, smrng) up = 0.0, up := filt > filt[1] ? nz(up[1]) + 1 : filt < filt[1] ? 0 : nz(up[1]) dn = 0.0, dn := filt < filt[1] ? nz(dn[1]) + 1 : filt > filt[1] ? 0 : nz(dn[1]) bullCond = bool(na), bullCond := source > filt and source > source[1] and up > 0 or source > filt and source < source[1] and up > 0 bearCond = bool(na), bearCond := source < filt and source < source[1] and dn > 0 or source < filt and source > source[1] and dn > 0 lastCond = 0, lastCond := bullCond ? 1 : bearCond ? -1 : lastCond[1] bull = bullCond and lastCond[1] == -1 bear = bearCond and lastCond[1] == 1 countBull = ta.barssince(bull) countBear = ta.barssince(bear) trigger = nz(countBull, bar_index) < nz(countBear, bar_index) ? 1 : 0 ribbon1 = ta.sma(close, smooth1) ribbon2 = ta.sma(close, smooth2) rsi = ta.rsi(close, 21) rsiOb = rsi > 70 and rsi > ta.ema(rsi, 10) rsiOs = rsi < 30 and rsi < ta.ema(rsi, 10) dHigh = securityNoRep(syminfo.tickerid, "D", high [1]) dLow = securityNoRep(syminfo.tickerid, "D", low [1]) dClose = securityNoRep(syminfo.tickerid, "D", close[1]) ema1 = ta.ema(srcEma1, lenEma1) ema2 = ta.ema(srcEma2, lenEma2) ema3 = ta.ema(srcEma3, lenEma3) [hh, lh, hl, ll] = swingPoints(prdSwing) ema = ta.ema(close, 144) emaBull = close > ema equal_tf(res) => str.tonumber(res) == f_chartTfInMinutes() and not timeframe.isseconds higher_tf(res) => str.tonumber(res) > f_chartTfInMinutes() or timeframe.isseconds too_small_tf(res) => (timeframe.isweekly and res=="1") or (timeframe.ismonthly and str.tonumber(res) < 10) securityNoRep1(sym, res, src) => bool bull_ = na bull_ := equal_tf(res) ? src : bull_ bull_ := higher_tf(res) ? request.security(sym, res, src, barmerge.gaps_off, barmerge.lookahead_on) : bull_ bull_array = request.security_lower_tf(syminfo.tickerid, higher_tf(res) ? str.tostring(f_chartTfInMinutes()) + (timeframe.isseconds ? "S" : "") : too_small_tf(res) ? (timeframe.isweekly ? "3" : "10") : res, src) if array.size(bull_array) > 1 and not equal_tf(res) and not higher_tf(res) bull_ := array.pop(bull_array) array.clear(bull_array) bull_ TF1Bull = securityNoRep1(syminfo.tickerid, "1" , emaBull) TF3Bull = securityNoRep1(syminfo.tickerid, "3" , emaBull) TF5Bull = securityNoRep1(syminfo.tickerid, "5" , emaBull) TF15Bull = securityNoRep1(syminfo.tickerid, "15" , emaBull) TF30Bull = securityNoRep1(syminfo.tickerid, "30" , emaBull) TF60Bull = securityNoRep1(syminfo.tickerid, "60" , emaBull) TF120Bull = securityNoRep1(syminfo.tickerid, "120" , emaBull) TF240Bull = securityNoRep1(syminfo.tickerid, "240" , emaBull) TF480Bull = securityNoRep1(syminfo.tickerid, "480" , emaBull) TFDBull = securityNoRep1(syminfo.tickerid, "1440", emaBull) [upperKC1, lowerKC1] = f_kc(close, lenRevBands, 3) [upperKC2, lowerKC2] = f_kc(close, lenRevBands, 4) [upperKC3, lowerKC3] = f_kc(close, lenRevBands, 5) [upperKC4, lowerKC4] = f_kc(close, lenRevBands, 6) [wt1, wt2] = wavetrend(hlc3, 9, 12) [wtDivBear1, wtDivBull1] = f_findDivs(wt2, 15, -40) [wtDivBear2, wtDivBull2] = f_findDivs(wt2, 45, -65) wtDivBull = wtDivBull1 or wtDivBull2 wtDivBear = wtDivBear1 or wtDivBear2 // Renkler cyan = #00DBFF, cyan30 = color.new(cyan, 70) pink = #E91E63, pink30 = color.new(pink, 70) red = #FF5252, red30 = color.new(red , 70) // Plotlar off = percWidth(300, offsetSignal) plotshape(showBuySell and

bull ? low - off : na, "Buy Label" , shape.labelup , location.absolute, cyan, 0, "Buy" , color.white, size=size.normal) plotshape(showBuySell and bear ? high + off : na, "Sell Label", shape.labeldown, location.absolute, pink, 0, "Sell", color.white, size=size.normal) plotshape(ta.crossover(wt1, wt2) and wt2 <= -53, "Mild Buy" , shape.xcross, location.belowbar, cyan, size=size.tiny) plotshape(ta.crossunder(wt1, wt2) and wt2 >= 53, "Mild Sell", shape.xcross, location.abovebar, pink, size=size.tiny) plotshape(wtDivBull, "Divergence Buy ", shape.triangleup , location.belowbar, cyan, size=size.tiny) plotshape(wtDivBear, "Divergence Sell", shape.triangledown, location.abovebar, pink, size=size.tiny) barcolor(up > dn ? cyan : pink) plotshape(showreversal and rsiOs, "Reversal Buy" , shape.diamond, location.belowbar, cyan30, size=size.tiny) plotshape(showreversal and rsiOb, "Reversal Sell", shape.diamond, location.abovebar, pink30, size=size.tiny) lStyle = lineStyle == "Solid" ? line.style_solid : lineStyle == "Dotted" ? line.style_dotted : line.style_dashed lSize = labelSize == "small" ? size.small : labelSize == "normal" ? size.normal : size.large dHighLine = showPdHlc ? line.new(bar_index, dHigh, bar_index + 1, dHigh , xloc.bar_index, extend.both, lineColor, lStyle, lineWidth) : na, line.delete(dHighLine[1]) dLowLine = showPdHlc ? line.new(bar_index, dLow , bar_index + 1, dLow , xloc.bar_index, extend.both, lineColor, lStyle, lineWidth) : na, line.delete(dLowLine[1]) dCloseLine = showPdHlc ? line.new(bar_index, dClose, bar_index + 1, dClose, xloc.bar_index, extend.both, lineColor, lStyle, lineWidth) : na, line.delete(dCloseLine[1]) dHighLabel = showPdHlc ? label.new(bar_index + 100, dHigh , "P.D.H", xloc.bar_index, yloc.price, #000000, label.style_none, labelColor, lSize) : na, label.delete(dHighLabel[1]) dLowLabel = showPdHlc ? label.new(bar_index + 100, dLow , "P.D.L", xloc.bar_index, yloc.price, #000000, label.style_none, labelColor, lSize) : na, label.delete(dLowLabel[1]) dCloseLabel = showPdHlc ? label.new(bar_index + 100, dClose, "P.D.C", xloc.bar_index, yloc.price, #000000, label.style_none, labelColor, lSize) : na, label.delete(dCloseLabel[1]) plot(showEmas ? ema1 : na, "EMA 1", color.green , 2) plot(showEmas ? ema2 : na, "EMA 2", color.purple, 2) plot(showEmas ? ema3 : na, "EMA 3", color.yellow, 2) plotshape(showSwing ? hh : na, "", shape.triangledown, location.abovebar, color.new(color.green, 50), -prdSwing, "HH", colorPos, false) plotshape(showSwing ? hl : na, "", shape.triangleup , location.belowbar, color.new(color.green, 50), -prdSwing, "HL", colorPos, false) plotshape(showSwing ? lh : na, "", shape.triangledown, location.abovebar, color.new(color.red , 50), -prdSwing, "LH", colorNeg, false) plotshape(showSwing ? ll : na, "", shape.triangleup , location.belowbar, color.new(color.red , 50), -prdSwing, "LL", colorNeg, false) srcStop = close atrBand = srcStop * (percentStop / 100) atrStop = trigger ? srcStop - atrBand : srcStop + atrBand lastTrade(src) => ta.valuewhen(bull or bear, src, 0) entry_y = lastTrade(srcStop) stop_y = lastTrade(atrStop) tp1_y = (entry_y - lastTrade(atrStop)) * 1 + entry_y tp2_y = (entry_y - lastTrade(atrStop)) * 2 + entry_y tp3_y = (entry_y - lastTrade(atrStop)) * 3 + entry_y labelTpSl(y, txt, color) => label labelTpSl = percentStop != 0 ? label.new(bar_index + 1, y, txt, xloc.bar_index, yloc.price, color, label.style_label_left, color.white, size.normal) : na label.delete(labelTpSl[1]) labelTpSl(entry_y, "Entry: " + str.tostring(math.round_to_mintick(entry_y)), color.gray) labelTpSl(stop_y , "Stop Loss: " + str.tostring(math.round_to_mintick(stop_y)), color.red) labelTpSl(tp1_y, "Take Profit 1: " + str.tostring(math.round_to_mintick(tp1_y)), color.green) labelTpSl(tp2_y, "Take Profit 2: " + str.tostring(math.round_to_mintick(tp2_y)), color.green) labelTpSl(tp3_y, "Take Profit 3: " + str.tostring(math.round_to_mintick(tp3_y)), color.green) lineTpSl(y, color) => line lineTpSl = percentStop != 0 ? line.new(bar_index - (trigger ? countBull : countBear) + 4, y, bar_index + 1, y,

xloc.bar_index, extend.none, color, line.style_solid) : na line.delete(lineTpSl[1]) lineTpSl(entry_y, color.gray) lineTpSl(stop_y, color.red) lineTpSl(tp1_y, color.green) lineTpSl(tp2_y, color.green) lineTpSl(tp3_y, color.green) var dashboard_loc = locationDashboard == "Top Right" ? position.top_right : locationDashboard == "Middle Right" ? position.middle_right : locationDashboard == "Bottom Right" ? position.bottom_right : locationDashboard == "Top Center" ? position.top_center : locationDashboard == "Middle Center" ? position.middle_center : locationDashboard == "Bottom Center" ? position.bottom_center : locationDashboard == "Top Left" ? position.top_left : locationDashboard == "Middle Left" ? position.middle_left : position.bottom_left var dashboard_size = sizeDashboard == "Large" ? size.large : sizeDashboard == "Normal" ? size.normal : sizeDashboard == "Small" ? size.small : size.tiny var dashboard = showDashboard ? table.new(dashboard_loc, 2, 15, tableBgColor, #000000, 2, tableBgColor, 1) : na dashboard_cell(column, row, txt, signal=false) => table.cell(dashboard, column, row, txt, 0, 0, signal ? #000000 : tableTextColor, text_size=dashboard_size) dashboard_cell_bg(column, row, col) => table.cell_set_bgcolor(dashboard, column, row, col) if barstate.islast and showDashboard dashboard_cell(0, 0 , "Razzere") dashboard_cell(0, 1 , "Current Position") dashboard_cell(0, 2 , "Current Trend") dashboard_cell(0, 3 , "Volume") dashboard_cell(0, 4 , "Timeframe") dashboard_cell(0, 5 , "1 min:") dashboard_cell(0, 6 , "3 min:") dashboard_cell(0, 7 , "5 min:") dashboard_cell(0, 8 , "15 min:") dashboard_cell(0, 9 , "30 min:") dashboard_cell(0, 10, "1 H:") dashboard_cell(0, 11, "2 H:") dashboard_cell(0, 12, "4 H:") dashboard_cell(0, 13, "8 H:") dashboard_cell(0, 14, "Daily:") dashboard_cell(1, 0 , "V.1") dashboard_cell(1, 1 , trigger ? "Buy" : "Sell", true), dashboard_cell_bg(1, 1, trigger ? color.green : color.red) dashboard_cell(1, 2 , emaBull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 2, emaBull ? color.green : color.red) dashboard_cell(1, 3 , str.tostring(volume)) dashboard_cell(1, 4 , "Trends") dashboard_cell(1, 5 , TF1Bull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 5 , TF1Bull ? color.green : color.red) dashboard_cell(1, 6 , TF3Bull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 6 , TF3Bull ? color.green : color.red) dashboard_cell(1, 7 , TF5Bull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 7 , TF5Bull ? color.green : color.red) dashboard_cell(1, 8 , TF15Bull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 8 , TF15Bull ? color.green : color.red) dashboard_cell(1, 9 , TF30Bull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 9 , TF30Bull ? color.green : color.red) dashboard_cell(1, 10, TF60Bull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 10, TF60Bull ? color.green : color.red) dashboard_cell(1, 11, TF120Bull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 11, TF120Bull ? color.green : color.red) dashboard_cell(1, 12, TF240Bull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 12, TF240Bull ? color.green : color.red) dashboard_cell(1, 13, TF480Bull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 13, TF480Bull ? color.green : color.red) dashboard_cell(1, 14, TFDBull ? "Bullish" : "Bearish", true), dashboard_cell_bg(1, 14, TFDBull ? color.green : color.red) plot(showRevBands ? upperKC1 : na, "Rev.Zone Upper 1", red30) plot(showRevBands ? upperKC2 : na, "Rev.Zone Upper 2", red30) plot(showRevBands ? upperKC3 : na, "Rev.Zone Upper 3", red30) plot(showRevBands ? upperKC4 : na, "Rev.Zone Upper 4", red30) plot(showRevBands ? lowerKC4 : na, "Rev.Zone Lower 4", cyan30) plot(showRevBands ? lowerKC3 : na, "Rev.Zone Lower 3", cyan30) plot(showRevBands ? lowerKC2 : na, "Rev.Zone Lower 2", cyan30) plot(showRevBands ? lowerKC1 : na, "Rev.Zone Lower 1", cyan30) fill(plot(showRibbon ? ribbon1 : na, "", na, editable=false), plot(showRibbon ? ribbon2 : na, "", na, editable=false), ribbon1 > ribbon2 ? cyan30 : pink30, "Ribbon Fill Color") // Alarmlar alert01 = ta.crossover(ribbon1,

ribbon2) alert02 = bull alert03 = wtDivBull alert04 = wtDivBear alert05 = bull or bear alert06 = ta.crossover(wt1, wt2) and wt2 <= -53 alert07 = ta.crossunder(wt1, wt2) and wt2 >= 53 alert08 = ta.crossunder(ribbon1, ribbon2) alert09 = rsiOb or rsiOs alert10 = bear alert11 = ta.cross(ribbon1, ribbon2) alerts(sym) => if alert02 or alert03 or alert04 or alert06 or alert07 or alert10 alert_text = alert02 ? "Buy Signal EzAlgo" : alert03 ? "Strong Buy Signal EzAlgo" : alert04 ? "Strong Sell Signal EzAlgo" : alert06 ? "Mild Buy Signal EzAlgo" : alert07 ? "Mild Sell Signal EzAlgo" : "Sell Signal EzAlgo" alert(alert_text, alert.freq_once_per_bar_close) alerts(syminfo.tickerid) alertcondition(alert01, "Blue Trend Ribbon Alert", "Blue Trend Ribbon, TimeFrame={{interval}}") alertcondition(alert02, "Buy Signal", "Buy Signal EzAlgo") alertcondition(alert03, "Divergence Buy Alert", "Strong Buy Signal EzAlgo, TimeFrame={{interval}}") alertcondition(alert04, "Divergence Sell Alert", "Strong Sell Signal EzAlgo, TimeFrame={{interval}}") alertcondition(alert05, "Either Buy or Sell Signal", "EzAlgo Signal") alertcondition(alert06, "Mild Buy Alert", "Mild Buy Signal EzAlgo, TimeFrame={{interval}}") alertcondition(alert07, "Mild Sell Alert", "Mild Sell Signal EzAlgo, TimeFrame={{interval}}") alertcondition(alert08, "Red Trend Ribbon Alert", "Red Trend Ribbon, TimeFrame={{interval}}") alertcondition(alert09, "Reversal Signal", "Reversal Signal") alertcondition(alert10, "Sell Signal", "Sell Signal EzAlgo") alertcondition(alert11, "Trend Ribbon Color Change Alert", "Trend Ribbon Color Change, TimeFrame={{interval}}") // ------------------------------UYUMSUZLUKLAR------------------------------------- // // Functions ----------------------------------------------------------------------------------- // ma(_source, _length, _type) => switch _type "SMA" => ta.sma (_source, _length) "EMA" => ta.ema (_source, _length) "RMA" => ta.rma (_source, _length) "WMA" => ta.wma (_source, _length) "VWMA" => ta.vwma(_source, _length) alarm(_osc, _message) => alert(syminfo.ticker + ' ' + _osc + ' : ' + _message + ', price (' + str.tostring(close, format.mintick) + ')') // Functions ----------------------------------------------------------------------------------- // // ---------------------------------------------------------------------------------------------- // // ---------------------------------------------------------------------------------------------- // // Inputs -------------------------------------------------------------------------------------- // oscType = input.string("Distance Oscillator", "Pick an Oscillator", options=[ "Awesome Oscillator (AO)", "Chaikin Oscillator (Chaikin Osc)", "Commodity Channel Index (CCI)", "Distance Oscillator", "Elder-Ray Bear and Bull Power", "Elliott Wave Oscillator (EWO)", "Klinger Oscillator", "Money Flow Index (MFI)", "Moving Average Convergence Divergence (MACD)", "Rate Of Change (ROC)", "Relative Strength Index (RSI)", "Stochastic (Stoch)", "Stochastic RSI (Stoch RSI)", "Volume Oscillator (Volume Osc)", "Wave Trend [LazyBear]" ]) group_ocs = 'Plotting Settings - General ================' oscLookbackLength = input.int(200, 'Display Length', minval = 10, step = 10, maxval = 250, group=group_ocs) oscPlacement = input.string('Bottom', 'Placement', options = ['Top', 'Bottom'], group=group_ocs) oscHight = 11 - input.int(7, 'Hight' , minval = 1, maxval = 10 , group=group_ocs ) oscVerticalOffset = input.int(3, "Vertical Offset", minval = -3, maxval = 10, group=group_ocs) / 10 group_diver = 'Divergence Settings - General ==============' lbR = input(5, "Pivot Lookback Right", group=group_diver) lbL = input(5, "Pivot Lookback Left", group=group_diver) rangeUpper = input(60, "Max of Lookback Range", group=group_diver) rangeLower = input(5, "Min of Lookback Range", group=group_diver) plotBull = input(true, "Plot Bullish  |  Hidden Bullish", inline = 'bull', group=group_diver) plotHiddenBull = input(false, "", inline='bull', group=group_diver) plotBear = input(true, "Plot Bearish |  Hidden Bearish", inline = 'bear',

group=group_diver) plotHiddenBear = input(false, "", inline = 'bear', group=group_diver) group_alert = 'Alert Settings - General ===================' signalCross = input(true, "Signal Line Crosses", group=group_alert) centerCross = input(false, "Center Line Crosses", group=group_alert) osobCross = input(true, "Overbought/Oversold Crosses", group=group_alert) histChange = input(true, "Histogram Color Changes", group=group_alert) oscDivergece = input(true, "Divergence Detection", group=group_alert) group_Chaikin = 'Chaikin Osc Settings =======================' chaikinShort = input.int(3, minval=1, title="Fast Length", group=group_Chaikin) chaikinLong = input.int(10, minval=1, title="Slow Length", group=group_Chaikin) group_cci = 'CCI Settings ===============================' cciLength = input.int(20, 'Length', minval=1, group=group_cci) cciSource = input(hlc3, "Source", group=group_cci) cciUpperBand = input.int(100, 'Upper Band', group=group_cci) cciLowerBand = input.int(-100, 'Lower Band', group=group_cci) cciSmoothing = input.bool(false, 'Oscillator MA', inline = 'CCI', group=group_cci) cciMaType = input.string(title = "", defval = "SMA", options=["SMA", "EMA", "RMA", "WMA", "VWMA"], inline = 'CCI',group=group_cci) cciSmoothLength = input.int(5, "Oscillator MA Length", minval = 1, maxval = 100, group=group_cci) group_pma = 'Distance Osc Settings =======================' pmaSource = input.source(close, "Source", group = group_pma) pmaLength = input.int(20, "Oscillator Length", minval = 2, maxval = 50, group = group_pma) pmaMaType = input.string("SMA", "Oscillator MA Type" , options=["SMA", "EMA"], group=group_pma) pmaSignalLength = input.int(9, "Signal Line MA Length", minval = 2, maxval = 50, group = group_pma) pmaSignalMA = input.string("EMA", "Signal Line MA Type", options=["SMA", "EMA"], group=group_pma) group_ewo = 'EWO Settings ==============================' ewoSiganl = input.bool(true, 'Signal Line', inline = 'EWO', group=group_ewo) ewoSignalMAType = input.string("SMA", "", options=["SMA", "EMA", "RMA", "WMA", "VWMA"], inline = 'EWO', group=group_ewo) ewoSignalLength = input.int(5 , "Signal Smoothing", minval = 1, maxval = 50 , group=group_ewo) group_mfi = 'MFI Settings ================================' mfiLegth = input.int(14, "Length", minval=1, maxval=2000, group=group_mfi) mfiUpperBand = input.int(80, 'Upper Band', group=group_mfi) mfiLowerBand = input.int(20, 'Lower Band', group=group_mfi) group_macd = 'MACD Settings ==============================' macdFastLength = input.int(12, "Fast Length", minval = 1, group=group_macd) macdSlowLength = input.int(26, "Slow Length", minval = 1, group=group_macd) macdSource = input(close , "Source", group=group_macd) macdSignalLength = input.int(9 , "Signal Smoothing", minval = 1, maxval = 50 , group=group_macd) macdSourceMA = input.string("EMA", "Oscillator MA Type" , options=["SMA", "EMA"], group=group_macd) macdSignalMA = input.string("EMA", "Signal Line MA Type", options=["SMA", "EMA"], group=group_macd) group_roc = 'ROC Settings ================================' rocLength = input.int(9, minval=1, group=group_roc) rocSource = input(close, "Source", group=group_roc) group_rsi = 'RSI Settings ===============================' rsiLength = input.int(14, "Length", minval = 1, group=group_rsi) rsiSource = input.source(close, "Source", group=group_rsi) rsiObThresh = input.int(70, 'Overbought', minval=50, maxval=100, group=group_rsi) rsiOsThresh = input.int(30, 'Oversold' , minval=1 , maxval=50 , group=group_rsi) rsiSmoothing = input.bool(true, 'Oscillator MA', inline = 'RSI', group=group_rsi) rsiMaType = input.string("EMA", "", options=["SMA", "EMA", "RMA", "WMA", "VWMA"], inline = 'RSI', group=group_rsi) rsiMaLength = input.int(14, "Oscillator MA Length", group=group_rsi) group_stoch = 'Stochastic Settings ==========================' stochPeriodK = input.int(14, "%K Length", minval=1, group=group_stoch) stochSmoothK = input.int(1 , "%K Smoothing", minval=1, group=group_stoch) stochPeriodD = input.int(3 , "%D Smoothing", minval=1, group=group_stoch) stochUpperBand =

input.int(80, 'Upper Band', group=group_stoch) stochLowerBand = input.int(20, 'Lower Band', group=group_stoch) group_stochRsi = 'Stochastic RSI Settings ======================' stochRSmoothK = input.int(3 , "%K Smoothing", minval=1, group=group_stochRsi) stochRPeriodD = input.int(3 , "%D Smoothing", minval=1, group=group_stochRsi) stochRsiLength = input.int(14, "RSI Length", minval=1, group=group_stochRsi) stochRLength = input.int(14, "Stochastic Length", minval=1, group=group_stochRsi) stochRSoruce = input(close, "RSI Source", group=group_stochRsi) stochRUpperBand = input.int(80, 'Upper Band', group=group_stochRsi) stochRLowerBand = input.int(20, 'Lower Band', group=group_stochRsi) group_volumeOsc = 'Volume Osc Settings ==========================' volShortLength = input.int(5, "Short Length", minval = 1, group=group_volumeOsc) volLongLength = input.int(10, "Long Length", minval = 1, group=group_volumeOsc) group_wave = 'Wave Trend Settings ==========================' waveChLength = input.int(10, 'Channel Length', minval=1, group=group_wave) waveAvgLength = input.int(21, 'Average Length', minval=1, group=group_wave) waveUpperBand = input.int(53, 'Upper Band', group=group_wave) waveLowerBand = input.int(-53, 'Lower Band', group=group_wave) // Inputs -------------------------------------------------------------------------------------- // // ---------------------------------------------------------------------------------------------- // // Calculations -------------------------------------------------------------------------------- // nzVolume = nz(volume) osc = switch oscType "Awesome Oscillator (AO)" => ma(hl2, 5, 'SMA') - ma(hl2, 34, 'SMA') "Chaikin Oscillator (Chaikin Osc)" => ma(ta.accdist, chaikinShort, 'EMA') - ma(ta.accdist, chaikinLong, 'EMA') 'Commodity Channel Index (CCI)' => (cciSource - ma(cciSource, cciLength, 'SMA')) / (0.015 * ta.dev(cciSource, cciLength)) "Distance Oscillator" => (pmaSource/ma(pmaSource, pmaLength, pmaMaType) - 1) * 100 "Elder-Ray Bear and Bull Power" => high - ma(close, 13, 'EMA') "Elliott Wave Oscillator (EWO)" => ma(close, 5, 'SMA') - ma(close, 35, 'SMA') "Klinger Oscillator" => sv = ta.change(hlc3) >= 0 ? nzVolume : -nzVolume, ma(sv, 34, 'EMA') - ma(sv, 55, 'EMA') "Money Flow Index (MFI)" => ta.mfi(hlc3, mfiLegth) 'Moving Average Convergence Divergence (MACD)' => ma(macdSource, macdFastLength, macdSourceMA) - ma(macdSource, macdSlowLength, macdSourceMA) "Rate Of Change (ROC)" => 100 * (rocSource - rocSource[rocLength])/rocSource[rocLength] 'Relative Strength Index (RSI)' => ta.rsi(rsiSource, rsiLength) 'Stochastic (Stoch)' => ma(ta.stoch(close, high, low, stochPeriodK), stochSmoothK, 'SMA') 'Stochastic RSI (Stoch RSI)' => rsix = ta.rsi(stochRSoruce, stochRsiLength), ma(ta.stoch(rsix, rsix, rsix, stochRLength), stochRSmoothK, 'SMA') "Volume Oscillator (Volume Osc)" => 100 * (ma(nzVolume, volShortLength, 'EMA') - ma(nzVolume, volLongLength, 'EMA')) / ma(nzVolume, volLongLength, 'EMA') "Wave Trend [LazyBear]" => esa = ma(hlc3, waveChLength, 'EMA'), d = ma(math.abs(hlc3 - esa), waveChLength, 'EMA'), ci = (hlc3 - esa) / (0.015 * d), ma(ci, waveAvgLength, 'EMA') signal = switch oscType 'Commodity Channel Index (CCI)' => cciSmoothing ? ma(osc, cciSmoothLength, cciMaType) : na "Distance Oscillator" => ma(osc, pmaSignalLength, pmaSignalMA) "Elder-Ray Bear and Bull Power" => -(low - ma(close, 13, 'EMA')) "Elliott Wave Oscillator (EWO)" => ewoSiganl ? ma(osc, ewoSignalLength, ewoSignalMAType) : na "Klinger Oscillator" => ma(osc, 13, 'EMA') 'Moving Average Convergence Divergence (MACD)' => ma(osc, macdSignalLength, macdSignalMA) 'Relative Strength Index (RSI)' => rsiSmoothing ? ma(osc, rsiMaLength, rsiMaType) : na 'Stochastic (Stoch)' => ma(osc, stochPeriodD, 'SMA') 'Stochastic RSI (Stoch RSI)' => ma(osc, stochRPeriodD, 'SMA') "Wave Trend [LazyBear]" => ma(osc, 4, 'SMA') [plotHist, histogram] = switch oscType "Awesome Oscillator (AO)" => [true, ma(hl2, 5, 'SMA') - ma(hl2, 34, 'SMA')] "Distance Oscillator" => [true, osc - signal] "Elliott Wave Oscillator (EWO)" => [true, ma(close, 5, 'SMA') -

ma(close, 35, 'SMA')] 'Moving Average Convergence Divergence (MACD)' => [true, osc - signal] "Wave Trend [LazyBear]" => [true, osc - signal] => [false, 0.] [oscColor, signalColor, fillColor, histColor] = switch oscType "Awesome Oscillator (AO)" => [#00000000, #00000000, #00000000, histogram - histogram[1] <= 0 ? #F44336 : #009688] "Chaikin Oscillator (Chaikin Osc)" => [#EC407A, #00000000, #00000000, #00000000] 'Commodity Channel Index (CCI)' => [#2962ff, #f37f20, color.new(#2196f3, 90), #00000000] "Distance Oscillator" => [color.red, color.blue, #00000000, histogram > 0 ? color.new(color.green, 34) : color.new(color.red , 34)] "Elder-Ray Bear and Bull Power" => [color.green, color.red, #00000000, #00000000] "Elliott Wave Oscillator (EWO)" => [#00000000, #FF6D00, #00000000, histogram >= 0 ? histogram[1] < histogram ? #006400 : color.green : histogram[1] < histogram ? color.red : #910000] "Klinger Oscillator" => [#2962FF, #43A047, #00000000, #00000000] "Money Flow Index (MFI)" => [#7E57C2, #00000000, color.new(#7e57c2, 90), #00000000] 'Moving Average Convergence Divergence (MACD)' => [#2962FF, #FF6D00, #00000000, histogram >= 0 ? histogram[1] < histogram ? #26A69A : #B2DFDB : histogram[1] < histogram ? #FFCDD2 : #FF5252] "Rate Of Change (ROC)" => [#2962FF, #00000000, #00000000, #00000000] 'Relative Strength Index (RSI)' => [#7e57c2, #ffeb3b, color.new(#7e57c2, 90), #00000000] 'Stochastic (Stoch)' => [#2962FF, #FF6D00, color.new(#2196f3, 90), #00000000] 'Stochastic RSI (Stoch RSI)' => [#2962FF, #FF6D00, color.new(#2196f3, 90), #00000000] "Volume Oscillator (Volume Osc)" => [#2962FF, #00000000, #00000000, #00000000] "Wave Trend [LazyBear]" => [#008000, #FF0000, #00000000, #0000FF50] [plotTresh, upperBand, plotMidLile, midLine, lowerBand] = switch oscType "Chaikin Oscillator (Chaikin Osc)" => [false, 0, true, 0, 0] 'Commodity Channel Index (CCI)' => [true, cciUpperBand, false, 0, cciLowerBand] "Money Flow Index (MFI)" => [true, mfiUpperBand, false, 0, mfiLowerBand] "Rate Of Change (ROC)" => [false, 0, true, 0, 0] 'Relative Strength Index (RSI)' => [true, rsiObThresh , true , 50, rsiOsThresh ] 'Stochastic (Stoch)' => [true, stochUpperBand, false, 0, stochLowerBand] 'Stochastic RSI (Stoch RSI)' => [true, stochRUpperBand, false, 0, stochRLowerBand] "Volume Oscillator (Volume Osc)" => [false, 0, true, 0, 0] "Wave Trend [LazyBear]" => [true, waveUpperBand , false , 0, waveLowerBand ] => [false, 0., false, 0., 0.] // Calculations -------------------------------------------------------------------------------- // // ---------------------------------------------------------------------------------------------- // // Divergence ---------------------------------------------------------------------------------- // plFound = na(ta.pivotlow (osc, lbL, lbR)) ? false : true phFound = na(ta.pivothigh(osc, lbL, lbR)) ? false : true _inRange(cond) =>  bars = ta.barssince(cond == true)  rangeLower <= bars and bars <= rangeUpper // Regular Bullish = Osc: Higher Low - Price: Lower Low oscHL = osc[lbR] > ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1]) priceLL = low[lbR] < ta.valuewhen(plFound, low[lbR], 1) bullCoond = plotBull and priceLL and oscHL and plFound plot(plFound ? low[lbR] : na, offset=-lbR, title="Regular Bullish", linewidth=2, color=(bullCoond ? color.green : na), show_last = oscLookbackLength) plotshape(bullCoond ? low[lbR] : na, offset=-lbR, title="Regular Bullish Label", text=" Bull ", style=shape.labelup, location=location.absolute, color=color.green, textcolor=color.white, show_last = oscLookbackLength) // Hidden Bullish = Osc: Lower Low - Price: Higher Low oscLL = osc[lbR] < ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1]) priceHL = low[lbR] > ta.valuewhen(plFound, low[lbR], 1) hiddenBullCoond = plotHiddenBull and priceHL and oscLL and plFound plot(plFound ? low[lbR] : na, offset=-lbR, title="Hidden Bullish", linewidth=2, color=(hiddenBullCoond ? color.new(color.green, 50) : na), show_last = oscLookbackLength) plotshape(hiddenBullCoond ? low[lbR] : na, offset=-lbR, title="Hidden Bullish Label", text=" H

Bull ", style=shape.labelup, location=location.absolute, color=color.green, textcolor=color.white, show_last = oscLookbackLength) // Regular Bearish = Osc: Lower High - Price: Higher High oscLH = osc[lbR] < ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1]) priceHH = high[lbR] > ta.valuewhen(phFound, high[lbR], 1) bearCoond = plotBear and priceHH and oscLH and phFound plot(phFound ? high[lbR] : na, offset=-lbR, title="Regular Bearish", linewidth=2, color=(bearCond ? color.red : na), show_last = oscLookbackLength) plotshape(bearCond ? high[lbR] : na, offset=-lbR, title="Regular Bearish Label", text=" Bear ", style=shape.labeldown, location=location.absolute, color=color.red, textcolor=color.white, show_last = oscLookbackLength) // Hidden Bearish = Osc: Higher High - Price: Lower High oscHH = osc[lbR] > ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1]) priceLH = high[lbR] < ta.valuewhen(phFound, high[lbR], 1) hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound plot(phFound ? high[lbR] : na, offset=-lbR, title="Hidden Bearish", linewidth=2, color=(hiddenBearCond ? color.new(color.red, 50) : na), show_last = oscLookbackLength) plotshape(hiddenBearCond ? high[lbR] : na, offset=-lbR, title="Hidden Bearish Label", text=" H Bear ", style=shape.labeldown, location=location.absolute, color=color.red, textcolor=color.white, show_last = oscLookbackLength) // Divergence ---------------------------------------------------------------------------------- // // ---------------------------------------------------------------------------------------------- // // Alerts -------------------------------------------------------------------------------------- // if signalCross and ta.cross(osc, signal) alarm(oscType, 'Signal Line Cross') if histChange and ta.cross(ta.change(histogram), 0) alarm(oscType, 'Histogram Color Change') if centerCross and ta.cross(osc, midLine) alarm(oscType, 'Center Line Cross') if osobCross and ta.cross(osc, upperBand) alarm(oscType, 'Overbought Band Cross') if osobCross and ta.cross(osc, lowerBand) alarm(oscType, 'Oversold Band Cross') if oscDivergece and (bullCoond or bearCond) alarm(oscType, bullCoond ? 'Bullish Divergence Detected' : 'Bearish Divergence Detected') if oscDivergece and (hiddenBullCoond or hiddenBearCond) alarm(oscType, hiddenBullCoond ? 'Hidden Bullish Divergence Detected' : 'Hidden Bearish Divergence Detected') // Alerts -------------------------------------------------------------------------------------- // // ---------------------------------------------------------------------------------------------- // // Plotting ------------------------------------------------------------------------------------ // var a_lines = array.new_line() var a_hist = array.new_box() var a_fill = array.new_linefill() priceHighest = ta.highest(high, oscLookbackLength) priceLowest = ta.lowest (low , oscLookbackLength) priceChangeRate = (priceHighest - priceLowest) / priceHighest priceLowest := priceLowest * (1 - priceChangeRate * oscVerticalOffset) priceHighest := priceHighest * (1 + priceChangeRate * oscVerticalOffset) oscHighest = ta.highest(osc, oscLookbackLength) if barstate.islast if array.size(a_lines) > 0 for i = 1 to array.size(a_lines) line.delete(array.shift(a_lines)) if array.size(a_hist) > 0 for i = 1 to array.size(a_hist) box.delete(array.shift(a_hist)) if array.size(a_fill) > 0 for i = 1 to array.size(a_fill) linefill.delete(array.shift(a_fill)) hight = priceChangeRate / oscHight if plotTresh obLevel = (oscPlacement == 'Top' ? priceHighest : priceLowest) * (1 + upperBand / oscHighest * hight) osLevel = (oscPlacement == 'Top' ? priceHighest : priceLowest) * (1 + lowerBand / oscHighest * hight) array.push(a_lines, line.new(bar_index[oscLookbackLength], obLevel , bar_index, obLevel , xloc.bar_index, extend.none, color.gray, line.style_dashed, 1)) array.push(a_lines, line.new(bar_index[oscLookbackLength], osLevel , bar_index, osLevel , xloc.bar_index, extend.none, color.gray, line.style_dashed, 1)) array.push(a_fill, linefill.new(array.get(a_lines, 0), array.get(a_lines, 1),

fillColor)) if plotMidLile midLevel = (oscPlacement == 'Top' ? priceHighest : priceLowest) * (1 + midLine / oscHighest * hight) array.push(a_lines, line.new(bar_index[oscLookbackLength], midLevel , bar_index, midLevel , xloc.bar_index, extend.none, color.new(color.gray, 50) ,line.style_dashed, 1)) for barIndex = 0 to oscLookbackLength - 1 if array.size(a_lines) < 498 if plotHist array.push(a_hist , box.new (bar_index[barIndex], oscPlacement == 'Top' ? priceHighest : priceLowest, bar_index[barIndex], (oscPlacement == 'Top' ? priceHighest : priceLowest) * (1 + histogram[barIndex] / oscHighest * hight), histColor[barIndex], 2)) array.push(a_lines, line.new(bar_index[barIndex], (oscPlacement == 'Top' ? priceHighest : priceLowest) * (1 + osc[barIndex] / oscHighest * hight), bar_index[barIndex + 1], (oscPlacement == 'Top' ? priceHighest : priceLowest) * (1 + osc[barIndex + 1] / oscHighest * hight), xloc.bar_index, extend.none, oscColor, line.style_solid, 1)) array.push(a_lines, line.new(bar_index[barIndex], (oscPlacement == 'Top' ? priceHighest : priceLowest) * (1 + signal[barIndex] / oscHighest * hight), bar_index[barIndex + 1], (oscPlacement == 'Top' ? priceHighest : priceLowest) * (1 + signal[barIndex + 1] / oscHighest * hight), xloc.bar_index, extend.none, signalColor, line.style_solid, 1)) // Plotting ------------------------------------------------------------------------------------ // // ---------------------------------------------------------------------------------------------- // var table info = table.new(position.top_right , 1, 1) var table logo = table.new(position.bottom_right, 1, 1) if barstate.islast table.cell(logo, 0, 0, '☼☾ ' , text_size = size.normal, text_color = color.teal) table.cell(info, 0, 0, oscType, text_size = size.small , text_color = color.teal) // ------------------------------DİRENÇ DESTEK------------------------------------- // // //SETTINGS // // INDICATOR SETTINGS swing_length = input.int(10, title = 'Swing High/Low Length', group = 'Settings', minval = 1, maxval = 50) history_of_demand_to_keep = input.int(20, title = 'History To Keep', minval = 5, maxval = 50) box_width = input.float(10, title = 'Supply/Demand Box Width', group = 'Settings', minval = 1, maxval = 10, step = 0.5) // INDICATOR VISUAL SETTINGS show_zigzag = input.bool(false, title = 'Show Zig Zag', group = 'Visual Settings', inline = '1') show_price_action_labels = input.bool(false, title = 'Show Price Action Labels', group = 'Visual Settings', inline = '2') supply_color = input.color(color.new(#f10808, 45), title = 'Supply', group = 'Visual Settings', inline = '3') supply_outline_color = input.color(color.new(color.white,75), title = 'Outline', group = 'Visual Settings', inline = '3') demand_color = input.color(color.new(#00FFFF,70), title = 'Demand', group = 'Visual Settings', inline = '4') demand_outline_color = input.color(color.new(color.white,75), title = 'Outline', group = 'Visual Settings', inline = '4') bos_label_color = input.color(color.white, title = 'BOS Label', group = 'Visual Settings', inline = '5') poi_label_color = input.color(color.white, title = 'POI Label', group = 'Visual Settings', inline = '7') swing_type_color = input.color(color.black, title = 'Price Action Label', group = 'Visual Settings', inline = '8') zigzag_color = input.color(color.new(#000000,0), title = 'Zig Zag', group = 'Visual Settings', inline = '9') // //END SETTINGS // // //FUNCTIONS // // FUNCTION TO ADD NEW AND REMOVE LAST IN ARRAY f_array_add_pop(array, new_value_to_add) => array.unshift(array, new_value_to_add) array.pop(array) // FUNCTION SWING H & L LABELS f_sh_sl_labels(array, swing_type) => var string label_text = na if swing_type == 1 if array.get(array, 0) >= array.get(array, 1) label_text := 'HH' else label_text := 'LH' label.new(bar_index - swing_length, array.get(array,0), text = label_text, style=label.style_label_down, textcolor = swing_type_color, color = color.new(swing_type_color, 100), size = size.tiny) else if swing_type == -1 if array.get(array, 0) >= array.get(array, 1) label_text := 'HL' else label_text := 'LL'

label.new(bar_index - swing_length, array.get(array,0), text = label_text, style=label.style_label_up, textcolor = swing_type_color, color = color.new(swing_type_color, 100), size = size.tiny) // FUNCTION MAKE SURE SUPPLY ISNT OVERLAPPING f_check_overlapping(new_poi, box_array, atr) => atr_threshold = atr * 2 okay_to_draw = true for i = 0 to array.size(box_array) - 1 top = box.get_top(array.get(box_array, i)) bottom = box.get_bottom(array.get(box_array, i)) poi = (top + bottom) / 2 upper_boundary = poi + atr_threshold lower_boundary = poi - atr_threshold if new_poi >= lower_boundary and new_poi <= upper_boundary okay_to_draw := false break else okay_to_draw := true okay_to_draw // FUNCTION TO DRAW SUPPLY OR DEMAND ZONE f_supply_demand(value_array, bn_array, box_array, label_array, box_type, atr) => atr_buffer = atr * (box_width / 10) box_left = array.get(bn_array, 0) box_right = bar_index var float box_top = 0.00 var float box_bottom = 0.00 var float poi = 0.00 if box_type == 1 box_top := array.get(value_array, 0) box_bottom := box_top - atr_buffer poi := (box_top + box_bottom) / 2 else if box_type == -1 box_bottom := array.get(value_array, 0) box_top := box_bottom + atr_buffer poi := (box_top + box_bottom) / 2 okay_to_draw = f_check_overlapping(poi, box_array, atr) // okay_to_draw = true //delete oldest box, and then create a new box and add it to the array if box_type == 1 and okay_to_draw box.delete( array.get(box_array, array.size(box_array) - 1) ) f_array_add_pop(box_array, box.new( left = box_left, top = box_top, right = box_right, bottom = box_bottom, border_color = supply_outline_color, bgcolor = supply_color, extend = extend.right, text = 'SUPPLY', text_halign = text.align_center, text_valign = text.align_center, text_color = poi_label_color, text_size = size.small, xloc = xloc.bar_index)) box.delete( array.get(label_array, array.size(label_array) - 1) ) f_array_add_pop(label_array, box.new( left = box_left, top = poi, right = box_right, bottom = poi, border_color = color.new(poi_label_color,90), bgcolor = color.new(poi_label_color,90), extend = extend.right, text = 'POI', text_halign = text.align_left, text_valign = text.align_center, text_color = poi_label_color, text_size = size.small, xloc = xloc.bar_index)) else if box_type == -1 and okay_to_draw box.delete( array.get(box_array, array.size(box_array) - 1) ) f_array_add_pop(box_array, box.new( left = box_left, top = box_top, right = box_right, bottom = box_bottom, border_color = demand_outline_color, bgcolor = demand_color, extend = extend.right, text = 'DEMAND', text_halign = text.align_center, text_valign = text.align_center, text_color = poi_label_color, text_size = size.small, xloc = xloc.bar_index)) box.delete( array.get(label_array, array.size(label_array) - 1) ) f_array_add_pop(label_array, box.new( left = box_left, top = poi, right = box_right, bottom = poi, border_color = color.new(poi_label_color,90), bgcolor = color.new(poi_label_color,90), extend = extend.right, text = 'POI', text_halign = text.align_left, text_valign = text.align_center, text_color = poi_label_color, text_size = size.small, xloc = xloc.bar_index)) // FUNCTION TO CHANGE SUPPLY/DEMAND TO A BOS IF BROKEN f_sd_to_bos(box_array, bos_array, label_array, zone_type) => if zone_type == 1 for i = 0 to array.size(box_array) - 1 level_to_break = box.get_top(array.get(box_array,i)) // if ta.crossover(close, level_to_break) if close >= level_to_break copied_box = box.copy(array.get(box_array,i)) f_array_add_pop(bos_array, copied_box) mid = (box.get_top(array.get(box_array,i)) + box.get_bottom(array.get(box_array,i))) / 2 box.set_top(array.get(bos_array,0), mid) box.set_bottom(array.get(bos_array,0), mid) box.set_extend( array.get(bos_array,0), extend.none) box.set_right( array.get(bos_array,0), bar_index) box.set_text( array.get(bos_array,0), 'BOS' ) box.set_text_color( array.get(bos_array,0), bos_label_color) box.set_text_size( array.get(bos_array,0), size.small) box.set_text_halign( array.get(bos_array,0), text.align_center) box.set_text_valign( array.get(bos_array,0), text.align_center)

box.delete(array.get(box_array, i)) box.delete(array.get(label_array, i)) if zone_type == -1 for i = 0 to array.size(box_array) - 1 level_to_break = box.get_bottom(array.get(box_array,i)) // if ta.crossunder(close, level_to_break) if close <= level_to_break copied_box = box.copy(array.get(box_array,i)) f_array_add_pop(bos_array, copied_box) mid = (box.get_top(array.get(box_array,i)) + box.get_bottom(array.get(box_array,i))) / 2 box.set_top(array.get(bos_array,0), mid) box.set_bottom(array.get(bos_array,0), mid) box.set_extend( array.get(bos_array,0), extend.none) box.set_right( array.get(bos_array,0), bar_index) box.set_text( array.get(bos_array,0), 'BOS' ) box.set_text_color( array.get(bos_array,0), bos_label_color) box.set_text_size( array.get(bos_array,0), size.small) box.set_text_halign( array.get(bos_array,0), text.align_center) box.set_text_valign( array.get(bos_array,0), text.align_center) box.delete(array.get(box_array, i)) box.delete(array.get(label_array, i)) // FUNCTION MANAGE CURRENT BOXES BY CHANGING ENDPOINT f_extend_box_endpoint(box_array) => for i = 0 to array.size(box_array) - 1 box.set_right(array.get(box_array, i), bar_index + 100) // //END FUNCTIONS // // //CALCULATIONS // // CALCULATE ATR atr = ta.atr(50) // CALCULATE SWING HIGHS & SWING LOWS swing_high = ta.pivothigh(high, swing_length, swing_length) swing_low = ta.pivotlow(low, swing_length, swing_length) // ARRAYS FOR SWING H/L & BN var swing_high_values = array.new_float(5,0.00) var swing_low_values = array.new_float(5,0.00) var swing_high_bns = array.new_int(5,0) var swing_low_bns = array.new_int(5,0) // ARRAYS FOR SUPPLY / DEMAND var current_supply_box = array.new_box(history_of_demand_to_keep, na) var current_demand_box = array.new_box(history_of_demand_to_keep, na) // ARRAYS FOR SUPPLY / DEMAND POI LABELS var current_supply_poi = array.new_box(history_of_demand_to_keep, na) var current_demand_poi = array.new_box(history_of_demand_to_keep, na) // ARRAYS FOR BOS var supply_bos = array.new_box(5, na) var demand_bos = array.new_box(5, na) // //END CALCULATIONS // // NEW SWING HIGH if not na(swing_high) //MANAGE SWING HIGH VALUES f_array_add_pop(swing_high_values, swing_high) f_array_add_pop(swing_high_bns, bar_index[swing_length]) if show_price_action_labels f_sh_sl_labels(swing_high_values, 1) f_supply_demand(swing_high_values, swing_high_bns, current_supply_box, current_supply_poi, 1, atr) // NEW SWING LOW else if not na(swing_low) //MANAGE SWING LOW VALUES f_array_add_pop(swing_low_values, swing_low) f_array_add_pop(swing_low_bns, bar_index[swing_length]) if show_price_action_labels f_sh_sl_labels(swing_low_values, -1) f_supply_demand(swing_low_values, swing_low_bns, current_demand_box, current_demand_poi, -1, atr) f_sd_to_bos(current_supply_box, supply_bos, current_supply_poi, 1) f_sd_to_bos(current_demand_box, demand_bos, current_demand_poi, -1) f_extend_box_endpoint(current_supply_box) f_extend_box_endpoint(current_demand_box) //ZIG ZAG h = ta.highest(high, swing_length * 2 + 1) l = ta.lowest(low, swing_length * 2 + 1) f_isMin(len) => l == low[len] f_isMax(len) => h == high[len] var dirUp = false var lastLow = high * 100 var lastHigh = 0.0 var timeLow = bar_index var timeHigh = bar_index var line li = na f_drawLine() => _li_color = show_zigzag ? zigzag_color : color.new(#ffffff,100) line.new(timeHigh - swing_length, lastHigh, timeLow - swing_length, lastLow, xloc.bar_index, color=_li_color, width=2) if dirUp if f_isMin(swing_length) and low[swing_length] < lastLow lastLow := low[swing_length] timeLow := bar_index line.delete(li) li := f_drawLine() li if f_isMax(swing_length) and high[swing_length] > lastLow lastHigh := high[swing_length] timeHigh := bar_index dirUp := false li := f_drawLine() li if not dirUp if f_isMax(swing_length) and high[swing_length] > lastHigh lastHigh := high[swing_length] timeHigh := bar_index line.delete(li) li := f_drawLine() li if f_isMin(swing_length) and low[swing_length] < lastHigh lastLow := low[swing_length] timeLow := bar_index dirUp := true li := f_drawLine() if f_isMax(swing_length) and

high[swing_length] > lastLow lastHigh := high[swing_length] timeHigh := bar_index dirUp := false li := f_drawLine() li // if barstate.islast // label.new(x = bar_index + 10, y = close[1], text = str.tostring( array.size(current_supply_poi) )) // label.new(x = bar_index + 20, y = close[1], text = str.tostring( box.get_bottom( array.get(current_supply_box, 0)))) // label.new(x = bar_index + 30, y = close[1], text = str.tostring( box.get_bottom( array.get(current_supply_box, 1)))) // label.new(x = bar_index + 40, y = close[1], text = str.tostring( box.get_bottom( array.get(current_supply_box, 2)))) // label.new(x = bar_index + 50, y = close[1], text = str.tostring( box.get_bottom( array.get(current_supply_box, 3)))) // label.new(x = bar_index + 60, y = close[1], text = str.tostring( box.get_bottom( array.get(current_supply_box, 4))))
Leave a Comment