CoffeeShopCrypto Supply Demand PPO AdvancedCoffeeShopCrypto PPO Advanced is a structure-aware momentum oscillator and price-trend overlay designed to help traders interpret momentum strength, exhaustion, and continuation across evolving market conditions. It’s not a “buy/sell” signal tool — it's a momentum context tool that helps confirm trend intent.
Original Code derived from the Price Oscillator Indicators (PPO) found in the TradingView Technical Indicators categories. You can view the info and calculation for the original PPO here
www.tradingview.com
Much like the MACD, the PPO uses a couple lagging indicators to present Momentum as a percentage. But it lacks context to market structure.
What It’s Based On
This tool is based on a dual-moving-average PPO oscillator structure (Percentage Price Oscillator) enhanced by:
Oscillator pivot structure: detection of Lower Highs (LH) and Higher Lows (HL) inside the oscillator.
Detection of Supply and Demand Trends via Market Absorption
Ability to transfer its average plots to price action
Detection of Trend Exhaustion
Real-time price-based exhaustion levels: projecting potential future supply and demand using trendlines from weakening momentum.
Integrated fast and slow Moving Averages on price using the same inputs as the oscillator, to visualize alignment between short- and long-term trends.
These elements combine momentum context with price action in a visual, intuitive system.
How It Works
1. Oscillator Structure
LHs (above zero): momentum weakening in uptrends.
HLs (below zero): momentum strengthening in downtrends.
Only valid pivots are shown (e.g., an LH must be preceded by a valid LL).
2. Exhaustion Levels
Green demand lines: price is making new lows, but oscillator prints HL → potential exhaustion.
Red supply lines: price is making new highs, but oscillator prints LH → potential exhaustion.
These lines are future-facing, projecting likely reaction zones based on momentum weakening.
3. Moving Averages on Price
Two MAs are drawn on the price chart:
Fast MA (same length as PPO short input)
Slow MA (same length as PPO long input)
These are not signal lines — they're visual guides for trend alignment.
MA crossover = PO crosses zero. This indicates short- and long-term momentum are syncing — a powerful signal of trend conviction.
When price is above both MAs, and the PO is rising above zero, bullish momentum is dominant.
When price is below both MAs, and the PO is falling below zero, bearish momentum dominates.
How Traders Can Use It
✅ Spot Trend Initiation
Wait for clear trend confirmation in price.
Use PPO Momentum+ to confirm momentum structure is aligned (e.g., HH/HL in oscillator + price above both MAs).
🔁 Track Continuations
In uptrends, look for oscillator HH and HL sequences with price holding above both MAs.
In downtrends, seek LL and LH sequences with price below both MAs.
⚠️ Watch for Exhaustion
Price breaking below red (supply) lines after oscillator LH = bearish exhaustion signal.
Price breaking above green (demand) lines after oscillator HL = bullish exhaustion signal.
These levels act like pre-mapped S/R zones, showing where momentum previously failed and price may react.
Why This Is Different
Momentum tools often lag or mislead when used blindly. This tool visualizes structural failure in momentum and maps potential outcomes. The integration of oscillator and price-based tools ensures traders are always reading context, not just raw signals.
Demand Trendlines
Demand trendlines show us Wykoff's law of "Absorbed Supply Reversal" In real time.
When aggressive selling pressure is persistently absorbed by passive buying interest without significant downward price continuation, and supply becomes exhausted, the market structure shifts as demand regains control—resulting in a directional reversal to the upside.
This commonly happens in a 3 phase interaction of price.
1. Selling pressure is absorbed quickly by buyers.
This PPO tool will calculate the trend of this absorption process
2. After there is a notable Bearish Exhaustion of price action, the PPO tool will draw a trendline of this absorption showing us the potential future prices where aggressive buyers will want to step in at lower prices.
3. After higher lows are defined in the oscillator, you'll see prices react in a strong bullish pattern at this trendline where aggressive buyers stepped in to reverse price action to the upside.
Supply Trendlines
Supply trendlines show us Wykoff's law of "Absorbed Demand Reversal" In real time.
When aggressive buying pressure is persistently absorbed by passive selling interest without significant downward price continuation, and demand becomes exhausted, the market structure shifts as supply regains control—resulting in a directional reversal to the downside.
This commonly happens in a 3 phase interaction of price.
1. Buying pressure is absorbed quickly by sellers.
This PPO tool will calculate the trend of this absorption process.
2. After there is a notable Bullish Exhaustion of price action, the PPO tool will draw a trendline of this absorption showing us the potential future prices where aggressive sellers will want to step in at higher prices.
3. After lower highs are defined in the oscillator, you'll see prices react in a strong bearish pattern at this trendline where aggressive sellers stepped in to reverse price action to the downside.
Lower High and Higher Low Signals
When the oscillator signals Lower Highs or High Lows its only noting that momentum in that trend direction is slowing. THis indicates a coming pause in the market and the proceeding longs of an uptrend or shorts of a downtrend should be taken with caution.
**These LH and HL markers are not reading as divergences in price vs momentum.**
They are simply registering against the highs and lows of itself..
Moving Averages on Price Action
The Oscillator will cross over its ZERO level the same time your Short and Long MAs cross each other. This will indicate that the short term average trend is moving ahead of the long term.
Crossovers are not an entry signal. It's a method in determining you current timeframe trend strength. Always observe price action as it passes through each of your moving averages and compare it to the positioning and direction of the oscillator.
If price dips in between the moving averages while the oscillator still shows a strong trend strength, you can wait for price to move ahead of your fast moving average.
Bar Colors and Signal Line for Trend Strength
Good Bullish Trend = Oscillator above zero + Signal rising below Oscillator
Weak Bullish Trend = Oscillator above zero + Signal above Oscillator
Good Bearish Trend = Oscillator below zero + Signal falling above Oscillator
Weak Bearish Trend = Oscillator below zero + Signal below Oscillator
Bar Colors
Bars are colored to match Oscillator Momentum Strength. Colors are set by user.
Why alter the known PPO (Percentage Price Oscillator) in this manner?
The PPO tool is great for measuring the strength as percentage of price action over and average amount of candles however, with these changes,
you know have the ability to correlate:
Wycoff theory of supply and demand,
Measure the depth of reversals and pullback by price positioning against moving averages,
Project potential reversal and exhaustion pricing,
Visibly note the structure of momentum much like you would note market structure,
Its not enough to know there is momentum. Its better to know
A) Is it enough
B) Is there something in the way which will cause price to push back
C) Does this momentum correlate to the prevailing trend
Structureanalysis
Smart money conceptThe indicator tracks the smallest movements of price action. It can monitor and analyze market context, attempting to identify trends within each time frame.
If a candle has its entire body above the previous swing high, it indicates a strong upward momentum. The market is leaning towards an upward direction. If the candle remains within the range of the previous swing high, it signifies weak upward momentum. The market is reluctant to move higher.
If a candle has its entire body below the previous swing low, it reflects a strong downward momentum. The market is leaning towards a downward direction. If the candle remains within the range of the previous swing low, it indicates weak downward momentum. The market is reluctant to move lower.
Sniffer
╭━━━╮╱╱╱╱╭━╮╭━╮
┃╭━╮┃╱╱╱╱┃╭╯┃╭╯
┃╰━━┳━╮╭┳╯╰┳╯╰┳━━┳━╮
╰━━╮┃╭╮╋╋╮╭┻╮╭┫┃━┫╭╯
┃╰━╯┃┃┃┃┃┃┃╱┃┃┃┃━┫┃
╰━━━┻╯╰┻╯╰╯╱╰╯╰━━┻╯
Overview
A vast majority of modern data analysis & modelling techniques rely upon the idea of hidden patterns, wether it is some type of visualisation tool or some form of a complex machine learning algorithm, the one thing that they have in common is the belief, that patterns tell us what’s hidden behind plain numbers. The same philosophy has been adopted by many traders & investors worldwide, there’s an entire school of thought that operates purely based on chart patterns. This is where Sniffer comes in, it is a tool designed to simplify & quantify the job of pattern recognition on any given price chart, by combining various factors & techniques that generate high-quality results.
This tool analyses bars selected by the user, and highlights bar clusters on the chart that exhibit similar behaviour across multiple dimensions. It can detect a single candle pattern like hammers or dojis, or it can handle multiple candles like morning/evening stars or double tops/bottoms, and many more. In fact, the tool is completely independent of such specific candle formations, instead, it works on the idea of vector similarity and generates a degree of similarity for every single combination of candles. Only the top-n matches are highlighted, users get to choose which patterns they want to analyse and to what degree, by customising the feature-space.
Background
In the world of trading, a common use-case is to scan a price chart for some specific candlestick formations & price structures, and then the chart is further analysed in reference to these events. Traders are often trying to answer questions like, when was the last time price showed similar behaviour, what are the instances similar to what price is doing right now, what happens when price forms a pattern like this, what were some of other indicators doing when this happened last(RSI, CCI, ADX etc), and many other abstract ideas to have a stronger confluence or to confirm a bias.Having such a context can be vital in making better informed decisions, but doing this manually on a chart that has thousands of candles can have many disadvantages. It’s tedious, human errors are rather likely, and even if it’s done with pin-point accuracy, chances are that we’ll miss out on many pieces of information. This is the thought that gave birth to Sniffer .
Sniffer tries to provide a general solution for pattern-based analysis by deploying vector-similarity computation techniques, that cover the full-breadth of a price chart and generate a list of top-n matches based on the criteria selected by the user. Most of these techniques come from the data science space, where vector similarity is often implemented to solve classification & clustering problems. Sniffer uses same principles of vector comparison, and computes a degree of similarity for every single candle formation within the selected range, and as a result generates a similarity matrix that captures how similar or dissimilar a set of candles is to the input set selected by the user.
How It Works
A brief overview of how the tool is implemented:
- Every bar is processed, and a set of features are mapped to it.
- Bars selected by the user are captured, and saved for later use.
- Once the all the bars have been processed, candles are back-tracked and degree of similarity is computed for every single bar(max-limit is 5000 bars).
- Degree of similarity is computed by comparing attributes like price range, candle breadth & volume etc.
- Similarity matrix is sorted and top-n results are highlighted on the chart through boxes of different colors.
A brief overview of the features space for bars:
- Range: Difference between high & low
- Body: Difference between close & open
- Volume: Traded volume for that candle
- Head: Upper wick for green candles & lower wick for red candles
- Tail: Lower wick for green candles & upper wick for red candles
- BTR: Body to Range ratio
- HTR: Head to Range ratio
- TTR: Tail to Range ratio
- HTB: Head to Body ratio
- TTB: Tail to Body ratio
- ROC: Rate of change for HL2 for four different periods
- RSI: Relative Strength Index
- CCI: Commodity Channel Index
- Stochastic: Stochastic Index
- ADX: DMI+, DMI- & ADX
A brief overview of how degree of similarity is calculated:
- Each bar set is compared to the inout bar set within the selected feature space
- Features are represented as vectors, and distance between the vectors is calculated
- Shorter the distance, greater the similarity
- Different distance calculation methods are available to choose from, such as Cosine, Euclidean, Lorentzian, Manhattan, & Pearson
- Each method is likely to generate slightly different results, users are expected to select the method & the feature space that best fits their use-case
How To Use It
- Usage of this tool is relatively straightforward, users can add this indicator to their chart and similar clusters will be highlighted automatically
- Users need to select a time range that will be treated as input, and bars within that range become the input formation for similarity calculations
- Boxes will be draw around the clusters that fit the matching criteria
- Boxes are color-coded, green color boxes represent the top one-third of the top-n matches, yellow boxes represent the middle third, red boxes are for bottom third, and white box represents user-input
- Boxes colors will be adjusted as you adjust input parameters, such as number of matches or look-back period
User Settings
Users can configure the following options:
- Select the time-range to set input bars
- Select the look-back period, number of candles to backtrack for similarity search
- Select the number of top-n matches to show on the chart
- Select the method for similarity calculation
- Adjust the feature space, this enables addition of custom features, such as pattern recognition, technical indicators, rate of change etc
- Toggle verbosity, shows degree of similarity as a percentage value inside the box
Top Features
- Pattern Agnostic: Designed to work with variable number of candles & complex patterns
- Customisable Feature Space: Users get to add custom features to each bar
- Comprehensive Comparison: Generates a degree of similarity for all possible combinations
Final Note
- Similarity matches will be shown only within last 4500 bars.
- In theory, it is possible to compute similarity for any size candle formations, indicator has been tested with formations of 50+ candles, but it is recommended to select smaller range for faster & cleaner results.
- As you move to smaller time frames, selected time range will provide a larger number of candles as input, which can produce undesired results, it is advised to adjust your selection when you change time frames. Seeking suggestions on how to directly receive bars as user input, instead of time range.
- At times, users may see array index out of bound error when setting up this indicator, this generally happens when the input range is not properly configured. So, it should disappear after you select the input range, still trying to figure out where it is coming from, suggestions are welcome.
Credits
- @HeWhoMustNotBeNamed for publishing such a handy PineScript Logger, it certainly made the job a lot easier.
Price Swing Detection - Smart Money ConceptSince my own style is Smart Money Concept and these days I have seen a lot of my friends who are having trouble identifying structures for their indicators and strategies. I wrote this code so they could use it in their strategy . In fact, this type of structure, as one of the strongest technical structures, can increase the success of your strategy according to your personalization.
The script detects swings (i.e. significant highs and lows) in a financial instrument's price action over a specified period. The user can set the lookback period (number of candles to consider) and the colors of the lines representing bullish and bearish trends.
The script has two functions: detectSwing and pivot high. The detectSwing function calculates the swing highs and lows for the specified number of candles. The function uses the ta.highest and ta.lowest functions to find the highest and lowest prices, respectively, over the lookback period. The function also determines the swing state (high or low) of the current candle and returns the calculated swing values.
The pivot high function calculates the pivot high, which is an important step in detecting bullish structures in the market. If a new top (i.e. swing high) is found, the script updates the pivot high values and creates a line from the recent top to the last bar. The script also updates the trailing maximum values, which are used to extend the top extension line.
For Strategy :
The variable "trendDirection" in the code is used to keep track of the trend state, either bullish (up trend) or bearish (down trend), in the market. The variable is initialized to 0 which represents a downtrend. The value of this variable is updated later in the code based on the calculations of swing highs and lows, pivot crosses, and the trailing maximum. If a bullish structure is detected, the value of "trendDirection" is set to 1, indicating an uptrend.