Pseudo-Entropy Oscillator with Standard Deviation (modified)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jawauntb

//@version=5
indicator(title="Pseudo-Entropy Oscillator with Standard Deviation", shorttitle="PEO_SD", overlay=false)

entropyPeriod = input(3, title="Entropy Period")
entropyMomentum = input(9, title="Entropy Momentum Length")
entropyMALength = input(3, title="Entropy MA Length")
fastPeriod = input(13, title="Fast Period")
slowPeriod = input(33, title="Slow Period")

// Calculate pseudo-entropy using standard deviation
pseudoEntropy = ta.stdev(close, entropyPeriod)
entropyDelta = ta.mom(pseudoEntropy, entropyMomentum)
entropySMA = ta.sma(pseudoEntropy, entropyMALength)

// Combine the pseudo entropy delta and SMA similar to RSI code
pseudoEntropyCombined = entropyDelta + entropySMA

// Calculate fast, medium and slow SMAs of combined pseudo-entropy
fastSMA = ta.sma(pseudoEntropyCombined, fastPeriod)
mediumSMA = ta.sma(pseudoEntropyCombined, entropyPeriod)
slowSMA = ta.sma(pseudoEntropyCombined, slowPeriod)

// Normalize the values to an unbounded oscillator using Z-score normalization
fastSMA_norm = 50 + ((fastSMA - ta.sma(fastSMA, fastPeriod)) / ta.stdev(fastSMA, fastPeriod)) * 10
mediumSMA_norm = 50 + ((mediumSMA - ta.sma(mediumSMA, entropyPeriod)) / ta.stdev(mediumSMA, entropyPeriod)) * 10
slowSMA_norm = 50 + ((slowSMA - ta.sma(slowSMA, slowPeriod)) / ta.stdev(slowSMA, slowPeriod)) * 10

// Plot pseudo-entropy oscillator
plot(fastSMA_norm, title="Fast Pseudo-Entropy", color=color.rgb(62, 159, 255))
plot(mediumSMA_norm, title="Medium Pseudo-Entropy", color=color.rgb(255, 255, 0))
plot(slowSMA_norm, title="Slow Pseudo-Entropy", color=color.rgb(243, 33, 68))
hline(50, title="Mid Line", color=color.gray)
hline(20, title="Lower Bound", color=color.gray)
hline(80, title="Upper Bound", color=color.gray)
