Leavitt Convolution Slope [CC]
"Leavitt Convolution Slope [CC]" by cheatcountry, MIT. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: Leavitt Convolution Slope [CC] (v1.0), read 2026-10-12T15:44:18.492Z; source language v5.
Licence: MIT License (MIT) — full text.
Leavitt Convolution Slope [CC] by cheatcountry, ported from Pine v5. Pane indicator with 3 plots, 1 level, alerts and 8 inputs.
// Copyright (c) 2019-present, Franklin Moormann (cheatcountry)
// Leavitt Convolution Slope [CC] script may be freely distributed under the MIT license.
// ------------------------------------------------------------------------------------------------
// Original author: cheatcountry
// Original title: Leavitt Convolution Slope [CC]
// Licence: MIT (the header above is the original notice, kept verbatim)
// Pine version: 5
// Fetched: 2026-10-12
// Ported to FloScript by FloSignals; modifications under MPL-2.0.
// Converter: @flosignals/floscript 0.1.0, strict mode, score 100/100
// ------------------------------------------------------------------------------------------------
//@floscript=1
//@version=5
indicator("Leavitt Convolution Slope [CC]")
float inp = input.source(title="Source", defval=hlcc4)
string res = input.timeframe(title="Resolution", defval="")
bool rep = input.bool(title="Allow Repainting?", defval=false)
bool bar = input.bool(title="Allow Bar Color Change?", defval=false)
bool useNormHyperbolic = input.bool(title="Use it Hyyperbolic Normalization?", defval=true)
float src = inp[rep ? 0 : barstate.isrealtime ? 1 : 0][rep ? 0 : barstate.isrealtime ? 0 : 1]
int length = input.int(title="Length", defval=70, minval=1)
int normLength = input.int(title="Normalization Length", defval=150, minval=1)
float unsure = input.float(title="Unsure", defval=0.2, minval=0.01)
softMax(float src, int length, bool useNormHyperbolic) =>
float mean = ta.sma(src, length)
float dev = ta.stdev(src, length)
float zmean = dev != 0 ? (src - mean) / dev : 0
float val = useNormHyperbolic ? (1.0 - math.exp(-zmean)) / (1.0 + math.exp(-zmean)) : 1.0 / (1.0 + math.exp(-zmean))
leavittProjection(float src, int length) =>
float result = ta.linreg(src, length, -1)
leavittConvolutionSlope(float src, int length) =>
int sqrtLength = math.floor(nz(math.sqrt(length)))
float currLinReg = ta.linreg(leavittProjection(src, length), sqrtLength, 0)
float prevLinReg = ta.linreg(leavittProjection(src, length), sqrtLength, 1)
float result = currLinReg - prevLinReg
float convSlope = leavittConvolutionSlope(src, length)
float maxConvSlope = ta.max(convSlope)
float minConvSlope = ta.min(convSlope)
float scaledConvSlope = softMax(convSlope, normLength, useNormHyperbolic)
float slo = useNormHyperbolic ? scaledConvSlope - 0 : scaledConvSlope - nz(scaledConvSlope[1])
int sig = slo > 0 ? (slo > nz(slo[1]) ? 2 : 1) : slo < 0 ? (slo < nz(slo[1]) ? -2 : -1) : 0
alertcondition(ta.crossover(sig, 1), "Strong Buy Signal", "Strong Bullish Change Detected")
alertcondition(ta.crossunder(sig, -1), "Strong Sell Signal", "Strong Bearish Change Detected")
alertcondition(ta.crossover(sig, 0), "Buy Signal", "Bullish Change Detected")
alertcondition(ta.crossunder(sig, 0), "Sell Signal", "Bearish Change Detected")
alertcondition(ta.crossover(sig, 0) or ta.crossover(sig, 1), "All Buy Signals", "Any Bullish Change Detected")
alertcondition(ta.crossunder(sig, 0) or ta.crossunder(sig, -1), "All Sell Signals", "Any Bearish Change Detected")
color lcsColor = sig > 1 ? color.green : sig > 0 ? color.lime : sig < -1 ? color.maroon : sig < 0 ? color.red : color.white
barcolor(bar ? lcsColor : na)
hline(0)
plot(scaledConvSlope, title="ConvSlope", color=lcsColor, style=plot.style_histogram, linewidth=2)
plot(unsure, title="Unsure+", color=chart.fg_color, linewidth=1)
plot(useNormHyperbolic ? -unsure : na, title="Unsure-", color=chart.fg_color, linewidth=1)
This file is under the MIT License; it is a port of the original by cheatcountry, with the original licence header kept and the changes made for FloScript noted in the file.
- v2
Library refresh 2026-10-14
- v1
Library refresh 2026-10-12
Disclaimer. Scripts are written and published by members, or ported by FloSignals from open-source originals, and are their authors' own work and opinion. FloSignals does not review them for correctness and nothing in a script is financial advice or a recommendation to buy or sell anything — read the Risk Disclaimer. Posting here is under the Community Rules; a script that is not the poster's to post can be reported as the Copyright & Takedowns page says.

Comments (0)
No comments yet. Members can leave one.