Gaussian Maximum‑Entropy Preserver For ThinkOrSwim

Adeodatus

Active member
Plus
mod note:
The script takes raw price movement, removes trend and scale, converts it into a standardized Gaussian signal, and then smooths it without destroying its statistical shape.

What traders get is a clean, stable z‑score oscillator that behaves consistently across symbols, volatility regimes, and timeframes.
2026-02-26-TOS_CHARTSA.png

How to use it in practice
1. Identify statistical extremes
Values far above or below zero indicate standard‑deviation outliers.​
Because the core is Gaussian‑preserving, these extremes are meaningful and comparable across markets.​
+2 to +3 → statistically stretched upward​
–2 to –3 → statistically stretched downward​
These are not trade signals by themselves, but context flags for exhaustion or mean‑reversion setups.

2. Track reversion toward the mean
When the oscillator rolls over from a high positive value or curls upward from a deep negative value, it often marks reversion phases.​
This is especially useful for:​
range‑bound markets​
fading extended moves​
timing exits on parabolic pushes​

3. Confirm trend exhaustion
If price is making new highs but the Gaussian core is making lower highs, the standardized momentum is weakening.​
Because the signal is normalized, this divergence is more reliable than raw‑price oscillators.​

4. Use the zero line as a regime boundary
Crossing above zero indicates price has moved above its rolling mean.​
Crossing below zero indicates price has moved below its rolling mean.​

This is not a trend indicator, but it helps define:
bullish vs. bearish statistical regimes​
early shifts in balance of pressure​
confirmation for other signals (VWAP stretch, DSMA drift, etc.)​

Why this indicator matters
Most oscillators distort the underlying distribution.​
This one preserves maximum entropy, meaning:​
no nonlinear compression​
no artificial clipping​
no skewing of tails​
no distortion of variance​

You get a clean, mathematically honest representation of price deviation, which is rare in retail indicators.

Code:
# =========================================
# Gaussian Maximum Entropy Preserver
# ver 04/AdeodatusTravelLink Series 2/2026
# =========================================

declare lower;

input length = 50;
input smoothLength = 10;

# --- Mean removal (center process)
def meanValue = Average(close, length);
def centeredValue = close - meanValue;

# --- Variance calculation
def varianceValue = Average(Sqr(centeredValue), length);
def stDevValue = Sqrt(varianceValue);

# --- Safe denominator (prevents divide-by-zero)
def stDevSafe = Max(stDevValue, 0.000001);

# --- Standardized Gaussian core
def zCore = centeredValue / stDevSafe;

# --- Linear smoothing (EMA is linear → preserves Gaussianity)
def smoothCore = ExpAverage(zCore, smoothLength);

# --- Plots
plot GaussianCore = smoothCore;
GaussianCore.SetDefaultColor(Color.CYAN);
GaussianCore.SetLineWeight(2);

plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.GRAY);
ZeroLine.SetLineWeight(1);
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

"a clean, mathematically honest representation of price deviation, which is rare in retail indicators,
one":) meant to "preserve maximum entropy, meaning:
2026-02-26-TOS_CHARTSB.png
no nonlinear compression, no artificial clipping, no skewing of tails, no distortion of variance"
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
1363 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top