PROTECTED SOURCE SCRIPT

Price-Shift Oscillator (PSO)

Updated
The PSOscillator calculates an oscillator value based on price movements over a specific period. Oscillators like this one are typically used to identify momentum shifts, and trend direction. Here's a breakdown of how the logic behind it works:

Key Concepts for Beginners:
Oscillators:

In this case, the PSOscillator helps indicate whether the market momentum is positive (price might rise) or negative (price might fall).
Input Parameters:

oscPeriod: This is the number of bars (or candles) used to calculate the oscillator. It affects how sensitive the oscillator is to price changes. A lower period makes it more sensitive to short-term movements, while a higher period smoothens it out.

smaPeriod: This is a simple moving average (SMA) applied to the oscillator for additional smoothing, further reducing noise.

Calculation Logic:

The JpOscillator uses recent price data to calculate its value. Specifically, it looks at the closing prices of the current and previous bars (candles). periods ago).
This calculation aims to identify how much recent price action is deviating from past price behavior.

Essentially, it tells us whether the current price is higher or lower relative to the past, and how the trend is evolving over recent periods.

Smoothing:

After calculating the oscillator values, we apply optional smoothing to make it less "jumpy." This is useful in reducing the noise caused by small, insignificant price movements.
The sma_from_array function averages out the recent oscillator values to make the signal smoother, depending on the oscPeriod.
Oscillator Levels:

Above Zero:

If the oscillator is above 0, it means the price is gaining momentum upwards (bullish signal), which is why we color the histogram green.
Below Zero: If the oscillator is below 0, it indicates downward momentum (bearish signal), which is why we color the histogram red.
You can think of the zero line as a "neutral zone." Crossing above it means momentum is shifting to the upside, and crossing below it means momentum is shifting to the downside.

Histogram Plotting:

The values of the oscillator are plotted as a histogram (bars). The color changes based on whether the oscillator is above or below zero (green for positive and red for negative momentum).

The moving average (SMA) of the oscillator is plotted as a line to help identify trends over time.

Using two different coloring methods for a histogram in a trading strategy can provide a trader with distinct, layered information about market conditions, trends, and momentum shifts. Each coloring method can highlight different aspects of the price action or the oscillator behavior. Here’s how a trader might use both methods to their advantage:

ETHUSDT Daily

snapshot

1. Color Based on Oscillator Position Relative to Zero
This method colors the histogram green when the oscillator value is above zero and red when it's below zero. This coloring strategy is straightforward and helps a trader quickly identify whether the market's momentum is generally bullish or bearish.

Advantages:

Trend Confirmation: When the oscillator remains above zero and green, it can confirm a bullish trend, and vice versa for a bearish trend with red colors below zero.
Quick Visual Reference: Easy to see at a glance, helping in fast decision-making processes.
2. Color Based on the Change of the Oscillator
This method changes the color based on whether the oscillator is increasing or decreasing compared to its previous value. For instance, a darker shade of green might be used if the oscillator value is rising from one period to the next, indicating increasing bullish momentum, and a darker red if declining, indicating increasing bearish momentum.

Advantages:

Momentum Insight: This coloring method gives insights into the strength of the movement. An oscillator that is increasing (even below zero) might suggest a weakening of a bearish trend or the start of a bullish reversal.
Detecting Reversals: Seeing the oscillator rise from negative to less negative or drop from positive to less positive can alert traders to potential early reversals before they cross the zero line.
Strategic Use in Trading:
A trader can use these two methods together by applying a multi-layered approach to analyze the oscillator:

Overall Trend Assessment:

Above Zero (Green): Considered bullish; look for buy opportunities, especially if the color gets brighter (indicating strengthening).
Below Zero (Red): Considered bearish; look for sell opportunities, especially if the color gets darker (indicating strengthening).
Short-Term Momentum and Entries:

Brightening Green: Could indicate a good time to enter or add to long positions as bullish momentum increases.
Darkening Red: Could indicate a good time to enter or add to short positions as bearish momentum increases.
Lightening Color: If red starts to lighten (become less intense), it might suggest a bearish trend is losing steam, which could be an exit signal for shorts or an early warning for a potential long setup.
Risk Management:

Switch in Color Intensity: A sudden change in color intensity can be used as a trigger for tightening stops or taking partial profits, helping manage risk by responding to changes in market momentum.

Release Notes
- added switch for choosing between the 0-cross and trend following color scheme.
snapshot
- added color scheme for trend following for more nuance
snapshot
Release Notes
Heiken Ashi Coloring Integration:

The integration of Heiken Ashi (HA) into the oscillator adds a powerful dimension of trend analysis. Heiken Ashi is known for smoothing price data to produce a cleaner and more understandable trend visualization.

I derive HA values (open, close, high, low) and use them to determine the current trend's direction and strength. Assigned distinct colors to the oscillator bars based on whether the HA candlesticks are bullish or bearish, and whether they indicate a strengthening or weakening trend. This is visualized with green shades for bullish trends and red shades for bearish trends. Additionally, a unique coloring (e.g., orange) is used when there's a shift in momentum, providing a clear signal of potential trend reversals.
Moving Average (SMA) with Glow Effect:

Incorporated a Simple Moving Average (SMA) of the PSO to help smooth out short-term fluctuations and provide a clearer view of the underlying trend in the oscillator's movement. The SMA is a commonly used indicator to gauge the direction of the momentum over a specified period.

The glow effect adds a visual enhancement that helps highlight the SMA line against the backdrop of the oscillator histogram. This makes it easier to distinguish the SMA from the PSO, enhancing visibility in different market conditions. The coloring of the SMA line itself is dynamic, changing between green and red based on the direction of the trend, which aligns with the bullish or bearish sentiment indicated by the PSO values.
Enhanced Visualization and Usability:

By offering inputs to toggle the SMA and its glow effect, provided flexibility for users to customize their chart views based on personal preferences or specific analytical needs.

The combination of Heiken Ashi coloring and the dynamic SMA with a glow effect makes the PSO a more robust tool for traders who need to quickly assess trend strength, direction, and potential reversals without getting lost in noise and frequent price spikes.
Release Notes

Updated Coloring for trend following.
Release Notes
Minor update because of a calculation issue for the coloring of the SMA, my apologies and happy trading! :)
Candlestick analysisCentered OscillatorsMomentum Indicator (MOM)

Protected script

This script is published closed-source and you may privately use it freely.

Want to use this script on a chart?


Also on:

Disclaimer