Enhanced Bollinger Bands (EBB) + Dyn. Fun# Enhanced Bollinger Bands (EBB) + Dynamic Fun Character for TradingView
**Author:** Gemini AI (Conceptualized by a Senior SWE/FinAnalyst Persona)
**Date:** 2025-04-09
**Version:** 1.4
## Overview
This TradingView Pine Script indicator provides a significantly enhanced version of the standard Bollinger Bands (BB) combined with a fun, dynamic character element for at-a-glance visualization of the current price action.
It offers greater flexibility in calculating the Bollinger Bands by allowing user selection of the Moving Average type and price source. Additionally, it includes visual aids like volatility squeeze highlighting, band filling, and band cross labels, along with configurable alerts.
The unique "Dynamic Fun Character" feature displays an emoji next to the current real-time candle, changing its expression based on the candle's direction (up, down, or neutral), providing an intuitive visual cue for market sentiment on the very latest bar.
## Core Concepts
* **Bollinger Bands (BB):** A volatility indicator consisting of:
* **Basis Line:** A moving average (SMA, EMA, etc.) representing the middle price range.
* **Upper Band:** Basis Line + (Standard Deviations * Multiplier).
* **Lower Band:** Basis Line - (Standard Deviations * Multiplier).
* The bands widen during high volatility and narrow ("squeeze") during low volatility. Price tends to stay within the bands most of the time.
* **Average True Range (ATR):** A measure of market volatility. Used in this script to dynamically position the character label vertically and to determine the threshold for a "neutral" candle.
## Features
### Enhanced Bollinger Bands
1. **Selectable Moving Average Type:** Choose the MA type for the Basis Line:
* `SMA` (Simple Moving Average - Default)
* `EMA` (Exponential Moving Average - More weight to recent prices)
* `WMA` (Weighted Moving Average - Linear weight to recent prices)
* `HMA` (Hull Moving Average - Aims for less lag, smoother)
* `VWMA` (Volume Weighted Moving Average - Weights price by volume)
2. **Selectable Price Source:** Calculate bands based on various price points:
* `close` (Default)
* `high`, `low`, `open`
* `hl2` ( (high + low) / 2 )
* `hlc3` ( (high + low + close) / 3 )
* `ohlc4` ( (open + high + low + close) / 4 )
3. **Volatility Squeeze Highlight:** Automatically highlights the chart background (default: gray) when bandwidth (relative width of the bands) reaches a low point over a user-defined lookback period. Squeezes often precede significant price moves.
4. **Band Fill:** Optionally fills the area between the upper and lower bands with a semi-transparent color for better visualization of the volatility channel.
5. **Band Cross Labels:** Displays small triangles (▲ for up-cross, ▼ for down-cross) when the price closes outside the upper or lower band, highlighting potential breakout or reversal signals.
6. **Band Cross Alerts:** Configurable TradingView alerts can be triggered when the price crosses above the upper band or below the lower band.
7. **Bandwidth & %B Calculations:** The script calculates Bandwidth (`(Upper - Lower) / Basis`) and %B (`(Price - Lower) / (Upper - Lower)`) internally. While not plotted separately, these values are used for features like the squeeze detection and could potentially be used for strategy development.
### Dynamic Fun Character
1. **Sentiment Visualization:** Displays an emoji character next to the **current, real-time candle only**.
2. **Dynamic Expression:** The emoji changes based on the candle's formation:
* **😀 (Happy):** Candle is Green (`close > open`).
* **😞 (Sad):** Candle is Red (`close < open`).
* **😑 (Neutral):** Candle body (`abs(close - open)`) is very small compared to the Average True Range (ATR). Indicates low momentum or indecision for that specific bar.
3. **Adaptive Neutral Threshold:** The threshold for displaying the neutral face (😑) is based on a user-defined fraction of the current ATR, making it adaptive to market volatility.
4. **Customizable Appearance:**
* Position (X/Y Offset from the current candle).
* Size (Tiny, Small, Normal, Large, Huge - Default: Huge).
* Background Color (Default: Black).
* Text/Emoji Color (Default: White).
5. **Dynamic Tooltip:** Hovering over the character provides a simple text description of the current candle state ("Moving Up!", "Moving Down!", "Not much action.").
## How to Use / Interpretation
* **Volatility:** Watch the **band width**. Narrowing bands (especially with **Squeeze Highlights**) indicate consolidation and potential energy buildup for a larger move. Widening bands show increased volatility.
* **Trend Following:** In strong trends, prices may "walk the band" (consistently touch or slightly exceed the upper/lower band). The **Basis Line** often acts as dynamic support/resistance.
* **Mean Reversion Signals:** Price touching an outer band *without* extreme volatility *might* suggest an overbought/oversold state, potentially leading to a move back towards the **Basis Line**. Confirm with other factors.
* **Breakouts/Reversals:** Price closing outside the bands (indicated by **Cross Labels** and potentially **Alerts**), especially after a **Squeeze**, can signal the start of a new move. Look for confirmation (e.g., volume).
* **Dynamic Character:** Use the character for a quick visual check of the **current real-time candle's sentiment**. Is the latest price action bullish (😀), bearish (😞), or indecisive (😑)?
* **Context is Key:** **Never** rely on this indicator alone. Combine its signals with price action analysis, chart patterns, volume, other indicators (RSI, MACD, etc.), and robust risk management strategies.
## How to Add to TradingView
1. Open your TradingView chart.
2. Click on the "Pine Editor" tab at the bottom panel.
3. Copy the entire script code (`.pine` file content).
4. Paste the code into the Pine Editor, replacing any existing content.
5. Click "Add to Chart".
6. Adjust parameters via the indicator's "Settings" cog icon if needed.
## Input Parameters
Parameters can be adjusted in the indicator settings window.
### Moving Average Settings
* **Price Source:** (`srcInput`, Default: `close`) - Selects the price data source for all calculations.
* **BB Length:** (`lenInput`, Default: `20`) - Lookback period for MA and Standard Deviation.
* **MA Type:** (`maTypeInput`, Default: `SMA`) - Type of Moving Average for the Basis Line.
* **StdDev Multiplier:** (`multInput`, Default: `2.0`) - Multiplier for the Standard Deviation to set band width.
### Visual Settings
* **Show Band Fill:** (`showFillInput`, Default: `true`) - Toggles the color fill between bands.
* **Fill Color:** (`fillColorInput`, Default: `Blue, 85% transparency`) - Color for the band fill.
* **Upper Band:** (`upperColorInput`, Default: `Teal`) - Color of the upper band line.
* **Basis Line:** (`basisColorInput`, Default: `Orange`) - Color of the middle basis line.
* **Lower Band:** (`lowerColorInput`, Default: `Teal`) - Color of the lower band line.
### Volatility Squeeze Settings
* **Highlight Squeezes:** (`showSqueezeInput`, Default: `true`) - Toggles the background highlight during squeezes.
* **Squeeze Lookback:** (`squeezeLookbackInput`, Default: `50`) - How many bars back to check for the lowest bandwidth to define a squeeze.
* **Squeeze Color:** (`squeezeColorInput`, Default: `Gray, 80% transparency`) - Background color during a squeeze.
### On-Chart Labels
* **Show Band Cross Labels:** (`showLabelsInput`, Default: `true`) - Toggles the ▲/▼ labels on band crosses.
* **Label Size:** (`labelSizeInput`, Default: `Small`) - Size of the ▲/▼ cross labels.
* **Up-Cross Label Color:** (`upCrossColorInput`, Default: `Green`) - Color for the ▲ label.
* **Down-Cross Label Color:** (`dnCrossColorInput`, Default: `Red`) - Color for the ▼ label.
### Alert Settings
* **Alert on Upper Band Cross:** (`alertCrossUpperInput`, Default: `false`) - Enable condition for alerts when price crosses above the upper band.
* **Alert on Lower Band Cross:** (`alertCrossLowerInput`, Default: `false`) - Enable condition for alerts when price crosses below the lower band.
### Fun Character Settings
* **Show Dynamic Character:** (`showCartoonInput`, Default: `true`) - Toggles the dynamic emoji character on/off.
* **Neutral Threshold (ATR Fraction):** (`littleMoveThresholdInput`, Default: `0.15`) - If candle body size < (this fraction * ATR), show Neutral face (😑).
* **Character X Offset (Bars):** (`cartoonXOffsetInput`, Default: `2`) - Horizontal offset (in bars) from the current candle.
* **Character Y Offset (ATR):** (`cartoonYOffsetMultInput`, Default: `0.5`) - Vertical offset (as a multiple of ATR) from the current candle's high.
* **Character Size:** (`cartoonSizeInput`, Default: `Huge`) - Size of the emoji character.
* **Character BG Color:** (`cartoonColorInput`, Default: `Black`) - Background color of the character label.
* **Character Text Color:** (`cartoonTextColorInput`, Default: `White`) - Color of the emoji text itself.
## Changelog
* **v1.4 (2025-04-09):** Replaced blinking character logic with dynamic face based on candle movement (Up 😀 / Down 😞 / Neutral 😑). Added ATR-based threshold input for neutral state.
* **v1.3 (2025-04-09):** Increased default character size to `size.huge`.
* **v1.2 (2025-04-09):** Changed default character background color to black and text color to white for better contrast.
* **v1.1 (2025-04-09):** Added optional blinking cartoon character next to the current candle.
* **v1.0 (2025-04-09):** Initial release - Enhanced Bollinger Bands with selectable MA/Source, squeeze highlighting, band fill, cross labels, and alerts.
## Disclaimer
This indicator is provided for informational and educational purposes only. It does not constitute financial advice or a recommendation to buy or sell any asset. Trading financial markets involves significant risk, and you could lose your capital. Always perform your own due diligence and consult with a qualified financial advisor before making any trading decisions. Past performance is not indicative of future results. The author is not responsible for any trading losses incurred using this indicator.
FUN
Tic Tac Toe Game [TradeDots]Feeling bored with trading?
Time to inject some fun into your decision-making process with our Tic Tac Toe Indicator!
The Tic Tac Toe game transforms your chart into a competitive playground where trading pairs face off in a classic game of Tic Tac Toe.
HOW TO PLAY
Our Tic Tac Toe game invites you to pit one trading pair against another directly on your chart. Choose the competitors and watch as they battle it out in a traditional grid setup.
Navigate to settings and select your competitor pair.
Choose who kicks off the game.
After the close of each new bar, the algorithm will utilize the closing prices of both symbols. These numbers feed into a random number generator which alternates the turns for placing marks on the grid.
The game progresses until one pair aligns three consecutive symbols and wins, or the board fills up. After that, the game resets every three bars, offering continual engagement during active market hours.
MANUAL PLAYING MODE
Currently, due to PineScript's limitations, a fully interactive manual mode is not supported, as all previous data will be lost with each new user input, preventing the replication of existing game states.
However, users can input a sequence at the start, guiding the placement of symbols throughout the game.
Stay tuned for future updates!
Daily Chess Puzzles [LuxAlgo]Play Chess Puzzles right on your Chart!
Daily Chess Puzzles brings you a new 1-Move chess puzzle straight to your chart every day.
🔶 USAGE
Submit your answer to see if your solution is correct! For quick access to the settings, Double-Click on the Chess board to open the settings interface.
The current active color (Who's move it is) is represented by the color of the information bar, and the corner board squares.
This game uses long algebraic notation without pieces names for submitting moves.
This method for determining moves is perfect for simplicity and clarity, and is standard for the Universal Chess Interface (UCI).
🔹 How to Notate
Long algebraic notation (without pieces name) is simple to understand. This notation does not use capture symbols or check/checkmate symbols; it uses only the squares involved in the move and any promotion occurring.
{Starting Square}{Ending Square}{Promotion Piece(if needed)}
Locate the starting square and the ending square of the piece being moved, without mentioning the piece itself.
Identify the column letters (a-h) and row numbers (1-8) that align with your desired move.
If a pawn reaches the opposite end of the board the pawn gets promoted, add the letter representing the piece it is promoted to at the end of the move.
Put it all together and you've got your notation!
Piece Notations for Pawn Promotions:
'n' for Knight ('k' is reserved for the King in chess notation)
'b' for Bishop
'r' for Rook
'q' for Queen
Normal Move Example: Moving a piece from e2 to e4 is notated as "e2e4".
Pawn Promotion Example: Promoting a pawn to a queen is notated as "e7e8q".
🔶 DETAILS
Miss a day? Yesterday's puzzle can be re-played, check the box for 'View Yesterday's Puzzle' in the settings.
This indicator makes use of Tooltips! . Hover over a square to see that square's notation.
This script makes use of 5 libraries, each storing 2 years worth of daily chess puzzles amounting to 10 years of unique daily chess puzzles.
"timenow" is used to determine which day it is, so even on a closed ticker or weekend or holiday a new chess puzzle will be displayed.
Users have the option to choose from 5 different board themes.
Gamification IndicatorDo you want your charts to look like a video game? Look no further! Would you rather be an alien racing through a lava tube, a surfer with great white sharks, an airplane flying through the clouds, or some other custom emoji setup of your choice? Traders can choose their own custom player emoji, trend indicator, obstacle emoji, and celestial emoji. This indicator is just for fun and is not intended to be used when making trading decisions. Enjoy!
This indicator also contains a live sun/moon emoji that should accurately reflect day/night and can give information about the current moon phases.
Shoutout to @citlacom for the public Moon Ephemeris and calculations. Building this indicator was a useful & fun introduction to financial astrology in Pinescript.
Momentum Sparkler (MS)Introduction:
In this script, we will be creating an indicator called "Momentum Sparkler" that plots lines on the chart to visualize the momentum of the given source.
Explanation:
First, we define the input "Source" as the source for the data to be plotted, and the input "Length" as an integer determining the number of lines to plot.
We then create an array called "lines" to store the lines we will be plotting.
Using an if statement, we check if the current bar is the last bar in the chart. If it is, we use a for loop to iterate through the range of the "Length" input and add a line to the "lines" array for each iteration. The color of each line is determined by a color gradient, with the first line being the most red and the last line being the most green.
Next, we use another if statement to check if the current bar is confirmed. If it is, we use a for loop to iterate through the "lines" array and delete all the lines. This is to prevent the lines from being carried over to the next bar and potentially being plotted multiple times.
Conclusion:
This script can be useful for quickly visualizing the momentum of the given source and identifying potential trends or reversals. It can be helpful for making trading decisions or for adding an additional layer of analysis to a chart.
Color Palette OptionsA quick, easy way to swap out colour palettes. Simple cosmetic, but charts are allowed to be fun too!
X-Mas TreeLet's play a game!! Find your Christmas Tree and post it in the comments.
How to use the script?
Open any instrument which best describes the Christmas Tree (Preferably on hourly timeframe).
Apply X-Mas Tree script on the chart.
Enjoy the snowfall, changes in lightings and other animations. Animations only happen if the instrument is in trading session. So, stocks and indexes do not work on weekends and holidays. Use crypto as they are traded 24X7.
Unfortunately cannot post moving charts. But, snapshot of chart will do :)
Well, Please don't ask these questions for this script (Also thanks to @Bjorgum for contributing to this section) 😃
Can you please add alerts?
Does it repaint?
Can we use this for crypto/stock/forex bla bla?
Can you convert this to strategy?
How can I access this indicator?
Can you please give access or how much does it cost?
Can you make it available for MTF?
Indicator is broken. Getting so and so error message etc.
Wish you all MERRY X-MAS and HAPPY NEW YEAR!!
watermarkJust for fun... watermark graphics! The steps are:
1. Choose an image, probably no more than 20x20 pixels
2. Use an image library to convert each pixel into a table cell, as shown in the script.
I used they Python "pillow" library for step 2. This library allows you to iterate over each pixel, grab the RGB value, and generate table cells. You can use the width/height attributes of each cell to size the watermark.
Be careful, because Pinescript has a maximum character limit around 60,000 or so, and this script will reach that limit quickly. You also run into some limitation on table size, I think. That's why I suggest using no more than a 20x20 image.
Pictured in this chart is a legendary trader... message me if you would like to commission your own watermark.
watermark_asciiJust for fun... You can make an ascii watermark! The steps are:
1. Convert an image into ascii, e.g. using an online generator.
2. Split the ascii into strings that are no more than 4096 characters (pinescript limit).
3. Stack them together as cells on a table (as shown in the script).
I use code generation for step 2, by splitting the ascii file into chunks, then joining each line with a plus sign to make a large string concatenation statement, which I manually copy/paste into pine. Ideally, you could make this whole script into a template with a couple parameters.
Unfortunately, Pinescript doesn't use a monospaced font, so there will be some distortion. Feature request!
DEMO ASCII Encode/DecodeDemo
Encode a string to an ascii array and decode the ascii array to a string.
Reads ascii 32 to 126.
Takes a long time to execute. You may get the "Loop is too long (> 200 ms)" execution error.
You can change the loop to iterate fewer times thereby shorten the string length.
OR
you can limit the characters converted.
THIS IS AN ABSOLUTE KLUDGE.
Just showing how to do this.
Rate Pine ScriptWhat do you think of Pine Script?
Here's your chance to let off some steam if your frustrated with the limitations of Pine Script.
This script stores a text string in a array.
Unfortunately tradingview doesn't think anything useful can be done with strings.
This is merely a demo of storing a string in an array. There currently seems to be no way to get an input.string and parse it.
What do you think of Pine Script?
Here's your chance to let off some steam if your frustrated with the limitations of Pine Script.
RAINBARSJust take a hit of LSD and ride the trend. I was messing around with generating colors. I used a simple python script which helps with generating tradingview code blocks and loops.