Inside Candle with EMA +ST +TP/SL@SaheemolInside Candle Breakout with EMA, SuperTrend & Auto TP/SL
This indicator combines the power of the Inside Candle breakout pattern, EMA trend analysis, and SuperTrend confirmation to identify high-probability breakout opportunities while automatically plotting trade management levels.
Key Features
✅ Detects valid Mother-Daughter (Inside Candle) formations using customizable body-size filters.
✅ Plots EMA 9, EMA 21, and EMA 200 to help visualize market trend and structure.
✅ Uses SuperTrend confirmation to filter false breakouts:
Buy signals only when SuperTrend is bullish.
Sell signals only when SuperTrend is bearish.
✅ Automatically identifies breakout levels from the Mother Candle's high and low.
✅ Draws:
Entry zone
Stop Loss (SL)
Take Profit 1 (TP1)
Take Profit 2 (TP2)
using user-configurable Risk ratios.
✅ Highlights Inside Candle setups and displays visual breakout signals directly on the chart.
✅ Includes alert conditions for automated notifications.
How It Works
The indicator searches for a strong Mother Candle followed by a valid Inside Candle.
The Mother Candle's high and low become the breakout levels.
A trade signal is generated only when price breaks out of the Mother Candle range and the SuperTrend agrees with the direction.
TP1, TP2, and SL levels are automatically calculated based on the Mother Candle range.
Best Use Cases
Intraday trading
Swing trading
Breakout strategies
Trend-following systems
Forex, Stocks, Crypto, and Indices
This indicator is designed to help traders quickly identify consolidation breakouts while maintaining disciplined risk management through predefined entry, target, and stop-loss zones.
Disclaimer: This script is for educational and informational purposes only and does not constitute financial advice. Trading involves risk, and users should perform their own analysis and risk management before making any trading decisions. Indicator

Indicator

Turtle Soup Reversal Map [AGPro Series]Turtle Soup Reversal Map
🔹 Overview
Turtle Soup Reversal Map is a mean-reversion pattern detector inspired by Linda Raschke's classic "Turtle Soup" setup — a counter-attack on failed 20-bar breakouts. When price pierces a multi-bar extreme and then closes back inside the prior range, institutional traders often interpret it as trapped breakout participants being flushed. This script automates the detection, qualifies each setup with a transparent 0–100 score, and projects a reference target alongside an auto-resolving rejection zone. It is designed for traders who want a disciplined, rule-based way to spot failed breakouts without drawing them manually.
🔹 Unique Edge
Unlike generic liquidity-sweep or wick-rejection indicators, Turtle Soup Reversal Map is built around Raschke's specific 20-bar-extreme rule — a pattern with decades of documented performance in swing-trading literature. Three characteristics separate it from similar tools:
• Strict N-bar-extreme definition (not a simple swing-high/low fade). Price must violate the exact prior-lookback extreme, not just a minor pivot.
• Five-component adaptive quality score — wick rejection, volume spike, overshoot magnitude, higher-timeframe trend alignment, and key-level proximity. Each component is a transparent weighted contribution, with clear A+ / A / B / C grades.
• Full lifecycle state engine — Pending → Fired → Target/Stop/Invalidated. Setups that do not confirm within their window are auto-invalidated (not left hanging), and live win-rate plus average R-multiple are tracked over the most recent resolved setups.
🔹 Methodology
The script continuously monitors for price piercing the highest high or lowest low of the prior N bars (default 20, range 10–50). When a sweep occurs, a Pending setup is created. Confirmation is then evaluated in one of two user-selectable modes:
• Same-Bar Close — the violating bar must close back inside the prior range on the same bar (faster, more signals).
• Next-Bar Close — Raschke's original specification; the next bar must close back inside the prior range (slower, higher reliability).
If confirmation fires, the setup becomes Fired and a reference target is projected from the confirmation close (default 2.5 × ATR(14)). Stop is placed at the sweep extreme plus a configurable ATR buffer. Setups that fail to confirm within their window, or where price overshoots the stop before confirmation, are automatically invalidated.
The quality score blends: wick-to-range ratio at the extreme bar, relative volume spike versus its 20-bar average, overshoot magnitude (ATR-normalized with a sweet-spot curve), counter-trend alignment against a user-defined higher timeframe, and proximity to round numbers or recent pivot levels.
🔹 Signals & Alerts
The script produces three alert types, all configurable:
• Pending — sweep detected, awaiting confirmation.
• Fired — confirmation closed back inside prior range.
• Invalidated — setup dismissed due to overshoot or window timeout.
Each alert message includes direction (Bull/Bear), current grade, ticker, and timeframe. Fired setups are visualized with a labeled confirmation marker, a dashed target-projection line, a dotted stop-reference line, and an auto-closing rejection zone. Labels display the Soup-Bull / Soup-Bear name, grade, and numeric score.
🔹 Key Inputs
• Lookback Bars — size of the extreme window (default 20, range 10–50).
• Confirmation Mode — Same-Bar Close or Next-Bar Close.
• Invalidation Distance (ATR) — stop buffer beyond the sweep extreme (default 0.5).
• Target Projection (ATR) — reference reversal target distance from entry (default 2.5).
• Quality Score Components — each of the five score components can be toggled independently for custom configurations.
• HTF for Trend — higher timeframe used for the trend-alignment component (default 240 min).
• Stats Sample Size — rolling window of resolved setups used for win-rate and average reward metrics (default 30).
• Visual & Panel Options — zones, lines, labels, target projection, panel location, font sizes, and per-element toggles.
🔹 How to Use
1. Apply to any liquid instrument and timeframe. The pattern's rule set is symbol-agnostic but performs differently across assets — review the live Win Rate and Avg Reward metrics in the panel to calibrate expectations.
2. Watch the Status field in the panel. Idle means no active setup; Pending Bull/Bear means a sweep has occurred and the script is waiting for confirmation; Fired Bull/Bear means confirmation closed and a target has been projected.
3. Filter setups by grade. A+ and A setups have stronger confluence — particularly wick rejection, volume, and HTF alignment. B setups are acceptable under favorable market regimes; C grades are educational only.
4. Treat the target projection as a reference, not a trade instruction. The stop reference line marks where the structural invalidation lies. Always combine with your own risk management.
5. The historical Win Rate is computed over the last N resolved setups on the current chart; it reflects the pattern's fit with the current symbol and timeframe, not a guarantee.
🔹 Limitations & Transparency
This indicator identifies historical setups algorithmically. It does not predict future price movement, and no indicator does. Turtle Soup is a counter-trend mean-reversion pattern — in strong trending regimes, false signals increase; in consolidation and range-bound conditions, it performs best. The displayed Win Rate and Avg Reward are historical, rolling, chart-dependent, and should not be interpreted as future expectations. Target and stop references are geometric projections based on ATR, not optimized parameters.
🔹 Risk Disclosure
This script is a technical analysis tool for educational and research purposes. It is not a trading strategy, not a recommendation, and not financial advice. Past performance does not guarantee future results. Always conduct your own analysis and use proper risk management. Trade at your own risk. Indicator

AG Pro Inside Bar Breakout Quality [AGPro Series]AG Pro Inside Bar Breakout Quality
Overview / What it does
AG Pro Inside Bar Breakout Quality is an overlay tool built to study one of the market’s most familiar compression structures: the inside bar. Instead of stopping at simple detection, the script evaluates what happens after the pattern forms and grades the breakout attempt with a structured quality model. The result is a workflow-oriented view of inside bar compression, breakout strength, and failed continuation behavior.
The script first identifies a strict inside bar condition, where the current bar remains fully contained within the previous bar’s range. That parent range becomes the active reference zone. From there, the script monitors whether price resolves above or below the structure, whether the move is confirmed by close, whether volume supports the breakout, and whether the breakout later fails and re-enters the range within a user-defined window.
This is not designed as a generic “any breakout” marker. Its purpose is narrower and more specific: it focuses on a compact volatility contraction event, then measures how decisively price leaves that compression. In practical chart work, this helps separate a low-commitment range poke from a more convincing expansion move.
The visual presentation is intentionally structured. Inside bar zones are boxed, breakout direction is marked, quality is scored, and fakeouts are labeled when the breakout reverses back into the monitored range. This makes the script suitable for traders who want a cleaner way to inspect inside bar behavior without manually drawing every structure.
Unique Edge
The main difference here is that the script does not treat every inside bar break as equally meaningful. Many tools stop at “pattern detected” or “level broken.” This script adds a second layer: breakout quality. That layer is derived from close position, volume context, candle body participation, and alignment with the parent candle’s directional bias.
A second differentiator is the built-in fakeout logic. After a breakout is detected, the script continues to watch price for a limited number of bars. If the move quickly returns back through the breakout boundary, the event is tagged as a fakeout. This adds post-event context instead of only marking the first directional move.
Another distinction is that the methodology is deterministic and chart-native. The logic is rule-based, visible, and reproducible from bar to bar. Users can decide whether to require close confirmation beyond the inside bar range, whether to require volume confirmation, and how strict they want the displayed threshold to be through the minimum score filter.
In short, this script is not only about finding compression. It is about ranking the quality of the expansion attempt that follows the compression, while also acknowledging that some breakouts fail quickly and should be read differently.
Methodology
1) Inside Bar Detection
An inside bar is identified when the current bar’s high is lower than the previous bar’s high and the current bar’s low is higher than the previous bar’s low. This creates a strict containment definition based on the previous candle’s full range.
2) Reference Zone
Once an inside bar is detected, the prior candle becomes the parent reference bar. Its high and low define the active breakout boundaries. That range can be visualized as a box, with an optional midpoint line to make the compression zone easier to read on chart.
3) Breakout Confirmation
A bullish breakout occurs when price moves above the parent high. A bearish breakout occurs when price moves below the parent low. Users can choose whether breakout confirmation should be based on close beyond the range or on a less restrictive intrabar break condition.
4) Quality Score
Each breakout can be scored on a 0–10 scale. The score is built from multiple components:
- close position relative to the inside bar boundary
- volume ratio versus the selected moving average
- body participation within the breakout candle’s total range
- directional alignment between the breakout and the parent candle bias
This scoring model is designed to estimate how committed the breakout candle appears, rather than assuming all breaks have equal informational value.
5) Fakeout Detection
If enabled, the script monitors a user-defined number of bars after breakout. A bullish breakout that returns back below the upper boundary within that window is labeled as a bull trap / fakeout. A bearish breakout that returns back above the lower boundary within that window is labeled as a bear trap / fakeout.
6) Visual Layer
The script can display the inside bar zone, midpoint, breakout arrows, score labels, and fakeout markers. A summary panel tracks aggregate statistics such as total inside bars, total breakouts, breakout direction counts, fakeouts, and the latest breakout score.
Signals & Alerts
The script can provide alert conditions for:
- bullish inside bar breakout
- bearish inside bar breakout
- fakeout detection
- high-quality breakout events
- any breakout event
These alerts are intended to help users monitor the pattern and its resolution more efficiently. They do not replace trade planning, confirmation from broader market context, or independent risk management.
Key Inputs
Min Score to Show Breakout
Filters displayed breakout labels by quality threshold. This can be useful for reducing low-quality visual noise.
Volume Confirmation Required
When enabled, breakout evaluation requires volume to be above its moving average threshold. This can help remove low-participation breaks.
Volume MA Period
Defines the lookback length for average volume comparison.
Require Close Beyond IB
When enabled, breakout confirmation depends on bar close beyond the parent range. This creates a more conservative and more stable breakout definition.
Max IBs to Display
Controls how many recent structures and related objects remain visible on chart.
Show IB Box / Midline / Breakout Arrow / Score Label
Lets users decide how much visual detail they want to keep on screen.
Glow Effect on High Score
Adds emphasis to stronger breakout events without changing the underlying logic.
Fakeout Window
Defines how many bars after breakout the script should continue monitoring for a return back through the breakout boundary.
Limitations & Transparency
This script studies inside bar compression and subsequent breakout behavior. It does not claim to identify all meaningful consolidations, and it does not attempt to classify every market regime. The methodology is intentionally focused on one structure.
The score is a rule-based quality model, not an objective measure of future outcome. A high score does not guarantee continuation, and a lower score does not guarantee failure. It simply reflects how the breakout candle and its context behave according to the script’s internal criteria.
Volume-based interpretation may vary across symbols and markets. On some instruments, especially those with inconsistent or synthetic volume data, volume confirmation may be less informative than on others. Users should evaluate whether volume filtering is appropriate for the asset they are studying.
Fakeout detection is also definition-dependent. The script labels a fakeout when price returns through the breakout boundary within the selected lookback window. Different traders may prefer a different timing window or a different failure definition.
As with any overlay, chart readability depends on market volatility, timeframe, and user settings. On lower timeframes or during highly active periods, more visual events may appear. The built-in filters and display controls are there to help manage that density.
Risk Disclosure
This script is an analytical tool for chart study. It is not financial advice, not a trade recommendation, and not a promise of future results.
Inside bar breakouts can behave differently across timeframes, instruments, and market regimes. Users should not rely on a single pattern, score, or alert in isolation. Context still matters, including trend condition, liquidity environment, nearby structure, volatility regime, and execution discipline.
Before using this script in any live decision process, it should be reviewed in the specific market and timeframe relevant to the user’s own approach. Testing, observation, and risk controls remain essential.
Indicator

AG Pro Fair Value Gap Engine [AGPro Series]AG Pro Fair Value Gap Engine
OVERVIEW / WHAT IT DOES
AG Pro Fair Value Gap Engine is a rules-based overlay built to detect 3-bar fair value gap structures and organize them as a living imbalance map on the chart.
The script identifies bullish fair value gaps when the current low is above the high from two bars earlier, and bearish fair value gaps when the current high is below the low from two bars earlier. Once detected, each zone is stored, rendered, tracked through time, and updated as price interacts with it.
Instead of stopping at basic FVG detection, this script continues to follow the structure after creation. It monitors whether the gap remains active, whether price returns into it, whether mitigation occurs, how old the structure has become, and how strong or weak that mitigation event appears relative to the gap itself.
The result is not just a visual list of imbalances. It is an FVG lifecycle model designed to help traders distinguish between fresh gaps, aging gaps, mitigated gaps, and higher-quality mitigation events.
UNIQUE EDGE
Many fair value gap tools simply highlight every detected gap and leave the user to interpret the rest.
This script is built around a different idea:
not all FVGs deserve the same attention, and not every mitigation event carries the same informational value.
AG Pro Fair Value Gap Engine separates itself by combining detection, aging, prioritization, mitigation tracking, and scoring in a single structured workflow. Gaps are not treated as static rectangles. They are treated as evolving chart objects with a lifecycle.
Within the AG Pro Series, this script is also distinct from breakout-quality, reclaim, rotation, pressure, or acceptance-style overlays. Those models focus on trend behavior, reclaim behavior, structural confirmation, momentum pressure, or price acceptance around a reference. This one is centered on imbalance structure itself: where the 3-bar gap formed, how long it stayed relevant, whether price returned, and how credible that mitigation looked once interaction happened.
In practical terms, the script is designed to answer questions such as:
Which FVGs are still active?
Which ones are becoming stale?
Which mitigation events happened with better quality?
Which visible zones are worth keeping in focus, and which are just legacy context?
That is the core difference. This is not a generic FVG highlighter. It is an imbalance-ranking and mitigation-quality engine.
METHODOLOGY
1) Detection Logic
The script scans for standard 3-bar fair value gap structures.
Bullish FVG:
current low > high from two bars back
Bearish FVG:
current high < low from two bars back
A minimum size filter relative to ATR is applied so that very small gaps can be ignored when desired.
2) Structure Tracking
After detection, each FVG is stored and tracked over time. The script keeps the zone on the chart, extends active zones forward when enabled, and updates their visual state as the market evolves.
This allows the chart to preserve the structural memory of imbalance zones instead of treating every new gap as an isolated event.
3) Aging and Visual Decay
Older gaps gradually lose visual priority through fade logic. This helps newer or more relevant structures stay readable while old zones move into the background.
Optional controls can also suppress distant legacy zones when they become both old and far from current price.
4) Mitigation Logic
The script monitors how deeply price returns into each gap. When the user-defined mitigation threshold is reached, the FVG is marked as mitigated.
Mitigated zones can remain visible as context or be hidden for a cleaner chart, depending on preference.
5) Quality Scoring
Mitigation is not treated as a simple yes/no event. The script evaluates mitigation quality using a weighted model that includes:
- Gap size relative to ATR
- Speed of return into the zone
- Relative volume during the mitigation event
- Return strength after contact with the gap
This produces a normalized score intended to help separate weaker fills from stronger, better-formed mitigation behavior.
6) Focus and Prioritization
To reduce chart noise, the script includes focused labeling, active-zone prioritization, top-zone filtering, and legacy suppression logic.
This means the visual output can be tuned away from “show everything” and toward “show what matters most.”
SIGNALS & ALERTS
This script provides alert conditions for:
- Newly detected bullish fair value gaps
- Newly detected bearish fair value gaps
- Bullish fair value gaps reaching mitigation
- Bearish fair value gaps reaching mitigation
These alerts are event-based and rules-based. They are not forecasts, predictions, or trade instructions.
The labels and panel are designed to summarize state, not to replace the user’s broader market process.
KEY INPUTS
Core Settings
- Minimum FVG Size (ATR)
- Mitigation Threshold (%)
- Maximum Tracked FVG Count
- Age Fade Length
- Extend Active FVG Boxes
Scoring Engine
- Speed Score Reference
- Volume Score SMA Length
- Volume Score Max Ratio
- Size Score Max ATR
Visual Settings
- Show FVG Labels
- Focused Label Mode
- Focused Label Minimum Score
- Active / Mitigated Label Age Limits
- Highlight Score Threshold
- Theme Preset
- Show Mitigated Zones
- Show Mitigated Zone Labels
- Label Horizontal Offset
- Hide Distant Legacy FVGs
- Legacy Hide Age
- Legacy Hide Distance
- Show Only Top Active Zones
- Top Active Zones Count
- Label Stack Spacing
Panel Settings
- Show Panel
- Panel Position
- Panel Font Size
These controls allow the same logic to be used in a more information-dense mode or in a much cleaner presentation mode, depending on the charting style of the user.
LIMITATIONS & TRANSPARENCY
This script detects and organizes 3-bar imbalance structures. It does not claim to identify every meaningful liquidity event, order-flow shift, or broader smart money context factor on its own.
A fair value gap can remain open for a long time, fail quickly, or be revisited multiple times. A high score does not guarantee a directional outcome. A low score does not automatically invalidate the zone as context.
The mitigation score is a structured ranking model, not an objective truth about future price behavior. It is designed to help compare events inside the framework of this script.
Because chart structure, volatility, timeframe, and instrument behavior vary, users should expect different FVG densities and different score distributions across markets.
This tool is best used as a market-organization layer for imbalance analysis, not as a standalone execution system.
RISK DISCLOSURE
AG Pro Fair Value Gap Engine is an analytical charting tool for educational and informational use.
It does not provide financial advice, does not promise outcomes, and should not be interpreted as a standalone buy or sell system. Fair value gaps, mitigation events, and score readings should be evaluated together with market structure, volatility, timeframe context, liquidity conditions, and the user’s own risk framework.
Trading involves risk. Past chart behavior does not guarantee future results.
Indicator

Indicator

Indicator

Indicator

Indicator

Indicator

Indicator

Indicator

Indicator

Session Coloring Bar with ICT Macro [dani]The Session Coloring Bar is customizable Pine Script indicator designed to visually enhance your charts by applying unique colors to specific trading sessions or timeframes. This tool allows traders to easily identify and differentiate between macro sessions (e.g., 24-hour cycles) and custom-defined sessions (e.g., Session A, Session B), making it ideal for analyzing market activity during specific periods.
In the context of trading, the term "ICT Macro" , as discussed by Michael J. Huddleston (ICT), refers to specific timeframes or "windows" where market behavior often follows predictable patterns. Traders typically focus on the last 10 minutes of an hour and the first 10 minutes of the next hour (e.g., 0150-0210 , 0050-0110 , or 0950-1010 ) to identify key price movements, liquidity shifts, or market inefficiencies.
This script highlights these macro timeframes, enabling traders to visually analyze price action during these critical periods. Use this tool to support your strategy, but always combine it with your own analysis and risk management.
With this indicator, you can:
Highlight Macro Sessions : Automatically color bars based on predefined 24-hour macro sessions.
Customize Session Settings : Define up to three custom sessions (A & B) with individual start/end times, visibility toggles, and unique bar colors.
Timeframe Filtering : Hide session coloring above a specified timeframe to avoid clutter on higher timeframes.
Personal Notes : Add comments to each session for better organization and quick reference.
Dynamic Color Logic : Bars are colored based on their direction (up, down, or neutral) within the active session.
How to Use:
Enable/Disable Sessions :
Use the Show Coloring toggle to enable or disable session coloring for Macro, Session A, Session B, or Session C.
Set Session Times :
Define the start and end times for each session in the format HHMM-HHMM (e.g., 1600-0930 for an overnight session).
Choose Colors :
Assign unique colors for upward (Bar Up) and downward (Bar Down) bars within each session.
Adjust Timeframe Visibility :
Use the Hide above this TF input to specify the maximum timeframe where session coloring will be visible.
Add Notes :
Use the Comment field to add personal notes or labels for each session.
Example Use Cases:
Overnight Sessions :
Highlight overnight trading hours (e.g., 1600-0930) to analyze price action during low liquidity periods.
Asian/European/US Sessions : Define separate sessions for major trading regions to track regional market behavior.
Macro Analysis : Use the predefined 24-hour macro sessions to study hourly price movements across a full trading day.
Disclaimer:
The Session Coloring Bar is not a trading signal generator and does not predict market direction or provide buy/sell signals. Instead, it is a visualization tool designed to help you identify and analyze specific trading sessions or timeframes on your chart. By highlighting key sessions and their corresponding price movements, this indicator enables you to focus on periods of interest and make more informed trading decisions.
Thank you for choosing this indicator! I hope it becomes a valuable part of your trading toolkit. Remember, trading is a journey, and having the right tools can make all the difference. Whether you're a seasoned trader or just starting out, this indicator is designed to help you stay organized and focused on what matters most—price action. Happy trading, and may your charts be ever in your favor! 😊
Indicator

BBr1 Candle Range Volitility Gap IndicatorModified Candle Range Volatility Gap Indicator
1. Useful to analyze bars body and wicks and volatility of security.
2. Added a Percentage Option - easier to analyze across different securities.
2. Added a Standard Deviation ("1 std dev= 68.2%, 2 std dev=95.4%, 3 std dev=99.7%, etc") based upon user defined lookback period.
3. Added the ability to include Gaps in Analysis. (Gaps are when the prior closing cost does not equal opening price)
4. Possible Uses setting up stop losses, trailing entries/exits (inside range or outside range).
5. Use it with other indicators in determining if to make an entry or close entry.
Reposted Original Description by © ka66 Kamal Advani
Visually shows the Body Range (open to close) and Candle Range (high to low).
Semi-transparent overlapping area is the full Candle Range, and fully-opaque smaller area is the Body Range. For aesthetics and visual consistency, Candle Range follows the direction of the Body Range, even though technically it's always positive (high - low).
The different plots for each range type also means the UI will allow deselecting one or the other as needed. For example, some strategies may care only about the Body Range, rather than the entire Candle Range, so the latter can be hidden to reduce noise.
Threshold horizontal lines are plotted, so the trader can modify these high and low levels as needed through the user interface. These need to be configured to match the instrument's price range levels for the timeframe. The defaults are pretty arbitrary for +/- 0.0080 (80 pips in a 4-decimal place forex pair). Where a range reaches or exceeds a threshold, it's visually marked as well with a shape at the Body or Candle peak, to assist with quicker visual potential setup scanning, for example, to anticipate a following reversal or continuation. Indicator

Indicator

Indicator

First 5 Minutes Open/Close LinesThis very simple indicator paints lines at the high and low of the first 5m candle of the session. It is primarily intended for big cap NYSE traded stocks with high volume. I wrote this indicator to save me the trouble of manually drawing the lines each day.
The lines drawn at the 5m high/low will remain constant regardless of which timeframe you switch to. In the example screenshot, we are looking at the 1m timeframe. This helps us switch effortlessly between different timeframes to see if a given price movement meets our entry criteria.
In addition to drawing lines at the first 5m high/low, it will optionally paint two zones, one each around the high and low. The boundaries of this zone are configurable and expressed as a percentage of the total movement of the first 5m bar. By default, it is set to 25%.
This indicator is based on the concept that the first 5m bar always has massive volume which helps us infer that price may react around the extremes of that movement. The basic strategy works something like this:
- You identify the high timeframe (HTF) trend direction of the stock
- You wait for the first 5m candle of the session to close
- You wait for price to puncture through the outer boundary of the zone marked by the indicator.
- You enter when price retraces to the high, or low, which marks the midpoint of the punctured zone.
- Only enter long on stocks in a HTF uptrend, and short on stocks in an HTF downtrend.
- Use market structure to identify stop loss and take profit targets
Note: Use at your own risk. This indicator and the strategy described herein are not in any way financial advice, nor does the author of this script make any claims about the effectiveness of this strategy, which may depend highly on the discretion and skill of the trader executing it, among many other factors outside of the author's control. The author of this script accepts no liability, and is not responsible for any trading decisions that you may or may not make as a result of this indicator. You should expect to lose money if using this indicator.
Indicator

Indicator

Indicator

YinYang Bar ForecastOverview:
YinYang Bar Forecast is a prediction indicator. It predicts the movement for High, Low, Open and Close for up to 13 bars into the future. We created this Indicator as we felt the TradingView community could benefit from a bar forecast as there wasn’t any currently available.
Our YinYang Bar Forecast is something we plan on continuously working on to better improve it, but at its current state it is still very useful and decently accurate. It features many calculations to derive what it thinks the future bars will hold. Let’s discuss some of the logic behind it:
Each bar has its High, Low, Open and Close calculated individually for highest accuracy. Within these calculations we first check which bar it is we are calculating and base our span back length that we are getting our data from based on the bar index we are generating. This helps us get a Moving Average for this bar index.
We take this MA and we apply our Custom Volume Filter calculation on it, which is essentially us dividing the current bars volume over the average volume in the last ‘Filtered Length’ (Setting) length. We take this decimal and multiply it on our MA and smooth it out with a VWMA.
We take the new Volume Filtered MA and apply a RSI Filter calculation on it. RSI Filter is where we take the difference between the high and low of this bar and we multiply it with an RSI calculation using our Volume Filtered MA. We take the result of that multiplication and either add or subtract it from the Volume Filtered MA based on if close > open. This makes our RSI Filtered MA.
Next, we do an EMA Strength Calculation which is where we check if close > ema(close, ‘EMA Averaged Length’) (Setting). Based on this condition we assign a multiplier that is applied to our RSI Filtered MA. We divide by how many bars we are predicting and add a bit to each predictive bar so that the further we go into the future the stronger the strength is.
Next we check RSI and RSI MA levels and apply multiplications based on its RSI levels and if it is greater than or less than the MA. Also it is affected by if the RSI is <= 30 and >= 70.
Finally we check the MFI and MFI MA levels and like RSI we apply multiplications based on its MFI levels and if it is greater than or less than the MA. It is also affected by if the MFI is <= 30 and >= 70.
Please note the way we calculate this may change in the future, this is just currently what we deemed works best for forecasting the future bars. Also note this script uses MA calculations out of scope for efficiency but there is potential for inconsistencies.
Innately it’s main use is the projection it provides. It only draws the bars for realtime bars and not historical ones, so the best way to backtest it is with TradingView’s Replay Tool.
Well, enough of the logic behind it, let's get to understanding how to use it:
Tutorial:
So unfortunately we aren’t able to plot legit bars/candles into the future so we’ve had to do a bit of a work around using lines and fills. As you can see here we have 4 Lines and 3 Zones:
Lines:
Green: Represents the High
Orange: Represents the Open
Teal: Represents the Close
Red: Represents the Low
Zones:
High Zone: This zone is from either Open or Close to the High and is ALWAYS filled with Green.
Open/Close Zone: This zone is from the Open to the Close and is filled with either Green or Red based on if it's greater than the previous bar (real or forecasted).
Low Zone: This zone is from either Open or Close to the Low and is ALWAYS filled with Red.
As you can see generally the Forecasted bars are generally within strong pivot locations and are a good estimation of what will likely go on. Please note, the WHOLE structure of the prediction can change based on the current bars movements and the way it affects the calculations.
Let's look 1 bar back from the current bar just so we can see what it used to Forecast:
As you can see it has changed quite a bit from the previous bar, but if you look close, we drew horizontal lines around where its projecting the next bar to be (our current realtime bar), if we go back to the live chart:
Its projections were pretty close for the high and low. Generally, right now at least, it does a much better job at predicting the high and low than it does the open and close, however we will do our best to fine tune that in future updates.
Remember, this indicator is not meant to base your trades on, but rather give you a Forecast towards the general direction of the next few bars. Somewhat like weather, the farther the bar (or day for weather), the harder it is to predict. For this reason we recommend you focusing on the first few bars as they are more accurate, but review the further ones as they may help show the trend and the way that pair will move.
We will conclude this tutorial here, hopefully this Predictive Indicator can be of some help and use to you. If you have any questions, comments, ideas or concerns please let us know.
Settings:
Forecast Length: How many bars should we predict into the Future? Max 13
Each Bar Length Multiplier: For each new Forecast bar, how many more bars are averaged? Min 2
VWMA Averaged Length: All Forecast bars are put into a VWMA, what length should we use?
EMA Averaged Length: All Forecast bars are put into a EMA, what length should we use?
Filtered Length: What length should we use for Filtered Volume and RSI?
EMA Strength Length: What length should we use for the EMA Strength
HAPPY TRADING! Indicator

CandlesGroup_TypesLibrary "CandlesGroup_Types"
CandlesGroup Type allows you to efficiently store and access properties of all the candles in your chart.
You can easily manipulate large datasets, work with multiple timeframes, or analyze multiple symbols simultaneously. By encapsulating the properties of each candle within a CandlesGroup object, you gain a convenient and organized way to handle complex candlestick patterns and data.
For usage instructions and detailed examples, please refer to the comments and examples provided in the source code.
method init(_self)
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup)
method init(_self, propertyNames)
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup)
propertyNames (string )
method get(_self, key)
get values array from a given property name
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
key (string) : : key name of selected property. Default is "index"
Returns: values array
method size(_self)
get size of values array. By default it equals to current bar_index
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
Returns: size of values array
method push(_self, key, value)
push single value to specific property
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
key (string) : : key name of selected property
value (float) : : property value
Returns: CandlesGroup object
method push(_self, arr)
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup)
arr (float )
method populate(_self, ohlc)
populate ohlc to CandlesGroup
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
ohlc (float ) : : array of ohlc
Returns: CandlesGroup object
method populate(_self, values, propertiesNames)
populate values base on given properties Names
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
values (float ) : : array of property values
propertiesNames (string ) : : an array stores property names. Use as keys to get values
Returns: CandlesGroup object
method populate(_self)
populate values (default setup)
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
Returns: CandlesGroup object
method lookback(arr, bars_lookback)
get property value on previous candles. For current candle, use *.lookback()
Namespace types: float
Parameters:
arr (float ) : : array of selected property values
bars_lookback (int) : : number of candles lookback. 0 = current candle. Default is 0
Returns: single property value
method highest_within_bars(_self, hiSource, start, end, useIndex)
get the highest property value between specific candles
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
hiSource (string) : : key name of selected property
start (int) : : start bar for calculation. Default is candles lookback value from current candle. 'index' value is used if 'useIndex' = true
end (int) : : end bar for calculation. Default is candles lookback value from current candle. 'index' value is used if 'useIndex' = true. Default is 0
useIndex (bool) : : use index instead of lookback value. Default = false
Returns: the highest value within candles
method highest_within_bars(_self, returnWithIndex, hiSource, start, end, useIndex)
get the highest property value and bar index between specific candles
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
returnWithIndex (bool) : : the function only applicable when it is true
hiSource (string) : : key name of selected property
start (int) : : start bar for calculation. Default is candles lookback value from current candle. 'index' value is used if 'useIndex' = true
end (int) : : end bar for calculation. Default is candles lookback value from current candle. 'index' value is used if 'useIndex' = true. Default is 0
useIndex (bool) : : use index instead of lookback value. Default = false
Returns:
method highest_point_within_bars(_self, hiSource, start, end, useIndex)
get a Point object which contains highest property value between specific candles
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
hiSource (string) : : key name of selected property
start (int) : : start bar for calculation. Default is candles lookback value from current candle. 'index' value is used if 'useIndex' = true
end (int) : : end bar for calculation. Default is candles lookback value from current candle. 'index' value is used if 'useIndex' = true. Default is 0
useIndex (bool) : : use index instead of lookback value. Default = false
Returns: Point object contains highest property value
method lowest_within_bars(_self, loSource, start, end, useIndex)
get the lowest property value between specific candles
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
loSource (string) : : key name of selected property
start (int) : : start bar for calculation. Default is candles lookback value from current candle. 'index' value is used if 'useIndex' = true
end (int) : : end bar for calculation. Default is candles lookback value from current candle. 'index' value is used if 'useIndex' = true. Default is 0
useIndex (bool) : : use index instead of lookback value. Default = false
Returns: the lowest value within candles
method lowest_within_bars(_self, returnWithIndex, loSource, start, end, useIndex)
get the lowest property value and bar index between specific candles
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
returnWithIndex (bool) : : the function only applicable when it is true
loSource (string) : : key name of selected property
start (int) : : start bar for calculation. Default is candles lookback value from current candle. 'index' value is used if 'useIndex' = true
end (int) : : end bar for calculation. Default is candles lookback value from current candle. 'index' value is used if 'useIndex' = true. Default is 0
useIndex (bool) : : use index instead of lookback value. Default = false
Returns:
method lowest_point_within_bars(_self, loSource, start, end, useIndex)
get a Point object which contains lowest property value between specific candles
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
loSource (string) : : key name of selected property
start (int) : : start bar for calculation. Default is candles lookback value from current candle. 'index' value is used if 'useIndex' = true
end (int) : : end bar for calculation. Default is candles lookback value from current candle. 'index' value is used if 'useIndex' = true. Default is 0
useIndex (bool) : : use index instead of lookback value. Default = false
Returns: Point object contains lowest property value
method time2bar(_self, t)
Convert UNIX time to bar index of active chart
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
t (int) : : UNIX time
Returns: bar index
method time2bar(_self, timezone, YYYY, MMM, DD, hh, mm, ss)
Convert timestamp to bar index of active chart. User defined timezone required
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
timezone (string) : : User defined timezone
YYYY (int) : : Year
MMM (int) : : Month
DD (int) : : Day
hh (int) : : Hour. Default is 0
mm (int) : : Minute. Default is 0
ss (int) : : Second. Default is 0
Returns: bar index
method time2bar(_self, YYYY, MMM, DD, hh, mm, ss)
Convert timestamp to bar index of active chart
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
YYYY (int) : : Year
MMM (int) : : Month
DD (int) : : Day
hh (int) : : Hour. Default is 0
mm (int) : : Minute. Default is 0
ss (int) : : Second. Default is 0
Returns: bar index
method get_prop_from_time(_self, key, t)
get single property value from UNIX time
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
key (string) : : key name of selected property
t (int) : : UNIX time
Returns: single property value
method get_prop_from_time(_self, key, timezone, YYYY, MMM, DD, hh, mm, ss)
get single property value from timestamp. User defined timezone required
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
key (string) : : key name of selected property
timezone (string) : : User defined timezone
YYYY (int) : : Year
MMM (int) : : Month
DD (int) : : Day
hh (int) : : Hour. Default is 0
mm (int) : : Minute. Default is 0
ss (int) : : Second. Default is 0
Returns: single property value
method get_prop_from_time(_self, key, YYYY, MMM, DD, hh, mm, ss)
get single property value from timestamp
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
key (string) : : key name of selected property
YYYY (int) : : Year
MMM (int) : : Month
DD (int) : : Day
hh (int) : : Hour. Default is 0
mm (int) : : Minute. Default is 0
ss (int) : : Second. Default is 0
Returns: single property value
method bar2time(_self, index)
Convert bar index of active chart to UNIX time
Namespace types: CandlesGroup
Parameters:
_self (CandlesGroup) : : CandlesGroup object
index (int) : : bar index
Returns: UNIX time
Point
A point on chart
Fields:
price (series float) : : price value
bar (series int) : : bar index
bartime (series int) : : time in UNIX format of bar
Property
Property object which contains values of all candles
Fields:
name (series string) : : name of property
values (float ) : : an array stores values of all candles. Size of array = bar_index
CandlesGroup
Candles Group object which contains properties of all candles
Fields:
propertyNames (string ) : : an array stores property names. Use as keys to get values
properties (Property ) : : array of Property objects Library

Indicator
