Posts

About

About Blog Topic Introduction This is a tech blog specializing in technical analysis, creating automated trading indicators, and algorithmic trading strategies using TradingView's Pine Script. Who Runs the Blog It is run by "Algo Trader," a trader and developer who researches and develops data-driven system trading. Why This Blog Was Created While Pine Script is a powerful tool, it can have a high barrier to entry for beginners. I created this blog to share how to implement my own indicators and strategies in code, and to grow together by communicating with people interested in quantitative investing and algorithmic trading.

Privacy Policy

Privacy Policy for The Wealth Lab Last Updated: May 22, 2026 Welcome to The Wealth Lab ("https://www.weinvesting.live/"). We are committed to protecting your privacy and ensuring that your personal information is handled in a safe and responsible manner. This Privacy Policy outlines how we collect, use, and protect your data when you visit our website. 1. Information We Collect A. Automatically Collected Information When you visit The Wealth Lab, we may automatically collect certain information about your device, including information about your web browser, IP address, time zone, and some of the cookies that are installed on your device. Additionally, as you browse the site, we collect information about the individual web pages or posts that you view, what websites or search terms referred you to the site, and information about how you interact with the site. B. Google Analytics We use Google Analytics to help us understand how our customers use the Site. Google An...

Contact

Contact dreamatthehome@gmail.com

SuperTrend Indicator in Pine Script v6: Canonical Formula, Flip Logic, and Non-Repainting Signals

Image
Every trend-following trader eventually faces the same frustration: a moving average that lags too far behind price, generating entries long after the move has started and exits well into the reversal. The SuperTrend indicator was designed to solve exactly this problem — it combines Average True Range (ATR) volatility with a dynamic band-switching mechanism to produce a single, clean line that sits below price in an uptrend and above price in a downtrend. When price closes beyond the opposite band, the line flips, generating a confirmed signal on the closed bar. This post builds a precise, well-defined SuperTrend variant in Pine Script v6 , maps every formula term to its code variable, explains the exact flip conditions, and clarifies non-repainting behavior. What Is SuperTrend? The Mathematical Foundation SuperTrend is built on two components: a midpoint price and an ATR-scaled offset . The midpoint is typically the average of the hig...

CCI Indicator in Pine Script v6: Detect Cyclical Price Reversals with Precision

Image
Every trader has faced this frustrating scenario: you enter a trend just as it exhausts itself, or you exit a position right before a powerful reversal completes. The Commodity Channel Index (CCI) was engineered specifically to solve this problem — it quantifies how far price has deviated from its statistical norm, giving you a mathematically grounded signal for when a cycle is overextended and likely to reverse. In this guide, we'll build a fully functional CCI indicator in Pine Script v6 , dissect the math behind it, and wire up actionable overbought/oversold signals — all with verified, compile-ready code. 📐 The Mathematics of CCI Developed by Donald Lambert in 1980, the CCI measures the deviation of the Typical Price from its Simple Moving Average, normalized by the Mean Absolute Deviation (MAD). The formula is: $$\text{Typical Price} = \frac{\text{High} + \text{Low} + \text{Close}}{3}$$ $$\text{CCI} = \frac{\text{TP} - \text...

ADX Trend Strength Indicator in Pine Script v6: Build a Compile-Tested DMI Filter

Image
Every trader has experienced the frustration of entering what looks like a clean breakout, only to watch price immediately reverse into a choppy, sideways grind. The Average Directional Index (ADX) was designed by J. Welles Wilder specifically to solve this problem — not to tell you which direction the market is moving, but how strongly it is moving at all. In this guide, we will build a complete, compile-tested ADX indicator in Pine Script v6, dissect the mathematics behind every calculation step, and show you exactly how to use ADX as a regime filter to avoid low-conviction trades. The Core Problem: Trend vs. Noise Most directional indicators — moving averages, MACD, RSI — assume the market is trending. When it is not, they generate a relentless stream of false signals. ADX quantifies trend strength on a scale from 0 to 100, independent of direction. A rising ADX means the market is developing a trend (bullish...

How Does ATR Measure Volatility? A Pine Script v6 Deep Dive into Average True Range

Image
When building systematic trading tools, quantifying market volatility is a foundational requirement — and the Average True Range (ATR) is one of the most mathematically rigorous ways to do it. Developed by J. Welles Wilder Jr., ATR measures the average magnitude of price movement over a rolling window, making it indispensable for dynamic stop-loss placement, position sizing, and volatility-adaptive indicators. This article dissects the ATR formula, explains its Pine Script v6 implementation, and demonstrates how to use it for stop-loss engineering. 1. The Mathematics of True Range Before ATR can be computed, we must define the True Range (TR) for each bar. TR captures the full extent of price movement, including gaps between sessions. It is defined as the maximum of three values: $$TR = \max\left(H - L,\; |H - C_{prev}|,\; |L - C_{prev}|\right)$$ Where: $H$ = Current bar's High $L$ = Current bar's Low $C_{prev}$ = P...