highPivotLen = input.int(21, "High Pivot Length", minval = 1, group = "Pivots", display = display.none) lowPivotLen = input.int(21, "Low Pivot Length", minval = 1, group = "Pivots", display = display.none) realPivotLabels = DEBUG ? input.bool(false, "[DBG] Real Pivot Labels", group = "Pivots") : false kdePivotLabels = DEBUG ? input.bool(false, "[DBG] KDE Pivot Labels", group = "Pivots") : false
activationThresholdStr = input.string("Medium", "Activation Threshold", options = ["High", "Medium", "Low"], group = "KDE", tooltip = "Determines the amount of arrows shown. Higher options will result in more arrows being rendered.") string KDEKernel = input.string("Gaussian", "Kernel", options=['Uniform', 'Gaussian', 'Sigmoid'], group = "KDE", tooltip = "The kernel function for KDE calculation. Gaussian is a commonly used kernel and is based on normal distribution.") float KDEBandwidth = input.float(2.71828, "Bandwidth", group = "KDE", tooltip = "This setting sets the smoothness of the KDE function output.") int KDEStep = input.int(100, "Nº Bins", minval = 1, group = "KDE", tooltip = "The number of elements the KDE Probability array will have. Higher settings will result in greater precision.") activationThreshold = DEBUG ? input.float(0.25, "[DBG] Activation Threshold", group = "KDE") : 0.25 if not DEBUG activationThreshold := (activationThresholdStr == "High" ? 0.4 : activationThresholdStr == "Medium" ? 0.25 : 0.15) probMode = DEBUG ? input.string("Sum", '[DBG] Probability Mode', options = ["Sum", "Nearest"], group = "KDE") : "Sum" minPadding = DEBUG ? input.bool(false, '[DBG] KDE Min Padding', group = "KDE") : false
if DEBUG and barstate.islastconfirmedhistory for i = 0 to KDELowX.size() - 1 curX = KDELowX.get(i) curY = KDELowY.get(i) log.info(str.tostring(curX) + " = " + str.tostring(curY)) log.info("High Y Sum " + str.tostring(KDEHighY.sum()))
alertcondition(na(curColor) and curColor[1] == bullishColor and barstate.isconfirmed, "Possible Bullish Pivot") alertcondition(na(curColor) and curColor[1] == bearishColor and barstate.isconfirmed, "Possible Bearish Pivot")
if KDELabelsEnabled or RSILabelsEnabled var lastBullishLabel = 0 if (na(curColor) and curColor[1] == bullishColor and barstate.isconfirmed) and (bar_index - lastBullishLabel) > labelCooldown lastBullishLabel := bar_index txt = "" if RSILabelsEnabled and KDELabelsEnabled txt := "RSI | " + str.tostring(rsi, "#") + " | " + str.tostring(lowProb * 100, "#.##") + "%" else if RSILabelsEnabled txt := "RSI | " + str.tostring(rsi, "#") else txt := str.tostring(rsi, "#") + "%" label.new(bar_index, low, txt, yloc = yloc.belowbar, color = na, style = label.style_label_up, textcolor = textColor, force_overlay = true)
var lastBearishLabel = 0 if (na(curColor) and curColor[1] == bearishColor and barstate.isconfirmed) and (bar_index - lastBearishLabel) > labelCooldown lastBearishLabel := bar_index txt = "" if RSILabelsEnabled and KDELabelsEnabled txt := "RSI | " + str.tostring(rsi, "#") + " | " + str.tostring(highProb * 100, "#.##") + "%" else if RSILabelsEnabled txt := "RSI | " + str.tostring(rsi, "#") else txt := str.tostring(rsi, "#") + "%" label.new(bar_index, low, txt, yloc = yloc.abovebar, color = na, style = label.style_label_down, textcolor = textColor, force_overlay = true)