0% found this document useful (0 votes)
6 views8 pages

rQVwzTSpmd

The document outlines a trading indicator script designed for technical analysis, incorporating various components such as ETRP, MACD, ADX, EMAs, and KRO Overlay. It includes user-defined inputs for customizing the indicator's parameters, such as source, length, and alert settings, as well as configurations for visual elements like colors and display options. The script also features functions for rendering order blocks and managing their properties based on market volume and price action.

Uploaded by

dipankarkar2008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views8 pages

rQVwzTSpmd

The document outlines a trading indicator script designed for technical analysis, incorporating various components such as ETRP, MACD, ADX, EMAs, and KRO Overlay. It includes user-defined inputs for customizing the indicator's parameters, such as source, length, and alert settings, as well as configurations for visual elements like colors and display options. The script also features functions for rendering order blocks and managing their properties based on market volume and price action.

Uploaded by

dipankarkar2008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

1st indicator: //@version=5 indicator("deep Volumized Order Blocks + ETRP, MACD, ADX, EMAs, KRO Overlay", shorttitle="deep vol+kro+etrp

+macd+adx", overlay=true, max_boxes_count=500, max_labels_count=500, max_lines_count=500, max_bars_back=5000) // Import necessary


libraries import HeWhoMustNotBeNamed/_matrix/5 as ma import HeWhoMustNotBeNamed/arrayutils/21 as ar import
HeWhoMustNotBeNamed/enhanced_ta/14 as eta import HeWhoMustNotBeNamed/drawingutils/8 as dr import HeWhoMustNotBeNamed/
arrays/1 as pa import QuantraAI/QuantraMAs/2 as DynamicMA import QuantraSystems/DynamicFunctions/1 as DynamicFunc // Inputs for
ETRP source = input.source(close, "Source", group="ETRP") type = input.string("sma", "Type", options=["sma", "ema", "rma", "wma"],
group="ETRP") length = input.int(20, "Length", step=5, group="ETRP") level = input.int(10, "Level", minval=5, step=5, group="ETRP")
minMaxRangePercentile = input.int(20, 'Range Percentile', minval=5, maxval=45, step=5, group="ETRP") extremeMinMaxRangePercentile =
input.int(45, 'Extreme Range Percentile', minval=40, maxval=48, step=2, group="ETRP") history = input.int(1000, 'Percentile History',
minval=1000, maxval=5000, step=500, group="ETRP") realTimeAlerts = input.bool(false, 'Real Time Alerts', 'If set to true, alerts are fired on
latest candle - which may repaint. For safer option set this to false', group="ETRP") maxHistory = length - 1 // Inputs for ADX and MACD
showsignals = input(true, title="Show BUY/SELL Signals", group="ADX/MACD") showcandlecolors = input(true, title="Show Candle Colors",
group="ADX/MACD") adx_length = input(14, title="ADX Length", group="ADX/MACD") adx_smoothing = input(10, title="ADX Smoothing",
group="ADX/MACD") macdsource = input(close, title="MACD Source", group="ADX/MACD") macdfast = input(12, title="MACD Fast Length",
group="ADX/MACD") macdslow = input(26, title="MACD Slow Length", group="ADX/MACD") macdsignal = input(9, title="MACD Signal Length",
group="ADX/MACD") colorup = input(color.green, title="Up Candle Color", group="ADX/MACD") colordown = input(color.red, title="Down Candle
Color", group="ADX/MACD") // Inputs for KRO Overlay var string KRS = "KRO Overlay - Settings", var string KRU = "KRO Overlay - UI" kro_source =
input.source(close, "Source", group=KRS) bandwidth = input.int(45, "Bandwidth", 1, group=KRS, tooltip="Length of the Kernel Regression
calculation") width = input.float(2, "Width", step=0.2, group=KRS, tooltip="Smoothes the Signal") sdLook = input.int(150, "Standard Deviation
Lookback", group=KRS, tooltip="Length of the SD bands lookback period") sdMult = input.float(3, "Standard Deviation Extreme for OB/OS
Border", step=0.5, group=KRS, tooltip="Defines the outer border of the SD bands. The inner border begins at 50% of the SD Multiplier") ColMode
= input.string("Modern", "Color Palette Choice", inline="drop", group=KRU, options=["Classic", "Modern", "Robust", "Accented", "Monochrome"])
man = input.bool(false, "Custom Palette", inline="drop", group=KRU) manUpC = input.color(#00ff00, "Custom Up", inline="man", group=KRU)
manDnC = input.color(#ff0000, "Custom Down", inline="man", group=KRU) sig = input.bool(false, "Show Trend Signals", group=KRU) BCol =
input.bool(true, "Enable Bar Coloring", group=KRU) devS = input.bool(true, "Enable Deviation Band Shading", group=KRU) OBOS = input.bool(true,
"Enable Overbought/Oversold Shading", group=KRU) TR = input.int(85, "Shading Transparency", 0, 100, group=KRU) // EMA Inputs ema9_length
= 9 ema200_length = 200 ema1000_length = 1000 // Turtle Soup Inputs const bool DEBUG = false const int maxDistanceToLastBar = 4900 //
Affects Running Time const int atrLen = 5 const bool maxTPLastHour = false var initRun = true // Volumized Order Blocks Inputs const int
maxBoxesCount = 500 const float overlapThresholdPercentage = 0 const int maxOrderBlocks = 30 showInvalidated = input.bool(true, "Show
Historic Zones", group="General Configuration", display=display.none) OBsEnabled = true orderBlockVolumetricInfo = input.bool(true,
"Volumetric Info", group="General Configuration", inline="EV", display=display.none) obEndMethod = input.string("Wick", "Zone Invalidation",
options=["Wick", "Close"], group="General Configuration", display=display.none) combineOBs = DEBUG ? input.bool(true, "Combine Zones",
group="General Configuration", display=display.none) : true maxATRMult = DEBUG ? input.float(3.5,"Max Atr Multiplier", group="General
Configuration") : 3.5 swingLength = input.int(10, 'Swing Length', minval=3, tooltip="Swing length is used when finding order block formations.
Smaller values will result in finding smaller order blocks.", group="General Configuration", display=display.none) zoneCount = input.string("Low",
'Zone Count', options=["High", "Medium", "Low", "One"], tooltip="Number of Order Block Zones to be rendered. Higher options will result in older
Order Blocks shown.", group="General Configuration", display=display.none) bullOrderBlockColor = input(#08998180, 'Bullish', inline='obColor',
group='General Configuration', display=display.none) bearOrderBlockColor = input(#f2364680, 'Bearish', inline='obColor', group='General
Configuration', display=display.none) bullishOrderBlocks = zoneCount == "One" ? 1 : zoneCount == "Low" ? 3 : zoneCount == "Medium" ? 5 : 10
bearishOrderBlocks = zoneCount == "One" ? 1 : zoneCount == "Low" ? 3 : zoneCount == "Medium" ? 5 : 10 timeframe1Enabled = true timeframe1
= "" textColor = input.color(#ffffff80, "Text Color", group="Style") extendZonesBy = DEBUG ? input.int(15, "Extend Zones", group="Style",
minval=1, maxval=30, inline="ExtendZones") : 15 extendZonesDynamic = DEBUG ? input.bool(true, "Dynamic", group="Style",
inline="ExtendZones") : true combinedText = DEBUG ? input.bool(false, "Combined Text", group="Style", inline="CombinedColor") : false
volumeBarsPlace = DEBUG ? input.string("Left", "Show Volume Bars At", options=["Left", "Right"], group="Style", inline="volumebars") : "Left"
mirrorVolumeBars = DEBUG ? input.bool(true, "Mirror Volume Bars", group="Style", inline="volumebars") : true volumeBarsLeftSide =
(volumeBarsPlace == "Left") extendZonesByTime = extendZonesBy * timeframe.in_seconds(timeframe.period) * 1000 atr = ta.atr(10) //
Functions and types for Volumized Order Blocks type orderBlockInfo float top float bottom float obVolume string obType int startTime float
bbVolume float obLowVolume float obHighVolume bool breaker int breakTime string timeframeStr bool disabled = false string
combinedTimeframesStr = na bool combined = false type orderBlock orderBlockInfo info bool isRendered = false box orderBox = na box
breakerBox = na line orderBoxLineTop = na line orderBoxLineBottom = na line breakerBoxLineTop = na line breakerBoxLineBottom = na // box
orderBoxText = na box orderBoxPositive = na box orderBoxNegative = na line orderSeperator = na line orderTextSeperator = na
createOrderBlock(orderBlockInfo orderBlockInfoF) => orderBlock newOrderBlock = orderBlock.new(orderBlockInfoF) newOrderBlock
safeDeleteOrderBlock(orderBlock orderBlockF) => orderBlockF.isRendered := false box.delete(orderBlockF.orderBox)
box.delete(orderBlockF.breakerBox) box.delete(orderBlockF.orderBoxText) box.delete(orderBlockF.orderBoxPositive)
box.delete(orderBlockF.orderBoxNegative) line.delete(orderBlockF.orderBoxLineTop) line.delete(orderBlockF.orderBoxLineBottom)
line.delete(orderBlockF.breakerBoxLineTop) line.delete(orderBlockF.breakerBoxLineBottom) line.delete(orderBlockF.orderSeperator)
line.delete(orderBlockF.orderTextSeperator) type timeframeInfo int index = na string timeframeStr = na bool isEnabled = false orderBlockInfo[]
bullishOrderBlocksList = na orderBlockInfo[] bearishOrderBlocksList = na newTimeframeInfo(index, timeframeStr, isEnabled) => newTFInfo =
timeframeInfo.new() newTFInfo.index := index newTFInfo.isEnabled := isEnabled newTFInfo.timeframeStr := timeframeStr newTFInfo type
obSwing int x = na float y = na float swingVolume = na bool crossed = false // ____ TYPES END ____ var timeframeInfo[] timeframeInfos =
array.from(newTimeframeInfo(1, timeframe1, timeframe1Enabled)) var bullishOrderBlocksList = array.new(0) var bearishOrderBlocksList =
array.new(0) var allOrderBlocksList = array.new(0) moveLine(_line, _x, _y, _x2) => line.set_xy1(_line, _x, _y) line.set_xy2(_line, _x2, _y)
moveBox(_box, _topLeftX, _topLeftY, _bottomRightX, _bottomRightY) => box.set_lefttop(_box, _topLeftX, _topLeftY) box.set_rightbottom(_box,
_bottomRightX, _bottomRightY) isTimeframeLower(timeframe1F, timeframe2F) => timeframe.in_seconds(timeframe1F) <
timeframe.in_seconds(timeframe2F) getMinTimeframe(timeframe1F, timeframe2F) => if isTimeframeLower(timeframe1F, timeframe2F)
timeframe1F else timeframe2F getMaxTimeframe(timeframe1F, timeframe2F) => if isTimeframeLower(timeframe1F, timeframe2F)
timeframe2F else timeframe1F formatTimeframeString(formatTimeframe) => timeframeF = formatTimeframe == "" ? timeframe.period :
formatTimeframe if str.contains(timeframeF, "D") or str.contains(timeframeF, "W") or str.contains(timeframeF, "S") or str.contains(timeframeF,
"M") timeframeF else seconds = timeframe.in_seconds(timeframeF) if seconds >= 3600 hourCount = int(seconds / 3600)
str.tostring(hourCount) + " Hour" + (hourCount > 1 ? "s" : "") else timeframeF + " Min" betterCross(s1, s2) => string ret = na if s1 >= s2 and s1[1] <
s2 ret := "Bull" if s1 < s2 and s1[1] >= s2 ret := "Bear" ret colorWithTransparency(colorF, transparencyX) => color.new(colorF, color.t(colorF) *
transparencyX) createOBBox(boxColor, transparencyX=1.0, xlocType=xloc.bar_time) => box.new(na, na, na, na, text_size=size.normal,
xloc=xlocType, extend=extend.none, bgcolor=colorWithTransparency(boxColor, transparencyX), text_color=textColor,
text_halign=text.align_center, border_color=#00000000) renderOrderBlock(orderBlock ob) => orderBlockInfo info = ob.info ob.isRendered := true
orderColor = ob.info.obType == "Bull" ? bullOrderBlockColor : bearOrderBlockColor if OBsEnabled and (not false or not (false and info.breaker))
and not (not showInvalidated and info.breaker) ob.orderBox := createOBBox(orderColor, 1.5) if ob.info.combined
ob.orderBox.set_bgcolor(colorWithTransparency(orderColor, 1.1)) ob.orderBoxText := createOBBox(color.new(color.white, 100)) if
orderBlockVolumetricInfo ob.orderBoxPositive := createOBBox(bullOrderBlockColor) ob.orderBoxNegative :=
createOBBox(bearOrderBlockColor) ob.orderSeperator := line.new(na, na, na, na, xloc.bar_time, extend.none, textColor, line.style_dashed, 1)
ob.orderTextSeperator := line.new(na, na, na, na, xloc.bar_time, extend.none, textColor, line.style_solid, 1) zoneSize = extendZonesDynamic ?
na(info.breakTime) ? extendZonesByTime : (info.breakTime - info.startTime) : extendZonesByTime if na(info.breakTime) zoneSize := (time + 1) -
info.startTime startX = volumeBarsLeftSide ? info.startTime : info.startTime + zoneSize - zoneSize / 3 maxEndX = volumeBarsLeftSide ?
info.startTime + zoneSize / 3 : info.startTime + zoneSize moveBox(ob.orderBox, info.startTime, info.top, info.startTime + zoneSize, info.bottom)
moveBox(ob.orderBoxText, volumeBarsLeftSide ? maxEndX : info.startTime, info.top, volumeBarsLeftSide ? info.startTime + zoneSize : startX,
info.bottom) percentage = int((math.min(info.obHighVolume, info.obLowVolume) / math.max(info.obHighVolume, info.obLowVolume)) * 100.0)
OBText = (na(ob.info.combinedTimeframesStr) ? formatTimeframeString(ob.info.timeframeStr) : ob.info.combinedTimeframesStr) + " OB"
box.set_text(ob.orderBoxText, (orderBlockVolumetricInfo ? str.tostring(ob.info.obVolume, format.volume) + " (" + str.tostring(percentage) +
"%)\n" : "") + (combinedText and ob.info.combined ? "[Combined]\n" : "") + OBText) if orderBlockVolumetricInfo showHighLowBoxText = false
curEndXHigh = int(math.ceil((info.obHighVolume / info.obVolume) * (maxEndX - startX) + startX)) curEndXLow =
int(math.ceil((info.obLowVolume / info.obVolume) * (maxEndX - startX) + startX)) moveBox(ob.orderBoxPositive, mirrorVolumeBars ? startX :
curEndXLow, info.top, mirrorVolumeBars ? curEndXHigh : maxEndX, (info.bottom + info.top) / 2) box.set_text(ob.orderBoxPositive,
showHighLowBoxText ? str.tostring(info.obHighVolume, format.volume) : "") moveBox(ob.orderBoxNegative, mirrorVolumeBars ? startX :
curEndXHigh, info.bottom, mirrorVolumeBars ? curEndXLow : maxEndX, (info.bottom + info.top) / 2) box.set_text(ob.orderBoxNegative,
showHighLowBoxText ? str.tostring(info.obLowVolume, format.volume) : "") moveLine(ob.orderSeperator, volumeBarsLeftSide ? startX :
maxEndX, (info.bottom + info.top) / 2, volumeBarsLeftSide ? maxEndX : startX) line.set_xy1(ob.orderTextSeperator, volumeBarsLeftSide ?
maxEndX : startX, info.top) line.set_xy2(ob.orderTextSeperator, volumeBarsLeftSide ? maxEndX : startX, info.bottom) // Fix the position of
findOBSwings findOBSwings(len) => var swingType = 0 var obSwing top = obSwing.new(na, na) var obSwing bottom = obSwing.new(na, na)
upper = ta.highest(len) lower = ta.lowest(len) swingType := high[len] > upper ? 0 : low[len] < lower ? 1 : swingType if swingType == 0 and
swingType[1] != 0 top := obSwing.new(bar_index[len], high[len], volume[len]) if swingType == 1 and swingType[1] != 1 bottom :=
obSwing.new(bar_index[len], low[len], volume[len]) [top, bottom] // Fix the position of findOrderBlocks findOrderBlocks() => [top, btm] =
findOBSwings(swingLength) if bar_index > last_bar_index - maxDistanceToLastBar useBody = false max = useBody ? math.max(close, open) :
high min = useBody ? math.min(close, open) : low // Bullish Order Block bullishBreaked = 0 if bullishOrderBlocksList.size() > 0 for i =
bullishOrderBlocksList.size() - 1 to 0 currentOB = bullishOrderBlocksList.get(i) if not currentOB.breaker if (obEndMethod == "Wick" ? low :
math.min(open, close)) < currentOB.bottom currentOB.breaker := true currentOB.breakTime := time currentOB.bbVolume := volume else if high >
currentOB.top bullishOrderBlocksList.remove(i) else if i < bullishOrderBlocks and top.y < currentOB.top and top.y > currentOB.bottom
bullishBreaked := 1 if close > top.y and not top.crossed top.crossed := true boxBtm = max[1] boxTop = min[1] boxLoc = time[1] for i = 1 to
(bar_index - top.x) - 1 boxBtm := math.min(min[i], boxBtm) boxTop := boxBtm == min[i] ? max[i] : boxTop boxLoc := boxBtm == min[i] ? time[i] :
boxLoc newOrderBlockInfo = orderBlockInfo.new(boxTop, boxBtm, volume + volume[1] + volume[2], "Bull", boxLoc)
newOrderBlockInfo.obLowVolume := volume[2] newOrderBlockInfo.obHighVolume := volume + volume[1] obSize =
math.abs(newOrderBlockInfo.top - newOrderBlockInfo.bottom) if obSize <= atr * maxATRMult
bullishOrderBlocksList.unshift(newOrderBlockInfo) if bullishOrderBlocksList.size() > maxOrderBlocks bullishOrderBlocksList.pop() // Bearish
Order Block bearishBreaked = 0 if bearishOrderBlocksList.size() > 0 for i = bearishOrderBlocksList.size() - 1 to 0 currentOB =
bearishOrderBlocksList.get(i) if not currentOB.breaker if (obEndMethod == "Wick" ? high : math.max(open, close)) > currentOB.top
currentOB.breaker := true currentOB.breakTime := time currentOB.bbVolume := volume else if low < currentOB.bottom
bearishOrderBlocksList.remove(i) else if i < bearishOrderBlocks and btm.y > currentOB.bottom and btm.y < currentOB.top bearishBreaked := 1 if
close < btm.y and not btm.crossed btm.crossed := true boxBtm = min[1] boxTop = max[1] boxLoc = time[1] for i = 1 to (bar_index - btm.x) - 1
boxTop := math.max(max[i], boxTop) boxBtm := boxTop == max[i] ? min[i] : boxBtm boxLoc := boxTop == max[i] ? time[i] : boxLoc
newOrderBlockInfo = orderBlockInfo.new(boxTop, boxBtm, volume + volume[1] + volume[2], "Bear", boxLoc)
newOrderBlockInfo.obLowVolume := volume + volume[1] newOrderBlockInfo.obHighVolume := volume[2] obSize =
math.abs(newOrderBlockInfo.top - newOrderBlockInfo.bottom) if obSize <= atr * maxATRMult
bearishOrderBlocksList.unshift(newOrderBlockInfo) if bearishOrderBlocksList.size() > maxOrderBlocks bearishOrderBlocksList.pop() true
areaOfOB(orderBlockInfo OBInfoF) => float XA1 = OBInfoF.startTime float XA2 = na(OBInfoF.breakTime) ? time + 1 : OBInfoF.breakTime float
YA1 = OBInfoF.top float YA2 = OBInfoF.bottom float edge1 = math.sqrt((XA2 - XA1) * (XA2 - XA2) + (YA2 - YA2) * (YA2 - YA2)) float edge2 =
math.sqrt((XA2 - XA2) * (XA2 - XA2) + (YA2 - YA1) * (YA2 - YA1)) float totalArea = edge1 * edge2 totalArea doOBsTouch(orderBlockInfo OBInfo1,
orderBlockInfo OBInfo2) => float XA1 = OBInfo1.startTime float XA2 = na(OBInfo1.breakTime) ? time + 1 : OBInfo1.breakTime float YA1 =
OBInfo1.top float YA2 = OBInfo1.bottom float XB1 = OBInfo2.startTime float XB2 = na(OBInfo2.breakTime) ? time + 1 : OBInfo2.breakTime float
YB1 = OBInfo2.top float YB2 = OBInfo2.bottom float intersectionArea = math.max(0, math.min(XA2, XB2) - math.max(XA1, XB1)) * math.max(0,
math.min(YA1, YB1) - math.max(YA2, YB2)) float unionArea = areaOfOB(OBInfo1) + areaOfOB(OBInfo2) - intersectionArea float
overlapPercentage = (intersectionArea / unionArea) * 100.0 if overlapPercentage > overlapThresholdPercentage true else false
isOBValid(orderBlockInfo OBInfo) => valid = true if OBInfo.disabled valid := false valid combineOBsFunc() => if allOrderBlocksList.size() > 0
lastCombinations = 999 while lastCombinations > 0 lastCombinations := 0 for i = 0 to allOrderBlocksList.size() - 1 curOB1 =
allOrderBlocksList.get(i) for j = 0 to allOrderBlocksList.size() - 1 curOB2 = allOrderBlocksList.get(j) if i == j continue if not isOBValid(curOB1.info)
or not isOBValid(curOB2.info) continue if curOB1.info.obType != curOB2.info.obType continue if doOBsTouch(curOB1.info, curOB2.info)
curOB1.info.disabled := true curOB2.info.disabled := true orderBlock newOB = createOrderBlock(orderBlockInfo.new(math.max(curOB1.info.top,
curOB2.info.top), math.min(curOB1.info.bottom, curOB2.info.bottom), curOB1.info.obVolume + curOB2.info.obVolume, curOB1.info.obType))
newOB.info.startTime := math.min(curOB1.info.startTime, curOB2.info.startTime) newOB.info.breakTime :=
math.max(nz(curOB1.info.breakTime), nz(curOB2.info.breakTime)) newOB.info.breakTime := newOB.info.breakTime == 0 ? na :
newOB.info.breakTime newOB.info.timeframeStr := curOB1.info.timeframeStr newOB.info.obVolume := curOB1.info.obVolume +
curOB2.info.obVolume newOB.info.obLowVolume := curOB1.info.obLowVolume + curOB2.info.obLowVolume newOB.info.obHighVolume :=
curOB1.info.obHighVolume + curOB2.info.obHighVolume newOB.info.bbVolume := nz(curOB1.info.bbVolume, 0) + nz(curOB2.info.bbVolume, 0)
newOB.info.breaker := curOB1.info.breaker or curOB2.info.breaker newOB.info.combined := true if
timeframe.in_seconds(curOB1.info.timeframeStr) != timeframe.in_seconds(curOB2.info.timeframeStr) newOB.info.combinedTimeframesStr :=
(na(curOB1.info.combinedTimeframesStr) ? formatTimeframeString(curOB1.info.timeframeStr) : curOB1.info.combinedTimeframesStr) + " & "
+ (na(curOB2.info.combinedTimeframesStr) ? formatTimeframeString(curOB2.info.timeframeStr) : curOB2.info.combinedTimeframesStr)
allOrderBlocksList.unshift(newOB) lastCombinations += 1 reqSeq(timeframeStr) => [bullishOrderBlocksListF, bearishOrderBlocksListF] =
request.security(syminfo.tickerid, timeframeStr, [bullishOrderBlocksList, bearishOrderBlocksList]) [bullishOrderBlocksListF,
bearishOrderBlocksListF] getTFData(timeframeInfo timeframeInfoF, timeframeStr) => if not isTimeframeLower(timeframeInfoF.timeframeStr,
timeframe.period) and timeframeInfoF.isEnabled [bullishOrderBlocksListF, bearishOrderBlocksListF] = reqSeq(timeframeStr)
[bullishOrderBlocksListF, bearishOrderBlocksListF] else [na, na] handleTimeframeInfo(timeframeInfo timeframeInfoF, bullishOrderBlocksListF,
bearishOrderBlocksListF) => if not isTimeframeLower(timeframeInfoF.timeframeStr, timeframe.period) and timeframeInfoF.isEnabled
timeframeInfoF.bullishOrderBlocksList := bullishOrderBlocksListF timeframeInfoF.bearishOrderBlocksList := bearishOrderBlocksListF
handleOrderBlocksFinal() => if DEBUG log.info("Bullish OB Count " + str.tostring(bullishOrderBlocksList.size())) log.info("Bearish OB Count " +
str.tostring(bearishOrderBlocksList.size())) if allOrderBlocksList.size() > 0 for i = 0 to allOrderBlocksList.size() - 1
safeDeleteOrderBlock(allOrderBlocksList.get(i)) allOrderBlocksList.clear() for i = 0 to timeframeInfos.size() - 1 curTimeframe =
timeframeInfos.get(i) if not curTimeframe.isEnabled continue if curTimeframe.bullishOrderBlocksList.size() > 0 for j = 0 to
math.min(curTimeframe.bullishOrderBlocksList.size() - 1, bullishOrderBlocks - 1) orderBlockInfoF = curTimeframe.bullishOrderBlocksList.get(j)
orderBlockInfoF.timeframeStr := curTimeframe.timeframeStr
allOrderBlocksList.unshift(createOrderBlock(orderBlockInfo.copy(orderBlockInfoF))) if curTimeframe.bearishOrderBlocksList.size() > 0 for j = 0
to math.min(curTimeframe.bearishOrderBlocksList.size() - 1, bearishOrderBlocks - 1) orderBlockInfoF =
curTimeframe.bearishOrderBlocksList.get(j) orderBlockInfoF.timeframeStr := curTimeframe.timeframeStr
allOrderBlocksList.unshift(createOrderBlock(orderBlockInfo.copy(orderBlockInfoF))) if combineOBs combineOBsFunc() if
allOrderBlocksList.size() > 0 for i = 0 to allOrderBlocksList.size() - 1 curOB = allOrderBlocksList.get(i) if isOBValid(curOB.info)
renderOrderBlock(curOB) // Main execution findOrderBlocks() [bullishOrderBlocksListTimeframe1, bearishOrderBlocksListTimeframe1] =
getTFData(timeframeInfos.get(0), timeframe1) if barstate.isconfirmed handleTimeframeInfo(timeframeInfos.get(0),
bullishOrderBlocksListTimeframe1, bearishOrderBlocksListTimeframe1) handleOrderBlocksFinal() // Calculations for ETRP ema(float
currentEma, float source, simple int length) => k = 2 / (length + 1) ema = source * k + (1 - k) * currentEma ema rma(float currentRma, float
source, simple int length) => k = 2 / (length + 1) rma = (currentRma * (length-1) + source)/length rma var maMatrix = matrix.new(1, level+1,
source) if (type == "ema") emaArray = array.new(1, source) for i = 1 to matrix.columns(maMatrix) - 1 emaValue = ema(matrix.get(maMatrix, 0, i),
array.get(emaArray, array.size(emaArray) - 1), length) array.push(emaArray, emaValue) ma.unshift(maMatrix, emaArray, maxHistory) if (type ==
"rma") rmaArray = array.new(1, source) for i = 1 to matrix.columns(maMatrix) - 1 rmaValue = rma(matrix.get(maMatrix, 0, i), array.get(rmaArray,
array.size(rmaArray) - 1), length) array.push(rmaArray, rmaValue) ma.unshift(maMatrix, rmaArray, maxHistory) if (type == "sma" or type ==
"wma") maArray = array.new(1, source) for i = 1 to matrix.columns(maMatrix) - 1 values = matrix.col(maMatrix, i - 1) tmpArray = array.new(1,
array.get(maArray, i - 1)) tmpArray := array.concat(tmpArray, values) array.push(maArray, ar.ma(tmpArray, type, length)) ma.unshift(maMatrix,
maArray, maxHistory) strength = 0 bearishStrength = 0 diffMatrix = matrix.new(level + 1, level + 1, 0) var linesArray = array.new() var labelsArray
= array.new() ar.clear(linesArray) ar.clear(labelsArray) for i = 0 to level for j = 0 to level pma = matrix.get(maMatrix, 0, i) nma =
matrix.get(maMatrix, 0, j) if (j > i) strength := pma > nma ? strength + 1 : strength matrix.set(diffMatrix, i, j, math.sign(pma - nma)) lastRow =
matrix.row(maMatrix, 0) lastRowIndex = array.sort_indices(array.slice(lastRow, 1, array.size(lastRow)), order.descending) if (barstate.islast) for i
= 1 to level levelColor = color.from_gradient(i, 1, level, color.green, color.red) dr.draw_labelled_line(array.get(lastRow, i), type + '(' + str.tostring(i) +
')', levelColor, levelColor, 0, true, linesArray, labelsArray) minRange = ta.percentile_nearest_rank(strength, history, 50 - minMaxRangePercentile)
maxRange = ta.percentile_nearest_rank(strength, history, 50 + minMaxRangePercentile) extremeMinRange =
ta.percentile_nearest_rank(strength, history, 50 - extremeMinMaxRangePercentile) extremeMaxRange = ta.percentile_nearest_rank(strength,
history, 50 + extremeMinMaxRangePercentile) plotColor = strength > extremeMaxRange ? color.green : strength > maxRange ? color.lime :
strength < extremeMinRange ? color.red : strength < minRange ? color.orange : color.silver strengthRange = strength > extremeMaxRange ? 2 :
strength > maxRange ? 1 : strength > minRange ? 0 : strength < extremeMinRange ? -1 : -2 maxStrength = level * (level + 1) / 2 maValue =
eta.ma(source, type, length) bullishTrendReversalPoint = strength[1] == maxStrength and ta.crossunder(source, maValue)
bearishTrendReversalPoint = strength[1] == 0 and ta.crossover(source, maValue) plotshape(bullishTrendReversalPoint, 'Bullish Trend Reversal
Point', style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small) plotshape(bearishTrendReversalPoint, 'Bearish
Trend Reversal Point', style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small) plot(strength, "Strength",
color=color.silver, display=display.data_window) plot(minRange, "Min Range", color=color.orange, display=display.data_window) plot(maxRange,
"Max Range", color=color.lime, display=display.data_window) plot(extremeMinRange, "Extreme Min Range", color=color.red,
display=display.data_window) plot(extremeMaxRange, "Extreme Max Range", color=color.green, display=display.data_window)
plot(strengthRange, "Strength Range", color=color.blue, display=display.data_window) plot(maValue, "Moving Average", plotColor)
alertcondition(bullishTrendReversalPoint[realTimeAlerts ? 0 : 1], "Bullish Trend Reversal", "Possible reversal of bullish trend")
alertcondition(bearishTrendReversalPoint[realTimeAlerts ? 0 : 1], "Bearish Trend Reversal", "Possible reversal of bearish trend") // Calculations
for ADX and MACD [diplus, diminus, adx] = ta.dmi(adx_length, adx_smoothing) [macdline, signalline, histline] = ta.macd(macdsource, macdfast,
macdslow, macdsignal) longcheck = diplus > diminus and macdline > signalline shortcheck = diminus > diplus and signalline > macdline var int
trade = 0 if trade == 0 and longcheck trade := 1 else if trade == 0 and shortcheck trade := -1 else if trade == 1 and shortcheck trade := -1 else if
trade == -1 and longcheck trade := 1 else trade := trade[1] colors = longcheck ? colorup : shortcheck ? colordown : color.white plotcandle(open,
high, low, close, color=showcandlecolors ? colors : na) plotshape(trade[1] != 1 and trade == 1 and showsignals, style=shape.labelup, text='BUY',
textcolor=color.white, color=color.green, size=size.small, location=location.belowbar) plotshape(trade[1] != -1 and trade == -1 and showsignals,
style=shape.labeldown, text='SELL', textcolor=color.white, color=color.red, size=size.small, location=location.abovebar) alertcondition(trade[1] !=
1 and trade == 1, "LONG") alertcondition(trade[1] != -1 and trade == -1, "SHORT") // EMA Calculations and Plotting ema9 = ta.ema(close,
ema9_length) ema200 = ta.ema(close, ema200_length) ema1000 = ta.ema(close, ema1000_length) plot(ema9, "EMA 9", color=color.rgb(33,
243, 226, 22), linewidth=1) plot(ema200, "EMA 200", color=color.blue, linewidth=2) plot(ema1000, "EMA 1000", color=color.purple,
linewidth=2) // KRO Overlay Calculations [UpC, DnC] = switch ColMode "Classic" => [#00E676, #880E4F] "Modern" => [#5ffae0, #c22ed0]
"Robust" => [#ffbb00, #770737] "Accented" => [#9618f7, #ff0078] "Monochrome" => [#dee2e6, #495057] [UpCol, DnCol] = switch man false =>
[UpC, DnC] true => [manUpC, manDnC] rescale(src) => src * (1 / syminfo.mintick) descale(src) => src / (1 / syminfo.mintick) kro_source :=
rescale(kro_source) Wave = descale(DynamicFunc.waveCalculation(kro_source, bandwidth, width)) Ep =
descale(DynamicFunc.kernelRegression(kro_source, bandwidth, 'Epanechnikov')) Lo = descale(DynamicFunc.kernelRegression(kro_source,
bandwidth, 'Logistic')) Wa = descale(DynamicFunc.kernelRegression(kro_source, bandwidth, 'Wave')) AV = math.avg(Ep, Lo, Wa) + close Mid =
DynamicMA.SMA(AV, sdLook) arrUp = Wave > Wave[1] and not (Wave[1] > Wave[2]) arrDn = Wave < Wave[1] and not (Wave[1] < Wave[2]) [_, u1,
l1] = DynamicFunc.stdv_bands(AV, sdLook, sdMult / 2) [_, u2, l2] = DynamicFunc.stdv_bands(AV, sdLook, sdMult) var all = sig ? display.all :
display.none pu1 = plot(u1, "1. +", color.new(DnCol, 70)) pl1 = plot(l1, "1. -", color.new(UpCol, 70)) pu2 = plot(u2, "2. +", color.new(DnCol,
70)) pl2 = plot(l2, "2. -", color.new(UpCol, 70)) mid = plot(Mid, "Mid", color.gray, 2) wave = plot(Wave, " BCol
", ? na : Wave > Wave[1] ?
UpCol : DnCol, 3) fill(pu1, pu2, u2, u1, devS and not na(u1) and not na(u2) ? color.new(DnCol, 60) : na, color.new(chart.bg_color, 55)) fill(pl1, pl2,
l2, l1, devS and not na(l1) and not na(l2) ? color.new(UpCol, 60) : na, color.new(chart.bg_color, 55)) fill(wave, wave, Wave, Wave, BCol and not
na(Wave) ? color.new(Wave > Wave[1] ? UpCol : DnCol, 50) : na, color.new(chart.bg_color, 75)) plotshape(arrUp, "Trend", shape.arrowup,
location.belowbar, UpCol, 0, "Up", UpCol, size = size.auto, display = all) plotshape(arrDn, "Trend", shape.arrowdown, location.abovebar, DnCol, 0,
"Down", DnCol, size = size.auto, display = all) bgcolor(OBOS ? (AV > u2 ? color.new(DnCol, TR) : AV < l2 ? color.new(UpCol, TR) : na) : na)
barcolor(BCol ? Wave > Wave[1] ? UpCol : DnCol : na) symbol = "KRO Overlay [QuantraAI] >>> {{exchange}}:{{ticker}}" alertcondition(arrUp or
arrDn, "Major Trend Shift", symbol + " Trend Shift!") alertcondition(AV < l2 or AV > u2, "OB/OS", symbol + " Extreme - OB/OS Zone!") 2nd
indicator: // This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://
creativecommons.org/licenses/by-nc-sa/4.0/ // © Zeiierman //@version=5 indicator("Volume Orderbook
(Expo)",overlay=true,max_boxes_count=500,max_lines_count=500) //~~} // ~~ Inputs { src = input.source(close,"Source") rows =
input.int(10,"Rows",0,20,inline="rows") mult = input.float(.5,"Width",.1,2,step=.05,inline="rows") poc = input.bool(false,"POC",inline="rows") tbl =
input.bool(false,"Table",inline="table") left = input.int(5,"Left",0,50,5,inline="table") tbli = input.bool(false,"Grid",inline="table") //
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~} // ~~ Variables & Array's { b = bar_index var step = 0.0 type Table array boxes array lines array lab var levels =
array.new() var volumes = array.new() var vols = array.new(rows*2+1) var tab =
Table.new(array.new(rows*2+2),array.new(rows*2+1),array.new(rows*2+1)) //
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~} // ~~ Code { //Save first candle size if barstate.isfirst step := (high-low)*mult //Stores each candle volume in
levels if levels.size()<=0 levels.push(src+step) levels.push(src-step) volumes.push(volume) else found = false for i=0 to levels.size()-2 lvl1 =
levels.get(i) lvl2 = levels.get(i+1) if srclvl2 volumes.set(i,volumes.get(i)+volume) found := true break if not found if src>levels.get(0) lvl =
levels.get(0) while src>lvl levels.unshift(lvl+step) volumes.unshift(0) lvl := lvl+step levels.unshift(lvl+step) volumes.unshift(volume) else if
srclevels.get(i+1) for x=0 to (rows*2) vols.set(x,volumes.get(math.max(0,i-rows+x))) vol = vols.copy() vols.sort() for x=0 to (rows*2)
tab.boxes.get(x).delete() col = xrows?color.lime:color.gray colgrade =
color.from_gradient(vols.indexof(vol.get(x)),0,vols.size(),color.new(col,80),color.new(col,40)) tab.boxes.set(x,box.new((b+left+rows*2)-
vols.indexof(vol.get(x)),levels.get(math.max(0,i-rows+x)), (b+left+rows*2)+vols.indexof(vol.get(x)),levels.get(math.max(1,i-rows+x+1)),
colgrade,bgcolor=colgrade,border_style=line.style_dotted, text=str.tostring(vol.get(x),format.volume),text_color=chart.fg_color, extend=poc and
vols.indexof(vol.get(x))==rows*2?extend.left:extend.none)) if tbli tab.lines.get(x).delete() tab.lines.set(x,line.new(b+left,levels.get(i-rows+x),b
+left+rows*2+vols.size()-1,levels.get(i-rows+x), color=color.gray)) if tbl tab.boxes.get(rows*2+1).delete() tab.boxes.set(rows*2+1,box.new(b
+left,box.get_top(tab.boxes.get(0)), b+left+rows*2+vols.size()-1,box.get_bottom(tab.boxes.get(rows*2)),
color.gray,border_width=2,bgcolor=color(na))) break //
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~}

You might also like