ClarityTrend SwiftEdge# TrendSync Indicator
## Overview
The TrendSync Indicator is a powerful tool designed to help traders identify high-probability trading opportunities by combining two proven technical analysis methods: Linear Regression-based candlesticks and an ATR-based trailing stop strategy (UT Bot Alerts). This indicator enhances these components with unique features, including candlestick smoothing for improved visual clarity and signal reinforcement to reduce noise, making it ideal for trend-following and swing trading across various markets and timeframes.
## Originality and Purpose
This indicator merges the strengths of Linear Regression Candles and UT Bot Alerts to create a synergistic approach to trend detection:
- **Linear Regression Candles** use linear regression to smooth price data, producing candlesticks that highlight the underlying trend while filtering out market noise. This helps traders visualize trend direction more clearly.
- **UT Bot Alerts** employ an ATR-based trailing stop to generate dynamic buy and sell signals, adapting to market volatility and identifying key reversal points.
- **Unique Contributions**:
- **Candlestick Smoothing**: Added an optional SMA or EMA-based smoothing feature to make candlesticks visually cleaner and easier to interpret, especially in volatile markets.
- **Signal Reinforcement**: Introduces a filter that only displays buy/sell signals when both Linear Regression Candles and UT Bot Alerts confirm the same trend direction, reducing false signals and improving reliability.
The combination is purposeful: Linear Regression Candles provide a smoothed trend context, while UT Bot Alerts pinpoint precise entry and exit points. The reinforcement feature ensures that only the strongest signals are shown, enhancing decision-making for traders.
## How It Works
### Linear Regression Candles
- The indicator applies linear regression to OHLC (open, high, low, close) prices over a user-defined period (default: 11 bars) to create smoothed candlesticks.
- Bullish candlesticks (green) are plotted when the smoothed open is below the smoothed close, and bearish candlesticks (red) when the open is above the close.
- An optional smoothing layer (SMA or EMA, default length: 5 bars) can be applied to further reduce noise, making trends visually clearer.
- A signal line (SMA or EMA, default length: 11 bars) tracks the smoothed close price to highlight the overall trend direction.
### UT Bot Alerts
- Uses an ATR-based trailing stop (default ATR period: 10 bars, sensitivity: 1) to generate buy and sell signals.
- A buy signal is triggered when the price crosses above the trailing stop, and a sell signal when it crosses below, confirmed by a 1-period EMA crossover.
- Optionally, signals can be based on Heikin Ashi close prices (manually calculated) for smoother trend detection.
### Signal Reinforcement
- When enabled (default: true), buy signals are only shown if the Linear Regression Candles are bullish, and sell signals if they are bearish. This ensures alignment between the trend context and signal triggers, reducing false positives.
### Visuals
- **Candlesticks**: Semi-transparent green (bullish) and red (bearish) candlesticks for clear trend visualization.
- **Signal Line**: A white line (thicker for visibility) showing the smoothed trend.
- **Signals**: Large "BUY" (green) and "SELL" (red) labels below/above bars for easy identification.
- **Bar Coloring**: Green bars for bullish UT Bot conditions, red for bearish, enhancing trend awareness.
## How to Use
1. **Add to Chart**: Apply the TrendSync Indicator to any chart in TradingView.
2. **Configure Inputs** (accessible via the indicator’s settings):
- **LinReg Settings**:
- *Signal Smoothing (default: 11)*: Length of the signal line (SMA or EMA).
- *Use SMA for Signal Line*: Toggle between SMA (checked) or EMA (unchecked).
- *Enable Linear Regression (default: true)*: Turn on/off linear regression for candlesticks.
- *Linear Regression Length (default: 11)*: Period for linear regression calculation.
- *Smooth Candlesticks (default: false)*: Enable smoothing for cleaner candlesticks.
- *Candlestick Smoothing Length (default: 5)*: Period for SMA/EMA smoothing.
- *Smoothing Type (default: SMA)*: Choose SMA or EMA for candlestick smoothing.
- **UT Bot Settings**:
- *Key Value (Sensitivity, default: 1)*: Adjusts the ATR multiplier for the trailing stop. Higher values widen the stop, reducing signals.
- *ATR Period (default: 10)*: Period for ATR calculation.
- *Use Heikin Ashi for Signals (default: false)*: Use Heikin Ashi close prices for UT Bot signals.
- **Signal Settings**:
- *Reinforce Signals (default: true)*: Only show signals when LinReg and UT Bot agree.
3. **Interpret Signals**:
- **BUY**: A green "BUY" label below a bar indicates a potential long entry, especially strong when reinforced.
- **SELL**: A red "SELL" label above a bar indicates a potential short entry.
- Use the signal line and candlestick colors to confirm the trend context.
4. **Set Alerts**:
- Create alerts for "TrendSync Long" (buy) and "TrendSync Short" (sell) to receive notifications when reinforced signals occur.
## Best Practices
- **Timeframes**: Works on all timeframes, but 1H-4H charts are recommended for swing trading, and 5M-15M for scalping.
- **Markets**: Suitable for stocks, forex, crypto, and commodities. Test on your preferred market to optimize settings.
- **Settings Optimization**:
- Increase `Candlestick Smoothing Length` (e.g., 7-10) for volatile markets to reduce noise.
- Adjust `Key Value` (e.g., 0.5-2) to balance signal frequency and reliability.
- Disable `Reinforce Signals` for more frequent signals, but expect potential noise.
- **Confirmation**: Combine with other tools (e.g., support/resistance, volume) for better trade validation.
## Credits
- **Original Scripts**: Built upon "Humble LinReg Candles" and "UT Bot Alerts" from TradingView’s public library.
- **Enhancements by **: Developed candlestick smoothing, signal reinforcement, and custom visuals to create a unique, trader-friendly tool.
## License
MIT License: Free to use, modify, and share, provided original credits are retained.
## Disclaimer
This indicator is for educational and informational purposes only and should not be considered financial advice. Always conduct your own research and test strategies before trading.
Moving Averages
RSIOMA IndicatorI trust the RSIOMA by itself when I am at work, on the road, at play, and using only my cell phone.
When I find the long, high plateau or the bottom river bed, my attention perks up.
I examine the nearby timeframes to see if there are any similar patterns.
Please don't use any of the middle crosses; they don't have the power out of the gate that the flat ones do.
I wait and wait for the smaller timeframe to make its cross and add one position.
At every pullback, I start adding positions. Each of you needs to become comfortable with this indicator and start trusting it first.
I am guilty of fading this flat top or bottom, but they can go forever, it seems.
But then that 200-point bar drops, and all the pain goes away with a considerable profit.
I reset and start scanning other charts for the same.
Renko Trend Reversal StrategyThis Pine Script implements a simple Renko-based trend reversal trading strategy for TradingView. Here’s what it does, broken down clearly:
🔍 Purpose
The script is a strategy (not just an indicator) designed to simulate trading based on Renko-style trend changes, using smoothed price data to detect entries and exits.
🧠 How It Works
1. Trend Detection Using SMAs
It uses two simple moving averages (SMAs) to simulate a Renko-like trend signal:
renko_trend = ta.sma(close, 2) > ta.sma(close, 10) ? 1 : -1
If the short-term SMA (2) is above the long-term SMA (10), the trend is considered bullish (1).
If below, it's bearish (-1).
2. Trend Reversal Detection
A trend change is detected using:
trend_change = ta.change(renko_trend)
It checks if the renko_trend has flipped since the previous candle.
3. Trade Entry Conditions
A long trade is entered when the trend changes to bullish.
A short trade is entered when the trend changes to bearish.
if long_condition
strategy.entry("Long", strategy.long)
if short_condition
strategy.entry("Short", strategy.short)
4. Exit Conditions
Exits are handled using a trailing stop:
strategy.exit(..., trail_points = 50, trail_offset = 20)
A trailing stop loss of 50 points is used, activating only after the price moves 20 points in favor of the trade.
📈 Visualization
It plots the current trend (1 or -1) on the chart as a blue line, which helps you see trend direction changes visually.
⚙️ Strategy Settings
Uses 10% of equity per trade (default_qty_value = 10).
Works on regular candlestick charts, but mimics a Renko-style trend-following behavior.
✅ Summary
This strategy:
Enters trades on trend reversals based on short-term vs. long-term SMA crossover.
Uses trailing stops for exits.
Mimics Renko behavior without using real Renko bricks—just SMA-based smoothing.
HMA 200 + EMA 20 Crossover StrategyThis strategy combines a long-term trend filter using the Hull Moving Average (HMA 200) with a short-term entry trigger using the Exponential Moving Average (EMA 20).
📈 Entry Logic:
Buy Entry: When price is above the HMA 200 and crosses above the EMA 20.
Sell Entry: When price is below the HMA 200 and crosses below the EMA 20.
The strategy closes the current position and reverses on the opposite signal.
⚙️ Strategy Settings (Backtest Configuration):
Position size: 10% of equity per trade
Commission: 0.1% per trade (to simulate broker fees)
Slippage: 2 ticks (to reflect realistic fill conditions)
✅ Purpose:
This script is designed to identify high-probability trades in the direction of the overall trend, avoiding whipsaw conditions. It is useful for traders looking for a dynamic crossover-based system that filters trades based on longer-term momentum.
🔎 Make sure to test across multiple assets and timeframes. For best results, apply this strategy to liquid trending markets like major FX pairs, indices, or high-cap stocks.
EMA 5/10 Crossover SignalsThis indicator measures the moving average of 5 and 10 and indicates the sell and buy signal
Moving Average Channel Avancé# Moving Average Channel Avancé (MAC)
This versatile TradingView indicator provides a dynamic channel around a central moving average, offering a comprehensive tool for trend identification, volatility assessment, and potential entry/exit signals.
## Key Features:
* **Flexible Moving Average Core:** Choose from a variety of popular moving average types (SMA, EMA, WMA, VWMA, HMA, TEMA) to serve as the baseline for your channel. Customize the length and price source for tailored analysis.
* **Multiple Channel Calculation Methods:**
* **Standard Deviation:** Creates Bollinger Band-like channels based on price volatility.
* **ATR (Average True Range):** Generates Keltner Channel-style bands that adapt to market volatility.
* **Percentage:** Defines channel width as a fixed percentage of the moving average.
* **Donchian:** Uses highest highs and lowest lows over a specified period to form the channel.
* **Visual Customization:**
* Toggle visibility of the midline, channel fill, and breakout signals.
* Full color customization for upper/lower bands, midline, channel fill, and bullish/bearish breakout signals.
* **Breakout Signals:** Displays arrows when the price crosses above the lower band (potential buy) or below the upper band (potential sell).
* **Overbought/Oversold Visualization:** Bar coloring highlights potential overbought (price near upper band) and oversold (price near lower band) conditions.
* **Information Panel:** A convenient on-chart table displays the selected MA type and the current price position within the channel as a percentage.
* **Alert Conditions:** Set up alerts for:
* Price crossing above/below the upper band.
* Price crossing above/below the lower band.
* Overbought and oversold conditions.
## How to Use:
The Moving Average Channel Avancé can be used in various ways:
* **Trend Following:** Trade in the direction of the channel. When the price is consistently above the midline and respecting the lower band as support, it can indicate an uptrend. Conversely, price action below the midline, with the upper band acting as resistance, can suggest a downtrend.
* **Volatility Breakouts:** Look for price breakouts above the upper band or below the lower band as potential entry signals, especially when accompanied by increased volume.
* **Mean Reversion:** In ranging markets, prices may tend to revert towards the central moving average after touching the outer bands.
* **Support and Resistance:** The channel bands can act as dynamic levels of support and resistance.
This indicator is designed to be intuitive for novice traders while offering the depth of customization that experienced analysts require. Experiment with different settings and MA types to find what best suits your trading style and the specific market you are analyzing.
Moving Average + Distance BandsDistance from moving average bands, shows the distance from the moving average
RSI-WMA + EMA Trend Filter | Signal OnlyThis is the specialized Indicator to create the internal Strategy for the class of Rio & Friend base on RSI-WMA with the EMA Trend Filter.
Enjoy and have fun with it!
EMA 5/10 Crossover SignalsThis indicator measures the 5-day and 10-day moving average and shows the buy and sell sign
Support BandsSupport Bands – Discount Zones for Bitcoin
⚡Overview:
-The Support Bands indicator identifies one of the most tested and respected support zones for Bitcoin using moving averages from higher timeframes.
-These zones are visualized through colored bands (blue, white, and violet), simplifying the decision making process especially for less experienced traders who seek high-probability areas to accumulate Bitcoin during retracements.
-Band levels are based on manual backtesting and real-world price behavior throughout Bitcoin’s history.
-Each zone reflects a different degree of support strength, from temporary pullback zones to historical bottoms.
⚡️ Key Characteristics:
-Highlights discount zones where Bitcoin has historically shown strong reactions.
-Uses 3 different levels of supports based on EMA/SMA combinations.
-Offers a clean, non-intrusive overlay that reduces chart clutter.
⚡ How to Use:
-Open your chart on the 1W timeframe and select the BTC Bitstamp or BLX symbol, as they provide the most complete historical data, ensuring optimal performance of the indicator.
-Use the bands as reference zones for support and potential pullbacks.
- Level 3 (violet band) historically marks the bottom of Bitcoin bear markets and is ideal for long-term entries during deep corrections.
- Level 2 (white band) often signals macro reaccumulation zones but usually requires 1–3 months of consolidation before a breakout. If the price closes below and then retests this level as resistance for 1–2 weekly candles, it often marks the start of a macro downtrend.
-Level 1 (blue band) acts as short-term support during strong bullish moves, typically after a successful rebound from Level 2.
⚡ What Makes It Unique:
- This script merges moving averages per level into three simplified bands for clearer analysis.
-Reduces chart noise by avoiding multiple overlapping lines, helping you make faster and cleaner decisions.
- Built from manual market study based on recurring Bitcoin behavior, not just random code.
-Historically backtested:
-Level 3 (violet band) until today has always marked the bitcoin bearmarket bottom.
- Level 2 (white band) is the strongest support during bull markets; losing it often signals a macro trend reversal.
- Level 1 is frequently retested during impulsive rallies and can act as short-term support or resistance.
⚡ Disclaimer:
-This script is a visual tool to assist with market analysis.
-It does not generate buy or sell signals, nor does it predict future movements.
-Historical performance is not indicative of future results.
-Always use independent judgment and proper risk management.
⚡ Why Use Support Bands:
-Ideal for traders who want clarity without dozens of lines on their charts.
- Helps identify logical zones for entry or reaccumulation.
- Based on actual market behavior rather than hypothetical setups.
-If the blue band (Level 1) doesn't hold as support, the price often moves to the white band (Level 2), and if that fails too, the violet band (Level 3) is typically the last strong support. By dividing your capital into three planned entries, one at each level,you can manage risk more effectively compared to entering blindly without this structure.
RSI-WMA + EMA Trend Filter | Signal OnlyThis is the specialized indicator representing the internal strategy created by RIO for the Trading Career 2025 Class.
Enjoy and have fun by using it if you feel the option being suitable for your trading!
EMA Breakdown Strategytake sell position when price crosses below ema take a short position when price crosses below green candel low target size of green candle SL high of green candel RR 1:1
Grid + Trade Annotations & Liquidations## Introducing the “Grid + Trade Annotations & Liquidations” Pine Script Strategy
Imagine you could overlay a perfectly-spaced price grid on your favorite chart, backtest a simple moving-average crossover, see exactly where trades would have fired off in the past—and even know at what price you’d have been liquidated if you were running at 10× leverage. That’s exactly what this all-in-one TradingView **Pine Script® v6** strategy delivers.
### Why you’ll love it
* **Visual clarity:** A fixed-interval horizontal grid, centered on each bar’s close, helps you instantly spot round-number levels (e.g. every \$0.50).
* **Trade annotations:** Every historical entry/exit is automatically marked with arrows and labels—no more scrolling through Trade History.
* **Liquidation lines:** For each entry, the script computes your theoretical liquidation price, based on your chosen leverage, and draws it as a dashed line.
* **Performance metrics:** Total return, maximum drawdown, Sharpe ratio, and win rate are calculated and displayed on-chart, so you don’t have to wrestle with spreadsheets.
---
## How it’s structured
The code lives in a single **strategy**—add it via **Pine Editor → New Strategy** and click **Add to Chart**. Internally, it’s broken into four main sections:
1. **Grid setup:**
* **Inputs:** `gridStep`, `aboveLines`, `belowLines`, `gridColor`, `gridStyle`, `gridWidth`.
* **Persistent array:** stores `line` objects so they survive bar updates.
* **Draw/update logic:** on each confirmed historical bar, the script either recreates all lines (when you change the count) or simply repositions them around the new close.
2. **Entry/exit logic & annotations:**
* **Example system:** 20-period vs. 50-period simple moving-average crossover.
* **Labels & shapes:**
* Green triangles for long entries/exits, red for short.
* A “Long Liq:” or “Short Liq:” label at the point of entry.
3. **Liquidation calculations:**
* **Formula:**
* Long: `P_liq = P_entry × (1 − 1⁄L)`
* Short: `P_liq = P_entry × (1 + 1⁄L)`
* Let the script draw a dashed red (for longs) or dashed green (for shorts) line at each `P_liq`.
4. **Performance metrics:**
* **Built-ins:**
* `strategy.netprofit_percent` → total return %
* `strategy.max_drawdown_percent` → max drawdown %
* `strategy.wintrades` / `strategy.closedtrades` → win rate %
* **Sharpe ratio:** manually computed from per-bar returns, assuming a user-defined risk-free rate and bars-per-year count.
---
## Using & customizing the strategy
1. **Add to your chart.**
* Copy the full script into Pine Editor, select **Strategy**, and hit **Add to Chart**.
2. **Tune your grid.**
* **`Grid Interval ($)`**: e.g. `0.50` for \$0.50 steps.
* **`Lines Above`/`Below`**: how many lines to show on each side of the current price.
* **`Grid Style`**: choose Solid, Dashed, or Dotted; set line width and opacity via the color picker.
3. **Adjust your trading logic.**
* Out of the box, the script uses SMA(20) vs. SMA(50). Swap in any `ta.*` indicator calls you like.
4. **Set leverage & capital.**
* **`Leverage`**: affects the liquidation price.
* **`Initial Capital`** and **`Order Size`**: the strategy uses 100% of equity per trade by default—you can change that in the `strategy()` call.
5. **Review performance.**
* Metrics show up in the Strategy Tester and on-chart label.
* If you want data in the Data Window, expand the script’s name to see the hidden plots for return, drawdown, Sharpe, and win rate.
---
## Behind the code
Below is a high-level walkthrough of the key snippets:
```pinescript
//@version=6
strategy("Grid + Annotations & Liquidations", overlay=true,
initial_capital=100000, default_qty_type=strategy.percent_of_equity,
default_qty_value=100)
// ─ Grid inputs & style mapping ────────────────────────────────────────
gridStep = input.float(0.50, "Grid Interval ($)", minval=0)
aboveLines = input.int(5, "Lines Above", minval=0)
belowLines = input.int(5, "Lines Below", minval=0)
gridColor = input.color(color.new(color.gray, 80), "Grid Color")
gridStyle = input.string("Dashed", "Grid Style", options= )
gridWidth = input.int(1, "Grid Line Width", minval=1, maxval=5)
gridStyleConst = gridStyle == "Solid" ? line.style_solid :
gridStyle == "Dotted"? line.style_dotted :
line.style_dashed
```
* We map a simple string choice into Pine’s `line.style_*` constants.
* `gridStep` drives the spacing in dollars.
```pinescript
// Persist & update lines only when needed
var line gridLines = array.new_line()
if barstate.islastconfirmedhistory
total = aboveLines + belowLines + 1
if array.size(gridLines) != total
// delete & recreate
…
else
// only reposition
…
```
* Wrapping all drawing in `barstate.islastconfirmedhistory` avoids repaint issues.
* The script deletes and rebuilds lines only when you change `aboveLines`/`belowLines`, otherwise it simply moves them.
```pinescript
// MA crossover logic & liquidation labels
fast = ta.sma(close, 20)
slow = ta.sma(close, 50)
if ta.crossover(fast, slow)
strategy.entry("Long", strategy.long)
liq = close * (1 - 1.0 / leverage)
label.new(bar_index, low, text="Long Liq: " + str.tostring(liq))
line.new(…, y1=liq, y2=liq, color=color.red, style=line.style_dashed)
```
* Entries trigger both the `strategy.entry` call and a pair of visual cues: a label and a dashed line at the computed liquidation price.
```pinescript
// Performance metrics: draw from built-ins + manual Sharpe
totalRet = strategy.netprofit_percent
maxDD = strategy.max_drawdown_percent
winRate = strategy.closedtrades > 0 ?
(strategy.wintrades / strategy.closedtrades)*100 : 0
// Manual Sharpe calculation
… accumulate per-bar % returns … compute mean, stddev … apply formula …
```
* TradingView gives us return, drawdown, and trade counts out of the box.
* We calculate Sharpe ourselves so you can adjust the risk-free rate and periods per year.
---
## Wrapping up
This one-file strategy is designed to be both **educational** and **practical**:
* **Learn by reading:** every section is commented so you can see how Pine v6 handles arrays, loops, strategy functions, and labels.
* **Customize for your edge:** swap in your own indicators, change leverage, or hook up alerts.
* **Publish & share:** drop it into your public repo with this story as your README, and fellow traders will know exactly how to use it.
Feel free to fork, file issues, or submit pull requests. Happy charting—and may your grid lines always align!
Virgil EMA10,20,50,200This indicator shows us the moving average on. 10 days 20 days. 50 days and 200 days
SMA ExtensionsExplanation of the SMA Extensions Indicator
The SMA Extensions indicator, designed for TradingView, overlays a 200-period Simple Moving Average (SMA) and its extensions (1.5x, 2x, 2.5x, 3x) on the price chart to identify price zones. Users can customize the SMA source, length, and line colors (default: blue, green, yellow, orange, red). Each level is plotted as a line, with transparent colored fills between them and below the SMA to highlight zones. Labels ("Very Cheap," "Cheap," "Fair Value," "Expensive," "Very Expensive") appear only on the last bar, slightly right-shifted, matching line colors for clarity. This helps traders assess whether prices are undervalued or overvalued relative to the SMA.
The idea originated from a video from the YouTube channel Crypto Currently
(DAFE) DEVMA - Crossover (Deviation Moving Average) (DAFE) DEVMA - Crossover (Deviation Moving Average)
Let’s keep pushing the edge. After the breakthrough of Deviation over Deviation (DoD)—which gave traders a true lens into volatility’s hidden regime shifts—many asked: “What’s next?” The answer is DEVMA: a crossover engine built not on price, but on the heartbeat of the market itself.
Why is this different?
DEVMA isn’t just a moving average crossover. It’s a regime detector that tracks the expansion and contraction of deviation—giving you a real-time readout of when the market’s energy is about to shift. This is the next step for anyone who wants to anticipate volatility, not just react to it.
What sets DEVMA apart:
Volatility-First Logic: Both fast and slow lines are moving averages of deviation, not price. You’re tracking the market’s “energy,” not just its direction. This is the quant edge that most scripts miss.
Regime-Colored Lines:
The fast and slow DEVMA lines change color in real time—green/aqua for expansion, maroon/orange for contraction—so you can see regime shifts at a glance.
Quant-Pro Visuals:
Subtle glow, clean cross markers, and a minimalist dashboard keep your focus on what matters: the regime, not the noise.
Static Regime Thresholds:
Reference lines at 1.5 and 0.5 (custom colors) give you instant context for “normal” vs. “extreme” volatility states.
No Price Chasing:
This isn’t about following price. It’s about anticipating the next volatility regime—before the crowd even knows what’s coming.
How this builds on DoD:
DoD showed you when volatility itself was about to change. DEVMA takes that insight and turns it into a crossover engine—so you can see, filter, and act on regime shifts in real time. If DoD was the radar, DEVMA is the navigation system.
Inputs/Signals—explained for clarity:
Deviation Lookback:
Controls the sensitivity of the regime detector. Shorter = more signals, longer = only the rarest events.
Fast/Slow DEVMA Lengths:
Fine-tune how quickly the regime lines react. Fast for scalping, slow for swing trading.
Source Selection:
Choose from price, volume, volatility, or VoVix. Each source gives you a different lens on market stress. VoVix is for those who want to see the “regime quake” before the aftershocks.
VoVix Parameters:
Fine-tune the volatility-of-volatility engine for your market. Lower ATR Fast = more responsive; higher ATR Slow = more selective.
Bottom line:
DEVMA is for those who want to see the market’s heartbeat, not just its shadow. Use it to filter your trades, time your entries, or simply understand the market’s true rhythm. Every input is there for a reason. Every plot is a direct readout of the quant logic. Use with discipline, and make it your own.
Disclaimer:
Trading is risky. This script is for research and informational purposes only, not financial advice. Backtest, paper trade, and know your risk before going live. Past performance is not a guarantee of future results.
To TradingView mods and serious users:
This isn’t just another indicator. This is a quant tool for the next era. If flagged, we’ll keep adapting and republishing until real quant innovation gets its place.
Use with discipline. Trade your edge.
— Dskyz, for DAFE Trading Systems
Davsabs 10-20-50 EMA strategyThis is a 10-20-50 day EMA strategy.
Buy signals are generated on price being over the 50 EMA, 10 EMA over the 20 EMA.
Sell signals are generated when price closed below the 10 ema
Functionally Weighted Moving AverageOVERVIEW
An anchor-able moving average that weights historical prices with mathematical curves (shaping functions) such as Smoothstep , Ease In / Out , or even a Cubic Bézier . This level of configurability lends itself to more versatile price modeling, over conventional moving averages.
SESSION ANCHORS
Aside from VWAP, conventional moving averages do not allow you to use the first bar of each session as an anchor. This can make averages less useful near the open when price is sufficiently different from yesterdays close. For example, in this screenshot the EMA (blue) lags behind the sessionally anchored FWMA (yellow) at the open, making it slower to indicate a pivot higher.
An incrementing length is what makes a moving average anchor-able. VWAP is designed to do this, indefinitely growing until a new anchor resets the average (which is why it doesn't have a length parameter). But conventional MA's are designed to have a set length (they do not increment). Combining these features, the FWMA treats the length like a maximum rather than a set length, incrementing up to it from the anchor (when enabled).
Quick aside: If you code and want to anchor a conventional MA, the length() function in my UtilityLibrary will help you do this.
Incrementing an averages length introduces near-anchor volatility. For this reason, the FWMA also includes an option to saturate the anchor with the source , making values near the anchor more resistant to change. The following screenshot illustrates how saturation affects the average near the anchor when disabled (aqua) and enabled (fuchsia).
AVERAGING MATH
While there's nothing special about the math, it's worth documenting exactly how the average is affected by the anchor.
Average = Dot Product / Sum of Weights
Dot Product
This is the sum of element-wise multiplication between the Price and Weight arrays.
Dot Product = Price1 × Weight1 + Price2 × Weight2 + Price3 × Weight3 ...
When the Price and Weight arrays are equally sized (aka. the length is no longer incrementing from the anchor), there's a 1-1 mapping between Price and Weight indices. Anchoring, however, purges historical data from the Price array, making it temporarily smaller. When this happens, a dot product is synthesized by linearly interpolating for proportional indices (rather than a 1-1 mapping) to maintain the intended shape of weights.
Synthetic Dot Product = FirstPrice × FirstWeight + ... MidPrice × MidWeight ... + LastPrice × LastWeight
Sum of Weights
Exactly what it sounds like, the sum of weights used by the dot product operation. The sum of used weights may be less than the sum of all weights when the dot product is synthesized.
Sum of Weights = Weight1 + Weight2 + Weight3 ...
CALCULATING WEIGHTS
Shaping functions are mathematical curves used for interpolation. They are what give the Functionally Weighted Moving Average its name, and define how each historical price in the look back period is weighted.
The included shaping functions are:
Linear (conventional WMA)
Smoothstep (S curve)
Ease In Out (adjustable S curve)
Ease In (first half of Ease In Out)
Ease Out (second half of Ease In Out)
Ease Out In (eases out and then back in)
Cubic Bézier (aka. any curve you want)
In the following screenshot, the only difference between the three FWMA's is the shaping function (Ease In, Ease In Out, and Ease Out) illustrating how different curves can influence the responsiveness of an average.
And here is the same example, but with anchor saturation disabled .
ADJUSTING WEIGHTS
Each function outputs a range of values between 0 and 1. While you can't expand or shrink the range, you can nudge it higher or lower using the Scalar . For example, setting the scalar to -0.2 remaps to , and +0.2 remaps to . The following screenshot illustrates how -0.2 (lightest blue) and +0.2 (darkest blue) affect the average.
Easing functions can be further adjusted with the Degree (how much the shaping function curves). There's an interactive example of this here and the following illustrates how a degrees 0, 1, and 20 (dark orange, orange, and light orange) affect the average.
This level of configurability completely changes how a moving average models price for a given length, making the FWMA extremely versatile.
INPUTS
You can configure:
Length (how many historical bars to average)
Source (the bar value to average)
Offset (horizontal offset of the plot)
Weight (the shaping function)
Scalar (how much to adjust each weight)
Degree (how much to ease in / out)
Bézier Points (controls shape of Bézier)
Divisor & Anchor parameters
Style of the plot
BUT ... WHY?
We use moving averages to anticipate trend initialization, continuation, and termination. For a given look back period (length) we want the average to represent the data as accurately and smoothly as possible. The better it does this, the better it is at modeling price.
In this screenshot, both the FWMA (yellow) and EMA (blue) have a length of 9. They are both smooth, but one of them more accurately models price.
You wouldn't necessarily want to trade with these FWMA parameters, but knowing it does a better job of modeling price allows you to confidently expand the model to larger timeframes for bigger moves. Here, both the FWMA (yellow) and EMA (blue) have a length of 195 (aka. 50% of NYSE market hours).
INSPIRATION
I predominantly trade ETF derivatives and hold the position that markets are chaotic, not random . The salient difference being that randomness is entirely unpredictable, and chaotic systems can be modeled. The kind of analysis I value requires a very good pricing model.
The term "model" sounds more intimidating than it is. Math terms do that sometimes. It's just a mathematical estimation . That's it. For example, a regression is an "average regressing" model (aka. mean reversion ), and LOWESS (Locally Weighted Scatterplot Smoothing) is a statistically rigorous local regression .
LOWESS is excellent for modeling data. Also, it's not practical for trading. It's computationally expensive and uses data to the right of the point it's averaging, which is impossible in realtime (everything to the right is in the future). But many techniques used within LOWESS are still valuable.
My goal was to create an efficient real time emulation of LOWESS. Specifically I wanted something that was weighted non-linearly, was efficient, left-side only, and data faithful. Incorporate trading paradigms (like anchoring) and you get a Functionally Weighted Moving Average.
The formulas for determining the weights in LOWESS are typically chosen just because they seem to work well. Meaning ... they can be anything, and there's no justification other than "looks about right". So having a variety of functions (aka. kernels) for the FWMA, and being able to slide the weight range higher or lower, allows you to also make it "look about right".
William Cleveland, prominent figure in statistics known for his contributions to LOWESS, preferred using a tri-cube weighting function. Using Weight = Ease Out In with the Degrees = 3 is comparable to this. Enjoy!
Bollinger Band Reversal Strategy//@version=5
strategy("Bollinger Band Reversal Strategy", overlay=true)
// Bollinger Band Parameters
length = input.int(20, title="BB Length")
src = input(close, title="Source")
mult = input.float(2.0, title="BB Multiplier")
basis = ta.sma(src, length)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
plot(basis, "Basis", color=color.gray)
plot(upper, "Upper Band", color=color.red)
plot(lower, "Lower Band", color=color.green)
// Get previous and current candle data
prev_open = open
prev_close = close
cur_close = close
// Check for upper band touch and reversal
bearish_reversal = high >= upper and cur_close < prev_open
// Check for lower band touch and reversal
bullish_reversal = low <= lower and cur_close > prev_open
// Plotting arrows
plotshape(bearish_reversal, title="Down Arrow", location=location.abovebar, color=color.red, style=shape.arrowdown, size=size.small)
plotshape(bullish_reversal, title="Up Arrow", location=location.belowbar, color=color.green, style=shape.arrowup, size=size.small)
// Optional: Add strategy entry signals
if (bullish_reversal)
strategy.entry("Buy", strategy.long)
if (bearish_reversal)
strategy.entry("Sell", strategy.short)
Moving Averages with ADR%/ATR/52W TableOption to select Moving Averages as per different time frames.
ADR%: It should be above 5% as it is a sign of strength and stop loss should be lower than the ADR%. It should be calculated for last 20 Days.
ATR%: It is calculated as per the previous 14 Candles.
Minervini’s 52-Week High and Low Principles:
52-Week High:
Key Principle: Minervini prefers stocks trading near or at their 52-week highs, as this indicates strong bullish momentum and institutional buying interest. A stock at or close to its 52-week high is often breaking out of consolidation or resistance, signaling potential for further upside.
Criteria:
The stock should ideally be within 25% of its 52-week high (i.e., no more than 25% below the high). This is considered the “pivot point” or “buy zone” where the stock is still in a strong uptrend.
A breakout above the 52-week high, especially on high volume, is a bullish signal, often marking the start of a new uptrend.
Rationale: Stocks near their 52-week highs are less likely to face overhead resistance (supply from previous buyers at higher prices) and are attractive to momentum traders and institutions.
52-Week Low:
Key Principle: Minervini advises avoiding stocks trading close to their 52-week lows, as they often indicate weakness, lack of demand, or bearish sentiment. Instead, he looks for stocks that are significantly above their 52-week lows, demonstrating strength and recovery.
Criteria:
The stock should be at least 30% above its 52-week low to confirm it has moved away from a downtrend and is showing relative strength.
Stocks too close to their 52-week lows are considered risky, as they may be in a prolonged downtrend or lack institutional support.
Rationale: A stock well above its 52-week low has likely absorbed selling pressure and is attracting buyers, indicating a healthier trend and potential for further gains.
Application in Trading:
Stock Selection: Minervini uses these criteria as part of his SEPA (Specific Entry Point Analysis) methodology to filter stocks. Stocks meeting the 52-week high/low criteria are more likely to be in a “Stage 2” uptrend (per his adaptation of Stan Weinstein’s stage analysis).
Breakout Strategy: He focuses on buying stocks breaking out from consolidation patterns (e.g., volatility contractions, cup-and-handle) near their 52-week highs, ideally with strong volume and tight price action.
Risk Management: Stocks too far from their 52-week highs or too close to their 52-week lows may have higher risk, either due to overextension or lack of momentum.
Dynamic Color Logic in Your Script:
Based on our previous discussions, your Pine Script incorporates Minervini’s criteria for dynamic coloring in the ADR%/ATR/52W Table:
Below 52-Week High: Text turns green if the stock is within -25% to 0% of the 52-week high (i.e., high_52w_dist >= -25 and high_52w_dist <= 0), highlighting stocks in the bullish “buy zone.”
Above 52-Week Low: Text turns green if the stock is ≥30% above the 52-week low (i.e., low_52w_dist >= 30), indicating strength and distance from weakness.
These thresholds align with Minervini’s principles to visually flag stocks meeting his momentum criteria.
Integration with Your Pine Script:
Your script already implements Minervini’s 52-week high/low principles in the table’s dynamic color logic. Here’s how it reflects his strategy:
Below 52-Week High (high_52w_dist): The condition high_52w_dist >= -25 and high_52w_dist <= 0 ensures the stock is within 25% of its 52-week high, marking it as a potential candidate for a breakout or continuation trade.
Above 52-Week Low (low_52w_dist): The condition low_52w_dist >= 30 confirms the stock is at least 30% above its 52-week low, filtering out weak stocks and highlighting those with bullish strength.
The table displays these metrics on intraday and daily charts, using daily data via request.security for accurate calculations, which supports Minervini’s focus on daily price action for entry points.
EMA 9/21/50The indicator shows the 9, 21, and 50-period EMAs on the TradingView chart. The objective of using 9,21, and 50 periods is to identify the short-term momentum.
EMA Indicator with Crossover SignalsThis indicator indicates the 1p moving average 20.50m and 200 days
Moving Averages with ADR%/ATR/52W TableOption to select Moving Averages as per different time frames.
ADR%: It should be above 5% as it is a sign of strength and stop loss should be lower than the ADR%. It should be calculated for last 20 Days.
ATR%: It is calculated as per the previous 14 Candles.
Minervini’s 52-Week High and Low Principles:
52-Week High:
Key Principle: Minervini prefers stocks trading near or at their 52-week highs, as this indicates strong bullish momentum and institutional buying interest. A stock at or close to its 52-week high is often breaking out of consolidation or resistance, signaling potential for further upside.
Criteria:
The stock should ideally be within 25% of its 52-week high (i.e., no more than 25% below the high). This is considered the “pivot point” or “buy zone” where the stock is still in a strong uptrend.
A breakout above the 52-week high, especially on high volume, is a bullish signal, often marking the start of a new uptrend.
Rationale: Stocks near their 52-week highs are less likely to face overhead resistance (supply from previous buyers at higher prices) and are attractive to momentum traders and institutions.
52-Week Low:
Key Principle: Minervini advises avoiding stocks trading close to their 52-week lows, as they often indicate weakness, lack of demand, or bearish sentiment. Instead, he looks for stocks that are significantly above their 52-week lows, demonstrating strength and recovery.
Criteria:
The stock should be at least 30% above its 52-week low to confirm it has moved away from a downtrend and is showing relative strength.
Stocks too close to their 52-week lows are considered risky, as they may be in a prolonged downtrend or lack institutional support.
Rationale: A stock well above its 52-week low has likely absorbed selling pressure and is attracting buyers, indicating a healthier trend and potential for further gains.
Application in Trading:
Stock Selection: Minervini uses these criteria as part of his SEPA (Specific Entry Point Analysis) methodology to filter stocks. Stocks meeting the 52-week high/low criteria are more likely to be in a “Stage 2” uptrend (per his adaptation of Stan Weinstein’s stage analysis).
Breakout Strategy: He focuses on buying stocks breaking out from consolidation patterns (e.g., volatility contractions, cup-and-handle) near their 52-week highs, ideally with strong volume and tight price action.
Risk Management: Stocks too far from their 52-week highs or too close to their 52-week lows may have higher risk, either due to overextension or lack of momentum.
Dynamic Color Logic in Your Script:
Based on our previous discussions, your Pine Script incorporates Minervini’s criteria for dynamic coloring in the ADR%/ATR/52W Table:
Below 52-Week High: Text turns green if the stock is within -25% to 0% of the 52-week high (i.e., high_52w_dist >= -25 and high_52w_dist <= 0), highlighting stocks in the bullish “buy zone.”
Above 52-Week Low: Text turns green if the stock is ≥30% above the 52-week low (i.e., low_52w_dist >= 30), indicating strength and distance from weakness.
These thresholds align with Minervini’s principles to visually flag stocks meeting his momentum criteria.
Integration with Your Pine Script:
Your script already implements Minervini’s 52-week high/low principles in the table’s dynamic color logic. Here’s how it reflects his strategy:
Below 52-Week High (high_52w_dist): The condition high_52w_dist >= -25 and high_52w_dist <= 0 ensures the stock is within 25% of its 52-week high, marking it as a potential candidate for a breakout or continuation trade.
Above 52-Week Low (low_52w_dist): The condition low_52w_dist >= 30 confirms the stock is at least 30% above its 52-week low, filtering out weak stocks and highlighting those with bullish strength.
The table displays these metrics on intraday and daily charts, using daily data via request.security for accurate calculations, which supports Minervini’s focus on daily price action for entry points.