OPEN-SOURCE SCRIPT

[CT] MoBo Bands

3 125
This script is the TradingView Pine Script version of MoBo Bands, the Momentum Breakout indicator, and the original creator credited in the code is NPR21, who also notes it was based on an original Thinkorswim concept and then modified and converted to Pine Script by NPR21.

At its core, MoBo Bands is a volatility envelope built from a simple moving average and standard deviation, but it’s not meant to be used like a normal Bollinger Band “touch = reversal” tool. It’s designed to identify when price has pushed far enough away from its recent average to qualify as a breakout regime, and then to keep you biased in that regime until a true opposite breakout occurs. The indicator calculates a midline using a simple moving average of your chosen price source over the selected length. It then measures how spread out price has been over that same lookback using standard deviation. From there it builds an upper and lower band by taking the midline and adding or subtracting a user-defined multiple of standard deviation. In this script those multipliers are “Num Dev Up” and “Num Dev Down.” They default to ±0.8, which is tighter than traditional Bollinger settings, meaning the bands are closer to price and the indicator is more willing to declare a breakout state. The “Displace” input simply shifts the plotted bands forward or backward by bars for visual alignment; functionally, the breakout comparisons are being made against the displaced band values, so if you use displacement you are intentionally changing where signals occur in time.

The key concept in MoBo is that it separates “where price is right now” from “what state we are in.” First it assigns a raw status called MoboStatus: if the close is above the upper band it becomes bullish breakout state, if the close is below the lower band it becomes bearish breakout state, and if the close is between the bands it is neutral. If the script stopped there, you’d only see signals on the exact bars that closed outside the bands. Instead, it adds a second layer called BreakStatus, which is a persistent regime variable. BreakStatus changes only when a true breakout happens, and it does not reset to neutral when price returns inside the bands. That is the entire purpose of the “recursion” line: once BreakStatus flips bullish, it stays bullish through the inside-band chop until a bearish breakout flips it the other way, and vice versa. This is why the band colors and the band fill behave the way they do. When BreakStatus is bullish, the bands plot green and the filled area between them is green. When BreakStatus is bearish, the bands plot red and the fill becomes red. If price is simply oscillating inside the bands, BreakStatus stays whatever it last was, which is the whole “stay with the breakout bias” philosophy.

Because of that design, the most straightforward way to trade it is to treat MoBo as a regime/bias indicator first, and an entry tool second. A bullish regime begins when you get a bullish breakout condition, meaning you had a close above the upper band and BreakStatus flips to bullish. In this script that flip is also where the “Break Out” arrow prints. That event is telling you volatility expansion has pushed price into an upside breakout state, so your default expectation becomes continuation or at least holding above the midline with higher odds of higher highs. A common execution approach is to take the breakout as your initial trigger, then use the band structure to manage the trade: if you want a more aggressive style, you enter on the breakout bar close or on the next bar if it confirms. If you want a more conservative style, you wait for the first pullback after the breakout and enter when price holds above the midline or reclaims the upper band area. Your risk can be framed in a few ways depending on instrument and timeframe: the most “indicator-pure” protective logic is that the bullish regime is invalidated only when price later breaks below the lower band and flips BreakStatus bearish. That is a very wide stop concept, but it reflects the indicator’s intent to ride trends. A tighter, more practical stop for active trading is to use the midline or a recent swing low as the risk point while still respecting the MoBo bias; the idea is you are using MoBo to keep you from fading the move, while your stop is based on structure rather than waiting for a full opposite breakout.

A bearish regime is the exact mirror. It begins when a close is below the lower band and BreakStatus flips bearish, which is when the red “Break Down” arrow prints. From that point, you treat rallies into the midline/band area as potential short opportunities as long as the regime remains bearish. More aggressive traders will short the initial breakdown; more conservative traders wait for a bounce that fails back below the midline or for a retest of the lower band zone. Exits can be handled either as “regime exits,” meaning you hold until BreakStatus flips the other way, or as “trade exits,” meaning you scale or exit into targets while staying aligned with the regime until it ends. On trend days, the regime exit can keep you in the move much longer than typical oscillators. On choppy days, a tighter risk plan is needed because a tight band setting can flip more often.

The candle coloring addition you asked for simply mirrors the fill state so you can read the regime without looking at the bands. When the fill is green (BreakStatus bullish), the candles are tinted green; when the fill is red (BreakStatus bearish), the candles are tinted red; when neither fill is active, it leaves the candles unchanged. This doesn’t change the logic or signals, it just makes the “state” visually obvious.

Where traders usually get the most out of MoBo is by using it in the context it was designed for: volatility expansion and trend participation. If you try to trade it like a mean-reversion Bollinger Band system, you’ll often do the opposite of what it’s signaling. Here, a close outside the band is not “overbought/oversold,” it’s the condition that defines a breakout regime. The best trades tend to come when the breakout occurs in alignment with a higher-timeframe trend or after a compression period, because the band break is then capturing a genuine shift in volatility and direction. If you want it to trigger fewer, higher-quality regimes, increase the length and/or increase the deviation multipliers, because that widens the envelope and demands a more significant move to flip state. If you want earlier, more frequent signals, reduce the length and/or reduce the multipliers, understanding you’ll also increase whipsaw risk.

免責聲明

這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。