OPEN-SOURCE SCRIPT
Telah dikemas kini One Time Framing

OTF Trend
One Time Framing is a simple idea from auction market theory (the AMD / Market Profile world) that gets overcomplicated more often than it needs to be.
A market is one time framing up when each bar makes a higher low than the one before it. That's the whole test — the highs aren't part of it. Sellers might still be winning the fight for the high, but as long as they can't push price below the previous bar's low, they're not getting control of the auction. Buyers are setting the floor, one bar at a time, and one timeframe of participant is running the show. One time framing down is the mirror image: each bar makes a lower high, and buyers can't lift price above the previous high.
What the indicator draws
A green triangle below the bar when a new upward run begins, a red triangle above the bar when a new downward run begins. Faded dots mark each bar the run continues. A small × marks the bar where the run ends.
You choose how many consecutive bars are required before it counts. The default is 2 — one higher low is enough to call it. Push it to 3 or 4 and you'll get far fewer signals, but the ones you get will have more behind them. I'd suggest 3 on daily and weekly charts, 2 on intraday.
Inside bars
An inside bar has a higher low and a lower high. On the letter of the definition, it technically qualifies as one time framing in both directions at once. So this indicator treats inside bars as neutral. They don't extend a run and they don't break one — the count simply pauses. Price is coiling, nobody is in control, and the trend picks up where it left off on the next real bar. Inside bars get their own colour so you can see them at a glance.
There's a second job inside bars do here though. Because they represent a genuine pause, a break of an inside bar's range is often the moment the trend actually turns. So when an inside bar prints, the indicator remembers its high and low. If price then breaks out of that range in the opposite direction to the current trend, that counts as a reversal and flips the trend immediately — you don't have to wait for a fresh run to build up from scratch. This tends to get you in a bar or two earlier at turning points.
That pending setup expires if nothing happens within a set number of bars (default 8), so a stale inside bar from thirty bars back can't fire off a signal that has nothing to do with current price action.
What actually triggers a new trend
In priority order, each bar:
No trend running and a fresh run qualifies → new trend, triangle prints
An inside bar range break against the existing trend → reversal, triangle prints
The current run is broken → trend ends, × prints
A trend ending and a new one starting in the other direction are deliberately kept on separate bars. You could argue for collapsing them into one, but I'd rather see the exit clearly than save a bar on the entry.
Settings
Optional bar colouring for up runs, down runs and inside bars, all colours adjustable
Optional moving average with a choice of types (EMA 21 by default) purely for context — it plays no part in the signal logic
Alerts for new bullish and bearish runs, for inside bar reversals specifically, and for a trend ending
The run depth counters are exposed in the Data Window if you want to see how deep the current run is
Things to consider
Set your alerts to Once Per Bar Close. The state of the current bar can change as its high and low extend, so anything read intrabar isn't final.
Also be aware that a large gap can satisfy "higher low" on its own without any real structure behind it. Worth knowing if you're running this over earnings on equities or any asset that gaps over a weekend or overnight.
This isn't a standalone system. One time framing tells you who's in control right now, not whether you should be in the trade. Use it for confirmation and for timing entries within a bias you've already formed elsewhere.
One Time Framing is a simple idea from auction market theory (the AMD / Market Profile world) that gets overcomplicated more often than it needs to be.
A market is one time framing up when each bar makes a higher low than the one before it. That's the whole test — the highs aren't part of it. Sellers might still be winning the fight for the high, but as long as they can't push price below the previous bar's low, they're not getting control of the auction. Buyers are setting the floor, one bar at a time, and one timeframe of participant is running the show. One time framing down is the mirror image: each bar makes a lower high, and buyers can't lift price above the previous high.
What the indicator draws
A green triangle below the bar when a new upward run begins, a red triangle above the bar when a new downward run begins. Faded dots mark each bar the run continues. A small × marks the bar where the run ends.
You choose how many consecutive bars are required before it counts. The default is 2 — one higher low is enough to call it. Push it to 3 or 4 and you'll get far fewer signals, but the ones you get will have more behind them. I'd suggest 3 on daily and weekly charts, 2 on intraday.
Inside bars
An inside bar has a higher low and a lower high. On the letter of the definition, it technically qualifies as one time framing in both directions at once. So this indicator treats inside bars as neutral. They don't extend a run and they don't break one — the count simply pauses. Price is coiling, nobody is in control, and the trend picks up where it left off on the next real bar. Inside bars get their own colour so you can see them at a glance.
There's a second job inside bars do here though. Because they represent a genuine pause, a break of an inside bar's range is often the moment the trend actually turns. So when an inside bar prints, the indicator remembers its high and low. If price then breaks out of that range in the opposite direction to the current trend, that counts as a reversal and flips the trend immediately — you don't have to wait for a fresh run to build up from scratch. This tends to get you in a bar or two earlier at turning points.
That pending setup expires if nothing happens within a set number of bars (default 8), so a stale inside bar from thirty bars back can't fire off a signal that has nothing to do with current price action.
What actually triggers a new trend
In priority order, each bar:
No trend running and a fresh run qualifies → new trend, triangle prints
An inside bar range break against the existing trend → reversal, triangle prints
The current run is broken → trend ends, × prints
A trend ending and a new one starting in the other direction are deliberately kept on separate bars. You could argue for collapsing them into one, but I'd rather see the exit clearly than save a bar on the entry.
Settings
Optional bar colouring for up runs, down runs and inside bars, all colours adjustable
Optional moving average with a choice of types (EMA 21 by default) purely for context — it plays no part in the signal logic
Alerts for new bullish and bearish runs, for inside bar reversals specifically, and for a trend ending
The run depth counters are exposed in the Data Window if you want to see how deep the current run is
Things to consider
Set your alerts to Once Per Bar Close. The state of the current bar can change as its high and low extend, so anything read intrabar isn't final.
Also be aware that a large gap can satisfy "higher low" on its own without any real structure behind it. Worth knowing if you're running this over earnings on equities or any asset that gaps over a weekend or overnight.
This isn't a standalone system. One time framing tells you who's in control right now, not whether you should be in the trade. Use it for confirmation and for timing entries within a bias you've already formed elsewhere.
Nota Keluaran
Fixed an issue with the MSS reversal path that was leading to false trend signal changes.Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.