OPEN-SOURCE SCRIPT
Buy Sell Badge with DMI by Bybllo

Buy Sell Badge with DMI by Bybllo
At its core, this indicator combines two independent Buy/Sell signal sources into one badge system: (1) a basic Fast/Slow EMA crossover ("BSB"), and (2) a DMI-based signal built from the golden cross (DI+ crossing above DI-) and dead cross (DI- crossing above DI+) of the Directional Movement Index, filtered by a minimum ADX threshold.
The EMA crossover generates the base Buy/Sell signal, then automatically manages an ATR-based stop loss and a risk:reward-based take profit for each signal, showing the resulting entry/stop/target levels directly on the chart along with a live status table. The DMI golden-cross / dead-cross engine can be enabled as a confirmation filter on top of that: when turned on, a badge is only shown if a matching DMI cross (with ADX above a configurable threshold) occurs within a set number of bars of the EMA signal. In practice, this acts as a noise-reduction filter — choppy, low-conviction EMA crossovers with no matching directional strength behind them are suppressed, so only badges backed by both a trend-following signal and a directional-strength signal are actually displayed.
Key Features
Fast/Slow EMA crossover generates the base Buy/Sell signal, with an optional candle-confirmation requirement (close beyond open in the signal direction).
Automatic ATR-based stop loss and configurable Risk:Reward take profit are calculated for every new signal, with intermediate take-profit levels plotted when Risk:Reward is greater than 1.
Optional "BSB + DMI" confirmation filter: a badge is only shown when a DMI golden cross or dead cross, confirmed by ADX above your threshold, occurs within a configurable bar window of the EMA signal, in either order. This suppresses noisy, low-conviction EMA crossovers and leaves only the badges that are backed by both signals.
On-chart entry / stop-loss / take-profit lines and an SL distance (in points) label, both toggleable and only shown while a badge has actually been displayed for the active position.
Take-profit, stop-loss, and "invalidated" (opposite signal fired before target/stop was hit) markers are plotted separately so you can see exactly how each trade idea played out.
A live status table (top-right) shows the current position, entry, stop loss, take profit, and realized Risk:Reward.
Real-price calculation via request.security() keeps signals consistent regardless of chart type (Heikin Ashi, Renko, etc.).
A full set of alertcondition() calls for BSB-only signals, BSB+DMI confirmed signals, take-profit hits, stop-loss hits, and invalidated entries.
How to Use
Leave "BSB + DMI" unchecked to use the EMA crossover badges on their own (fastest signals, no directional-strength filter).
Check "BSB + DMI" to require that a DMI golden cross (for Buy) or dead cross (for Sell), confirmed by ADX, also occurs near the EMA signal — this filters out noise and typically reduces the number of badges, but favors signals that also have directional strength behind them.
Watch the on-chart entry/SL/TP lines and the status table to track an open idea's risk and progress in real time.
Set up alerts on the "BSB+DMI Buy/Sell", "Buy/Sell Signal", "Take Profit Hit", "Stop Loss Hit", or "Entry Invalidated" conditions depending on which events you want to be notified about.
Notes
The "EMA Badge Spacing" and "DMI Badge Spacing" inputs each apply their own cooldown to prevent duplicate signals firing on consecutive bars; keep the DMI spacing aligned with the badge spacing you use on other DMI-based indicators if you compare them side by side.
Stop-loss and alert-sensitivity offsets are point-based and will need adjusting per instrument (see the tooltips on those inputs).
This indicator does not place real orders; it is a visual / alerting tool for tracking a rules-based EMA + DMI golden-cross/dead-cross trade idea.
At its core, this indicator combines two independent Buy/Sell signal sources into one badge system: (1) a basic Fast/Slow EMA crossover ("BSB"), and (2) a DMI-based signal built from the golden cross (DI+ crossing above DI-) and dead cross (DI- crossing above DI+) of the Directional Movement Index, filtered by a minimum ADX threshold.
The EMA crossover generates the base Buy/Sell signal, then automatically manages an ATR-based stop loss and a risk:reward-based take profit for each signal, showing the resulting entry/stop/target levels directly on the chart along with a live status table. The DMI golden-cross / dead-cross engine can be enabled as a confirmation filter on top of that: when turned on, a badge is only shown if a matching DMI cross (with ADX above a configurable threshold) occurs within a set number of bars of the EMA signal. In practice, this acts as a noise-reduction filter — choppy, low-conviction EMA crossovers with no matching directional strength behind them are suppressed, so only badges backed by both a trend-following signal and a directional-strength signal are actually displayed.
Key Features
Fast/Slow EMA crossover generates the base Buy/Sell signal, with an optional candle-confirmation requirement (close beyond open in the signal direction).
Automatic ATR-based stop loss and configurable Risk:Reward take profit are calculated for every new signal, with intermediate take-profit levels plotted when Risk:Reward is greater than 1.
Optional "BSB + DMI" confirmation filter: a badge is only shown when a DMI golden cross or dead cross, confirmed by ADX above your threshold, occurs within a configurable bar window of the EMA signal, in either order. This suppresses noisy, low-conviction EMA crossovers and leaves only the badges that are backed by both signals.
On-chart entry / stop-loss / take-profit lines and an SL distance (in points) label, both toggleable and only shown while a badge has actually been displayed for the active position.
Take-profit, stop-loss, and "invalidated" (opposite signal fired before target/stop was hit) markers are plotted separately so you can see exactly how each trade idea played out.
A live status table (top-right) shows the current position, entry, stop loss, take profit, and realized Risk:Reward.
Real-price calculation via request.security() keeps signals consistent regardless of chart type (Heikin Ashi, Renko, etc.).
A full set of alertcondition() calls for BSB-only signals, BSB+DMI confirmed signals, take-profit hits, stop-loss hits, and invalidated entries.
How to Use
Leave "BSB + DMI" unchecked to use the EMA crossover badges on their own (fastest signals, no directional-strength filter).
Check "BSB + DMI" to require that a DMI golden cross (for Buy) or dead cross (for Sell), confirmed by ADX, also occurs near the EMA signal — this filters out noise and typically reduces the number of badges, but favors signals that also have directional strength behind them.
Watch the on-chart entry/SL/TP lines and the status table to track an open idea's risk and progress in real time.
Set up alerts on the "BSB+DMI Buy/Sell", "Buy/Sell Signal", "Take Profit Hit", "Stop Loss Hit", or "Entry Invalidated" conditions depending on which events you want to be notified about.
Notes
The "EMA Badge Spacing" and "DMI Badge Spacing" inputs each apply their own cooldown to prevent duplicate signals firing on consecutive bars; keep the DMI spacing aligned with the badge spacing you use on other DMI-based indicators if you compare them side by side.
Stop-loss and alert-sensitivity offsets are point-based and will need adjusting per instrument (see the tooltips on those inputs).
This indicator does not place real orders; it is a visual / alerting tool for tracking a rules-based EMA + DMI golden-cross/dead-cross trade idea.
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.