Indicator · Pine Script v4 · On the chart

Fear + Greed Reversal Projection

by krosenfeld7

Fear + Greed Reversal Projection measures market sentiment extremes by comparing price source values against historical highs and lows using standard deviation bands.

View on GitHub

GitHub stars5on the repository
Pine versionv4older, still runs
Lines of code67
Settings5inputs
LicenceApache-2.0
Last update3 years ago12 May 2023

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

67 lines of Pine Script v4 from Fear+Greed_Reversal/Fear+Greed_Reversal.txt, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

Fear+Greed_Reversal.txt
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © krosenfeld7

//@version=4
study("Fear + Greed Reversal Projection", overlay=true, shorttitle="Fear & Greed")

// Fear & Greed Section
lowPeriod = input(30, title="Low Period")
highPeriod = input(30, title="High Period")
stdev_period = input(50, title="Stdev Period")
src = input(ohlc4, title="Source")
WMA = input(false, title="Use WMA instead of SMA?")

// Condition One 
greedZone1 = (lowest(src, lowPeriod) - src) / lowest(src, lowPeriod)
greedAvg1 = WMA ? wma(greedZone1, stdev_period) : sma(greedZone1, stdev_period)
greedZoneLimit1 = greedAvg1 - stdev(greedZone1, stdev_period)

fearZone1 = (highest(src, highPeriod) - src) / highest(src, highPeriod)
fearAvg1 = WMA ? wma(fearZone1, stdev_period) : sma(fearZone1, stdev_period)
fearZoneLimit1 = fearAvg1 + stdev(fearZone1, stdev_period)

// Condition Two
greedZone2 = WMA ? wma(src, lowPeriod) : sma(src, lowPeriod)
greedAvg2 = WMA ? wma(greedZone2, stdev_period) : sma(greedZone2, stdev_period)
greedZoneLimit2 = greedAvg2 + stdev(greedZone2, stdev_period)

fearZone2 = WMA ? wma(src, highPeriod) : sma(src, highPeriod)
fearAvg2 = WMA ? wma(fearZone2, stdev_period) : sma(fearZone2, stdev_period)
fearZoneLimit2 = fearAvg2 - stdev(fearZone2, stdev_period)

// GreedZone
inGreedZone = greedZone1 < greedZoneLimit1 and greedZone2 > greedZoneLimit2 
greedZoneOpen = inGreedZone ? low - tr : na
greedZoneClose = inGreedZone ? low - 2 * tr : na

inFearZone = fearZone1 > fearZoneLimit1 and fearZone2 < fearZoneLimit2
fearZoneOpen = inFearZone ? low - tr : na
fearZoneClose = inFearZone ? low - 2 * tr : na

greedGap = inGreedZone ? greedZoneOpen - greedZoneClose : na
fearGap = inFearZone ? fearZoneOpen - fearZoneClose : na

// Fear / Greed Trend reversing
greedy = greedGap > 0
noLongerGreedy = (greedy[1] == true and greedy == false) ? 1 : 0
fearful = fearGap > 0
noLongerFearful = (fearful[1] == true and fearful == false) ? 1 : 0

// Extreme cases
extremeFear = (fearGap > fearZoneClose) ? 1 : 0
extremeGreed = (greedGap > greedZoneClose) ? 1 : 0

plot(greedGap, color=color.purple, style=plot.style_linebr)
plotcandle(greedZoneOpen, greedZoneOpen, greedZoneClose, greedZoneClose, color=color.red, bordercolor=color.white,  title="Greedy Candlesticks")

plot(fearGap, color=color.aqua, style=plot.style_linebr)
plotcandle(fearZoneOpen, fearZoneOpen, fearZoneClose, fearZoneClose, color=color.blue, bordercolor=color.white,  title="Fearful Candlesticks")

// Alerts
alertcondition(inGreedZone == true and inGreedZone[1] == false, title='Entering Greedy Zone', message='Entering Greedy Zone')
alertcondition(noLongerGreedy, title='Leaving Greedy Zone', message='Leaving Greedy Zone (Trend Reversal)')
alertcondition(extremeGreed, title='EXTREME GREED (Day Only)', message='EXTREME GREED')

alertcondition(inFearZone == true and inFearZone[1] == false, title='Entering Fear Zone', message='Entering Fear Zone')
alertcondition(noLongerFearful, title='Leaving Fear Zone', message='Leaving Fear Zone (Trend Reversal)')
alertcondition(extremeGreed, title='EXTREME FEAR (Day Only)', message='EXTREME FEAR')

Overview

Fear + Greed Reversal Projection calculates fear and greed zones through simple or weighted moving averages. When market conditions enter these predefined statistical boundaries, the indicator overlays custom colored candlesticks beneath price bars on the chart. Traders can adjust the calculation periods, price source, moving average type, and standard deviation multipliers. The script includes standard alert conditions for entering or exiting fear and greed zones.

Details

Published by

krosenfeld7 on GitHub

Type

Indicator, Pine Script v4

Draws

On the price chart

Category

Volatility & bands, Mean reversion, Moving averages

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Low Periodint30lowPeriod
High Periodint30highPeriod
Stdev Periodint50stdev_period
Sourcesourceohlc4src
Use WMA instead of SMA?boolfalseWMA
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

This indicator plots trade entry and exit signals on the price chart by combining Bollinger Bands with optional filter conditions. It calculates standard Bollinger Bands along with RSI, Aroon, and moving average filters. Reversal signals trigger when price bre

Indicator v4 Volatility & bandsOscillators & momentum
Updated 2 months ago · None stated GitHub repository of Bollinger Bands Winner IND [Alorse]

Kalman Percentile Bands

by NQ-stats-MX
15 stars

Kalman Percentile Bands plots a volatility-adaptive Kalman mean along with three empirical percentile bands on each side of the price chart. It calculates a local-level Kalman filter as the fair value mean, normalizes price deviations by an EWMA of volatility,

Indicator v6 Mean reversionVolatility & bands
Updated 2 weeks ago · MIT GitHub repository of Kalman Percentile Bands
6 stars

This indicator classifies price action into four distinct market regimes: Trend, Expansion, Compression, or Mean Reversion. It determines states using a simplified Hurst exponent estimate, ADX slope thresholds, and realized volatility measurements. Based on th

Indicator v6 TrendVolatility & bands
Updated 8 weeks ago · MIT GitHub repository of Capital41 Regime Matrix v3
5 stars

Greeffer's Scalping Indicator overlays higher-timeframe exponential moving averages, Bollinger Bands, and Donchian channels on the price chart. It flags a long when price touches the lower Donchian and lower band while the faster averages are not stacked beari

Indicator v5 Moving averagesVolatility & bands
Updated 4 years ago · None stated GitHub repository of Greeffer's Scalping Indicator

Antigravity Elite

by eltonaguiar
4 stars

Antigravity Elite is an overlay indicator that screens price with seven selectable components: Mercury Fear, Connors RSI-2, volatility-spike reversal, EMA stack, Supertrend, multi-sigma bands, and an optional funding proxy. Auto-Detect chooses one method, whil

Indicator v6 Oscillators & momentumMoving averages
Updated today · None stated GitHub repository of Antigravity Elite

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers