// Mxwll Capital //@version=5 indicator("Mxwll Suite", overlay = true, max_labels_count = 500, max_lines_count = 500, max_boxes_count = 500, max_bars_back = 500) bullC = input.color(defval = #14D990, title = "Bull Color", group = "Smart Money Concepts", inline = "7") bearC = input.color(defval = #F24968, title = "Bear Color", group = "Smart Money Concepts", inline = "7") showInt = input.bool(defval = true, title = "Show Internals", group = "Smart Money Concepts") intSens = input.int(3, "Internals Sensitivity", options = [3 , 5 , 8 ], group = "Smart Money Concepts", inline = "20") intStru = input.string(defval = "All", title = "Internal Structure", options = ["All", "BoS", "CHoCH"], inline = "30", group = "Smart Money Concepts") showExt = input.bool(defval = true, title = "Show Externals" ,group = "Smart Money Concepts") extSens = input.int(25, "Externals Sensitivity", options = [10, 25, 50],group = "Smart Money Concepts", inline = "21") extStru = input.string(defval = "All", title = "External Structure", options = ["All", "BoS", "CHoCH"], inline = "31", group = "Smart Money Concepts") showOB = input.bool(defval = true, title = "Show Order Blocks" ,group = "Swing Blocks") showLast = input.int(defval = 10, title = "Swing Order Blocks", minval = 0, group = "Swing Blocks") showHHLH = input.bool(defval = true, title = "Show HH/LH", group = "Swing Blocks") showHLLL = input.bool(defval = true, title = "Show LH/LL", group = "Swing Blocks") showAOE = input.bool(defval = true, title = "Show Area of Interest", group = "Swing Blocks") show1D = input.bool(defval = true, title = "Show Previous Day High", group = "High/Low") show1DLab = input.bool(defval = true, title = "Show 1 Day Labels", group = "High/Low") show4H = input.bool(defval = true, title = "Show 4 Hour High", group = "High/Low") show4hLab = input.bool(defval = true, title = "Show 4 Hour Labels", group = "High/Low") showFVG = input.bool(defval = true, title = "Show Fair Value Gaps", group = "FVG") contract = input.bool(defval = false, title = "Contract Violated FVG", group = "FVG") closeOnly = input.bool(defval = false, title = "Show Closest Up/Down FVG Only", group = "FVG") fvgcol = input.color(defval = #F2B807, title = "FVG Color", group = "FVG") fvgtra = input.int(defval = 80, minval = 0, maxval = 100, title = "FVG Transparency", group = "FVG") showFibs = input.bool(defval = true, title = "Show Auto Fibs", group = "Auto Fibs") // extSensFibs = input.int(25, "Fibs Sensitivity", options = [10, 25, 50], group = "Auto Fibs", inline = "22") show236 = input.bool(defval = true, title = "", inline = "1", group = "Auto Fibs") show382 = input.bool(defval = true, title = "", inline = "2", group = "Auto Fibs") show5 = input.bool(defval = true, title = "", inline = "3", group = "Auto Fibs") show618 = input.bool(defval = true, title = "", inline = "4", group = "Auto Fibs") show786 = input.bool(defval = true, title = "", group = "Auto Fibs", inline = "5") fib1 = input.float(defval = .236, title = "", minval = 0, step = 0.01, inline = "1", group = "Auto Fibs") fib2 = input.float(defval = .382, title = "", minval = 0, step = 0.01, inline = "2", group = "Auto Fibs") fib3 = input.float(defval = .5, title = "", minval = 0, step = 0.01, inline = "3", group = "Auto Fibs") fib4 = input.float(defval = .618, title = "", minval = 0, step = 0.01, inline = "4", group = "Auto Fibs") fib5 = input.float(defval = .786, title = "", minval = 0, step = 0.01, group = "Auto Fibs", inline = "5") fib1col = input.color(title = "", defval = color.gray, inline = "1" , group = "Auto Fibs") fib2col = input.color(title = "", defval = color.lime, inline = "2" , group = "Auto Fibs") fib3col = input.color(title = "", defval = color.yellow, inline = "3", group = "Auto Fibs") fib4col = input.color(title = "", defval = color.orange, inline = "4", group = "Auto Fibs") fib5col = input.color(title = "", defval = color.red , group = "Auto Fibs", inline = "5") var bigData = map.new() if bigData.size() == 0 bigData.put("moving", 0) bigData.put("upaxis", 0.0) bigData.put("upaxis2", 0) bigData.put("dnaxis", 0.0) bigData.put("dnaxis2", 0) bigData.put("upside", 1) bigData.put("downside", 1) [pdHigh, pdLow, dayHigh, dayLow, pdBar, dayBar] = request.security(syminfo.tickerid, "1D", [high[1], low[1], high, low, time[1], time]) var highArr = array.new_float(), var lowArr = array.new_float() var timeArr = array.new_int (), var volArr = array.new_float() var closeArr = array.new_float(), var openArr = array.new_float() highArr.unshift(high), lowArr.unshift(low) timeArr.unshift(time), volArr.unshift(volume) closeArr.unshift(close), openArr.unshift(open) type rollingTF float highTF = 0 float lowTF = 1e8 int highTFt = 0 int lowTFt = 0 float volTF = 0 map rTFdraw map rTFlabel method tfDraw(int tfDiff, bool showRollingLab, string tf, bool showLevels) => TFhrdata = rollingTF.new(), var volRolling = array.new() if highArr.size() > tfDiff for i = 0 to tfDiff if showLevels and barstate.islast getHigh = highArr.get(i), getLow = lowArr.get(i), getTime = timeArr.get(i) TFhrdata.highTF := math.max(TFhrdata.highTF, getHigh) TFhrdata.lowTF := math.min(TFhrdata.lowTF , getLow ) if TFhrdata.highTF == getHigh TFhrdata.highTFt := timeArr.get(i) if TFhrdata.lowTF == getLow TFhrdata.lowTFt := timeArr.get(i) TFhrdata.volTF += volArr.get(i) volRolling.push(TFhrdata.volTF) var lineDraw = rollingTF.new(rTFdraw = map.new(), rTFlabel = map.new()) if showLevels switch lineDraw.rTFdraw.size() == 0 true => lineDraw.rTFdraw.put("High", line.new(TFhrdata.highTFt, TFhrdata.highTF, time, TFhrdata.highTF, xloc = xloc.bar_time, color = color.aqua)), lineDraw.rTFdraw.put("Low" , line.new(TFhrdata.lowTFt , TFhrdata.lowTF , time, TFhrdata.lowTF , xloc = xloc.bar_time, color = color.aqua)) => lineDraw.rTFdraw.get("High").set_xy1(TFhrdata.highTFt, TFhrdata.highTF), lineDraw.rTFdraw.get("High").set_xy2(time, TFhrdata.highTF), lineDraw.rTFdraw.get("Low").set_xy1(TFhrdata.lowTFt, TFhrdata.lowTF), lineDraw.rTFdraw.get("Low").set_xy2(time, TFhrdata.lowTF) if showRollingLab switch lineDraw.rTFlabel.size() == 0 true => lineDraw.rTFlabel.put("High", label.new(time, TFhrdata.highTF, xloc = xloc.bar_time, textcolor = color.aqua, text = tf + "H", size = size.tiny, style = label.style_label_left, color = #00000000 )), lineDraw.rTFlabel.put("Low" , label.new(time, TFhrdata.lowTF , xloc = xloc.bar_time, textcolor = color.aqua, text = tf + "L", size = size.tiny, style = label.style_label_left, color = #00000000 )) => lineDraw.rTFlabel.get("High") .set_xy(time, TFhrdata.highTF), lineDraw.rTFlabel.get("Low") .set_xy(time, TFhrdata.lowTF) [TFhrdata.volTF, volRolling] tfDrawLower(bool showRollingLab, simple string tf, bool showLevels) => simple int end = switch tf "240" => 240 "1D" => 1440 [o, h, l, c, v, t] = request.security_lower_tf(syminfo.tickerid, "1", [open, high, low, close, volume, time]) var oArr = array.new_float() var hArr = array.new_float() var lArr = array.new_float() var cArr = array.new_float() var vArr = array.new_float() var tArr = array.new_int() TFhrdata = rollingTF.new(), var volRolling = array.new() if h.size() > 0 for i = 0 to h.size() - 1 oArr.push(o.get(i)) hArr.push(h.get(i)) lArr.push(l.get(i)) cArr.push(c.get(i)) vArr.push(v.get(i)) tArr.push(t.get(i)) if hArr.size() > end oArr.shift() hArr.shift() lArr.shift() cArr.shift() vArr.shift() tArr.shift() for i = 0 to hArr.size() - 1 if showLevels getHigh = hArr.get(i), getLow = lArr.get(i), getTime = tArr.get(i) TFhrdata.highTF := math.max(TFhrdata.highTF, getHigh) TFhrdata.lowTF := math.min(TFhrdata.lowTF , getLow) if TFhrdata.highTF == getHigh TFhrdata.highTFt := tArr.get(i) if TFhrdata.lowTF == getLow TFhrdata.lowTFt := tArr.get(i) TFhrdata.volTF += vArr.get(i) volRolling.push(TFhrdata.volTF) var lineDraw = rollingTF.new(rTFdraw = map.new(), rTFlabel = map.new()) if showLevels switch lineDraw.rTFdraw.size() == 0 true => lineDraw.rTFdraw.put("High", line.new(TFhrdata.highTFt, TFhrdata.highTF, time, TFhrdata.highTF, xloc = xloc.bar_time, color = color.aqua)), lineDraw.rTFdraw.put("Low" , line.new(TFhrdata.lowTFt , TFhrdata.lowTF , time, TFhrdata.lowTF , xloc = xloc.bar_time, color = color.aqua)) => lineDraw.rTFdraw.get("High").set_xy1(TFhrdata.highTFt, TFhrdata.highTF), lineDraw.rTFdraw.get("High").set_xy2(time, TFhrdata.highTF), lineDraw.rTFdraw.get("Low").set_xy1(TFhrdata.lowTFt, TFhrdata.lowTF), lineDraw.rTFdraw.get("Low").set_xy2(time, TFhrdata.lowTF) if showRollingLab switch lineDraw.rTFlabel.size() == 0 true => lineDraw.rTFlabel.put("High", label.new(time, TFhrdata.highTF, xloc = xloc.bar_time, textcolor = color.aqua, text = tf + "H", size = size.tiny, style = label.style_label_left, color = #00000000 )), lineDraw.rTFlabel.put("Low" , label.new(time, TFhrdata.lowTF , xloc = xloc.bar_time, textcolor = color.aqua, text = tf + "L", size = size.tiny, style = label.style_label_left, color = #00000000 )) => lineDraw.rTFlabel.get("High") .set_xy(time, TFhrdata.highTF), lineDraw.rTFlabel.get("Low") .set_xy(time, TFhrdata.lowTF) [TFhrdata.volTF, volRolling] var r4hrbars = math.floor(timeframe.in_seconds("240") / timeframe.in_seconds(timeframe.period)) var rDbars = math.floor(timeframe.in_seconds("1D") / timeframe.in_seconds(timeframe.period)) [vol4hr, vol4hrArr] = switch timeframe.in_seconds() <= 60 => r4hrbars.tfDraw(show4hLab, "240", show4H) => tfDrawLower(show4hLab, "240", show4H) [vol1D, vol1DArr] = switch timeframe.in_seconds() <= 60 => rDbars.tfDraw(show1DLab, "1D", show1D) => tfDrawLower(show1DLab, "1D", show1D) calculatePivots(length)=> var int intraCalc = 0 if bar_index > length + 1 up = highArr.slice(0, length).max() dn = lowArr .slice(0, length).min() cHi = highArr.get(length) cLo = lowArr .get(length) intraCalc := switch cHi > up => 0 cLo < dn => 1 => intraCalc[1] topSwing = switch intraCalc == 0 and intraCalc[1] != 0 => cHi => 0 botSwing = switch intraCalc == 1 and intraCalc[1] != 1 => cLo => 0 [topSwing, botSwing] [bigUpper , bigLower ] = calculatePivots(extSens) [smallUpper , smallLower ] = calculatePivots(intSens) var label [] upLabel = array.new_label(1) var label [] dnLabel = array.new_label(1) var box [] highBlock = array.new_box() var box [] lowBlock = array.new_box() drawChar(x, y, str, col, down) => style = switch down true => label.style_label_down => label.style_label_up line.new (int(x), y, bar_index, y, color = col, style = line.style_dashed) label.new(math.round(math.avg(x, bar_index)), y, str, color = #00000000, textcolor = col, style = style, size = size.small) drawStructureExt() => var int counter = 0 if bigUpper != 0 bigData.put("upside", 1) x1 = bar_index - extSens txt = switch bigUpper > bigData.get("upaxis") true => 'HH' => 'LH' if showHHLH upLabel.set(0, label.new(x1, bigUpper, txt, color = color.new(color.white, 100), textcolor = bearC, style = label.style_label_down, size = size.small )) if showOB highBlock.push(box.new(x1, bigUpper, last_bar_index + 5, bigUpper * .998, border_color = color.new(color.red, 75), bgcolor = color.new(color.red, 95) )) bigData.put("upaxis" , bigUpper) bigData.put("upaxis2", x1) counter := 1 if bigLower != 0 bigData.put("downside", 1) x1 = bar_index - extSens txt = switch bigLower < bigData.get("dnaxis") true => "LL" => "HL" if showHLLL == true dnLabel.set(0, label.new(x1, bigLower, txt, color = #ffffff00, textcolor = bullC, style = label.style_label_up, size = size.small )) if showOB lowBlock.push(box.new(x1, bigLower, last_bar_index + 5, bigLower * 1.002, border_color = color.new(color.blue, 75), bgcolor = color.new(color.blue, 95) )) bigData.put("dnaxis" , bigLower) bigData.put("dnaxis2", x1) counter := -1 if showExt if ta.crossover(close, bigData.get("upaxis")) if bigData.get("upside") != 0 str = switch bigData.get("moving") < 0 true => extStru != "BoS" ? 'CHoCH' : "" => extStru != 'CHoCH' ? 'BoS' : "" if extStru == "All" or str.contains(extStru, str) drawChar(bigData.get("upaxis2"), bigData.get("upaxis"), str, bullC, true) bigData.put("upside", 0) bigData.put("moving", 1) if ta.crossunder(close, bigData.get("dnaxis")) if bigData.get("downside") != 0 str = switch bigData.get("moving") > 0 true => extStru != "BoS" ? 'CHoCH' : "" => extStru != 'CHoCH' ? 'BoS' : "" if extStru == "All" or str.contains(extStru, str) drawChar(bigData.get("dnaxis2"), bigData.get("dnaxis"), str, bearC, false) bigData.put("downside", 0) bigData.put("moving", -1) counter counter = drawStructureExt() method updateBox(array id) => if id.size() > 0 for i = 0 to id.size() - 1 id.get(i).set_right(last_bar_index + 5) method cleanseLevel(array id, bool isHighBlock) => if id.size() > 0 for i = id.size() - 1 to 0 condition = switch isHighBlock true => close >= id.get(i).get_top() => close <= id.get(i).get_bottom() if condition id.remove(i).delete() if id.size() > showLast and showLast != 0 for i = id.size() - showLast to 0 id.remove(i).delete() highBlock.cleanseLevel(true) lowBlock .cleanseLevel(false) if barstate.islast highBlock.updateBox() lowBlock .updateBox() method updateMain(line id) => hi = 0.0 lo = 1e8 if showFibs [bigUpperFibs, bigLowerFibs] = calculatePivots(25) var int counterFibs = 0 if bigUpperFibs != 0 counterFibs := 1 if bigLowerFibs != 0 counterFibs := -1 if counterFibs == 1 hi := 0.0 id.set_xy1(int(bigData.get("upaxis2")), bigData.get("upaxis")) for i = 0 to bar_index - int(bigData.get("dnaxis2")) getLow = lowArr.get(i) lo := math.min(getLow, lo) if lo == getLow id.set_xy2(bar_index - i, lo) else if counterFibs == -1 lo := 1e8 id.set_xy1(int(bigData.get("dnaxis2")), bigData.get("dnaxis")) for i = 0 to bar_index - bigData.get("upaxis2") getHigh = highArr.get(i) hi := math.max(highArr.get(i), hi) if hi == getHigh id.set_xy2(bar_index - i, hi) if id.get_x2() < id.get_x1() x2 = id.get_x2(), x1 = id.get_x1() y2 = id.get_y2(), y1 = id.get_y1(), id.set_xy2(x1, y1), id.set_xy1(x2, y2) switch id.get_y2() < id.get_y1() true => id.set_color(#F24968) => id.set_color(#14D990) 0 var main = line.new(dnLabel.first().get_x(), dnLabel.first().get_y(), upLabel.first().get_x(), upLabel.first().get_y(), style = line.style_dashed, width = 2 ) main.updateMain() quickLine(getX2, y, color) => line.new(getX2, y, bar_index + 5, y, color = color.new(color, 75)) quickLabel(y, txt, color) => label.new(bar_index + 5, y, text = str.tostring(txt), color = #00000000, style = label.style_label_left, textcolor = color) drawFibs() => if barstate.islast var fibLine = array.new(5) var fibLab = array.new