Explainers / CM Stochastic Multi-TimeFrame by ChrisMo
CM Stochastic Multi-TimeFrame by ChrisMoody, explained from the source
CM Stochastic Multi-TimeFrame is an open-source TradingView indicator by ChrisMoody, written in October 2014, with about 23,000 boosts. It draws a stochastic, prints "B" and "S" letters on some crosses, and can take its values from another timeframe. This page walks through the published code in order, says what each part really does, and ends with where it fails. It does not say whether the indicator makes money, and it gives no trades.
The surprise: the timeframe option is real, and that is where live and history part ways
Some older multi-timeframe scripts only fetch a price from the other timeframe and do the maths on chart bars. This one does not. The whole stochastic is worked out on the timeframe you pick, so a 60-minute setting gives a true 60-minute stochastic.
The catch is in the letters. The cross test compares each chart bar with the chart bar before it. While a higher-timeframe bar is still forming, its stochastic moves with every chart bar, and a letter can print on any of them. In our Python port, with a higher timeframe of five chart bars, the live chart printed 7,144 letters. The same data loaded as history showed 4,052.
Step 1: the stochastic
Length 14, K smoothed over 3, D a 3-bar average of K. Lines at 80 and 20. "Use Current Chart Resolution" is ticked by default, so out of the box nothing comes from another timeframe.
Step 2: the strict letters (on by default)
"B": on the previous bar K was below D and below 20, and on this bar K is above D. "S" is the mirror at 80. The 20 test is on the previous bar only. K does not have to be under 20 on the bar that gets the letter, and D's level is not tested. In our port 2,521 of 10,732 "B" letters (23%) printed with K already above 20.
Step 3: the any-cross letters (off by default)
The same letters on every cross of K and D, at any level.
Step 4: the second stochastic
A second stochastic, daily by default, can be drawn in orange and yellow. It is for display. No letter or highlight uses it. Its lines are hidden on any bar where the value is exactly zero.
Step 5: there are no alerts in the code
The letters are drawn on the pane. Nothing in the code can raise a TradingView alert.
What we checked in Python
We ported the logic to Python and ran it on invented random-walk prices with a typical move of 1% a bar, each bar built from 10 smaller steps: 40 runs of 5,000 bars, the first 300 of each run left out.
Letters on random prices. At the defaults, a median of 529 strict letters per 4,700 bars, about one bar in nine. With any-cross on, 1,164. These prices have nothing to find.
The live bar flickers. For every 10 strict letters that held at the close, about 4 more showed inside a bar and were gone by its close (8,072 against 21,108).
Live against reloaded, with another timeframe. The code has no version line, which makes it the oldest kind of Pine. TradingView's documentation says scripts from before version 3 show another timeframe's value on past bars as it stood at the end of that bar. If so, a reloaded chart puts each letter on the first chart bar of the higher bar, before that bar had closed, and drops the letters that came and went while it formed. That is the 7,144 against 4,052 above. We read this from the documentation and the code; we did not watch it on a live chart.
These figures describe the code on invented data, not any market.
Where it fails
- Live and history disagree on another timeframe. Our port printed about 1.8 letters live for every 1 that a reload would show.
- Past letters may sit earlier than they could have been seen.
- The 20 and 80 test is one bar late. About one "B" in four printed with K already back above 20.
- Letters are frequent. About one bar in nine on random prices at the defaults.
- The live bar can show a letter that disappears. About 4 for every 10 that held.
- The second stochastic changes nothing. It is drawn and never tested.
- No alerts.
- Old code. Written for the first version of Pine.
Two scripts where the timeframe option is not a true higher-timeframe value: Moving Average Cross Alert MTF by ChartArt and Ultimate Moving Average MTF by ChrisMoody.
Educational only. Not financial advice. Nothing here is a recommendation to buy or sell anything. CM Stochastic Multi-TimeFrame is by ChrisMoody on TradingView; this page describes its published open-source code in our own words and is not affiliated with the author. Simulation figures come from synthetic random-walk prices and say nothing about how the script behaves on any market.
Also explained: Repaint checker, VWAP, Supertrend, RSI, UT Bot Alerts, Nadaraya-Watson Envelope, Squeeze Momentum, What is repainting on TradingView?, Is TradingView backtesting accurate?, Chandelier Exit, WaveTrend Oscillator, QQE MOD, Pivot highs and lows, Hull Suite, Range Filter, Twin Range Filter, HalfTrend, ZigZag++, SSL Hybrid, CM MacD Ultimate MTF, Volume Profile / Fixed Range, ADX and DI, Support Resistance Channels, Market Structure Break & Order Block, Order Block Finder, Pivot Point SuperTrend, Trendlines with Breaks [LuxAlgo], Divergence for Many Indicators, TradingView script selling terms, Support and Resistance Levels with Break, Liquidity Swings [LuxAlgo], Pine Script errors, Breakout Probability (Expo), Did ChatGPT or Claude write your Pine Sc, Lorentzian Classification, SuperTrend AI (Clustering), Machine Learning Adaptive SuperTrend, Dynamic Swing Anchored VWAP, Support and Resistance Power Channel by , Support and Resistance (High Volume Boxe, Trendline Breakouts With Targets by Char, Breakout Finder by LonesomeTheBlue, Volume Flow Indicator by LazyBear, FVG Order Blocks by BigBeluga, CM_Williams_Vix_Fix by ChrisMoody, Bollinger + RSI Double Strategy by Chart, Ultimate Moving Average MTF by ChrisMood, Fibonacci Bollinger Bands by Rashad, Candlestick Patterns Identified by repo3, MACD + SMA 200 Strategy by ChartArt, Pine Script v5 to v6, Moving Average Cross Alert, Multi-Timefr, WaveTrend Oscillator [WT] by LazyBear, WaveTrend with Crosses [LazyBear], CM_Price-Action-Bars by ChrisMoody, RSI Candles by glaz, CM RSI-2 Strategy Lower Indicator by Chr, CM_Ultimate RSI Multi Time Frame by Chri, TonyUX EMA Scalper - Buy / Sell by tux, MACD 4C by vkno422, My Pine Script is valid. What did the va
Get the next teardown by email
One short email when a new teardown or free tool goes live, about twice a month. No signals, no hype. Unsubscribe in one click.
Almost done. Check your inbox and click the confirmation link.
Sent with Kit. Your address is used only for these emails. Privacy
No TradingView account yet? This affiliate link gives you a $15 coupon toward a paid plan, and we earn a commission if you buy one. The free plan is enough to follow this page.