NCJE Mesa Stochastic Description
NCJE Mesa Stochastic is John Ehlers' MESA Stochastic indicator for NinjaTrader 8, and it comes with the full C# source code. A normal stochastic reads raw price, so a strong trend pins it to the top or bottom while short noise makes it twitch. Ehlers' fix is to filter price first and run the stochastic on what's left. I like the idea a lot, but know the flip side: with the trend filtered out, it keeps swinging even while a strong trend runs.
How it works. First, a roofing filter cleans the price. A two-pole high-pass filter with a 48-bar period removes the slow trend, and John Ehlers' Super Smoother, a two-pole filter that removes short-term noise, takes out what's faster than about 10 bars. What's left are swings between roughly 10 and 48 bars. Then comes the stochastic: where the filtered value sits between its highest and lowest of the last Period bars (10 by default), from 0 at the low to 1 at the high. If that range is flat, the previous value is kept. Finally, another 10-bar Super Smoother calms the result, and it is scaled to 0 to 100.
What you see. One orange-red line in its own panel, with two level lines at 80 and 20. A single Threshold input (20 by default, from 0 to 50) sets both: the bottom line at the Threshold and the top line at 100 minus it, so the zones stay symmetric. The three filter lengths, 48, 10 and 10, are fixed in the code. It calculates on bar close.
How to use it. Treat readings above the top line as overbought and below the bottom line as oversold, and watch for the line to turn back out of a zone. Because trends longer than about 48 bars are filtered out, it shows cycles, not trend direction, so pair it with a trend filter if you only trade with the trend. A longer Period compares against a wider range, so extremes come less often; a shorter one reaches them more easily. The value is exposed as MesaStoch, so a strategy can read it directly.
Make it yours. Use it as is, learn from the code, or change it yourself or with AI like Claude. Good first changes: turn the three fixed filter lengths into inputs, add arrows and an API signal when the line leaves a zone, or add an alert. The indicator is built from separate filter indicators, a high-pass filter, the Super Smoother and a roofing filter that combines them, and you get their source too, so you can reuse them in your own tools. Have some good trades!