Johnny's Machine Learning Moving Average (MLMA) w/ Trend Alerts📖 Overview
Johnny's Machine Learning Moving Average (MLMA) w/ Trend Alerts is a powerful adaptive moving average indicator designed to capture market trends dynamically. Unlike traditional moving averages (e.g., SMA, EMA, WMA), this indicator incorporates volatility-based trend detection, Bollinger Bands, ADX, and RSI, offering a comprehensive view of market conditions.
The MLMA is "machine learning-inspired" because it adapts dynamically to market conditions using ATR-based windowing and integrates multiple trend strength indicators (ADX, RSI, and volatility bands) to provide an intelligent moving average calculation that learns from recent price action rather than being static.
🛠 How It Works
1️⃣ Adaptive Moving Average Selection
The MLMA automatically selects one of four different moving averages:
📊 EMA (Exponential Moving Average) – Reacts quickly to price changes.
🔵 HMA (Hull Moving Average) – Smooth and fast, reducing lag.
🟡 WMA (Weighted Moving Average) – Gives recent prices more importance.
🔴 VWAP (Volume Weighted Average Price) – Accounts for volume impact.
The user can select which moving average type to use, making the indicator customizable based on their strategy.
2️⃣ Dynamic Trend Detection
ATR-Based Adaptive Window 📏
The Average True Range (ATR) determines the window size dynamically.
When volatility is high, the moving average window expands, making the MLMA more stable.
When volatility is low, the window shrinks, making the MLMA more responsive.
Trend Strength Filters 📊
ADX (Average Directional Index) > 25 → Indicates a strong trend.
RSI (Relative Strength Index) > 70 or < 30 → Identifies overbought/oversold conditions.
Price Position Relative to Upper/Lower Bands → Determines bullish vs. bearish momentum.
3️⃣ Volatility Bands & Dynamic Support/Resistance
Bollinger Bands (BB) 📉
Uses standard deviation-based bands around the MLMA to detect overbought and oversold zones.
Upper Band = Resistance, Lower Band = Support.
Helps traders identify breakout potential.
Adaptive Trend Bands 🔵🔴
The MLMA has built-in trend envelopes.
When price breaks the upper band, bullish momentum is confirmed.
When price breaks the lower band, bearish momentum is confirmed.
4️⃣ Visual Enhancements
Dynamic Gradient Fills 🌈
The trend strength (ADX-based) determines the gradient intensity.
Stronger trends = More vivid colors.
Weaker trends = Lighter colors.
Trend Reversal Arrows 🔄
🔼 Green Up Arrow: Bullish reversal signal.
🔽 Red Down Arrow: Bearish reversal signal.
Trend Table Overlay 🖥
Displays ADX, RSI, and Trend State dynamically on the chart.
📢 Trading Signals & How to Use It
1️⃣ Bullish Signals 📈
✅ Conditions for a Long (Buy) Trade:
The MLMA crosses above the lower band.
The ADX is above 25 (confirming trend strength).
RSI is above 55, indicating positive momentum.
Green trend reversal arrow appears (confirmation of a bullish reversal).
🔹 How to Trade It:
Enter a long trade when the MLMA turns bullish.
Set stop-loss below the lower Bollinger Band.
Target previous resistance levels or use the upper band as take-profit.
2️⃣ Bearish Signals 📉
✅ Conditions for a Short (Sell) Trade:
The MLMA crosses below the upper band.
The ADX is above 25 (confirming trend strength).
RSI is below 45, indicating bearish pressure.
Red trend reversal arrow appears (confirmation of a bearish reversal).
🔹 How to Trade It:
Enter a short trade when the MLMA turns bearish.
Set stop-loss above the upper Bollinger Band.
Target the lower band as take-profit.
💡 What Makes This a Machine Learning Moving Average?
📍 1️⃣ Adaptive & Self-Tuning
Unlike static moving averages that rely on fixed parameters, this MLMA automatically adjusts its sensitivity to market conditions using:
ATR-based dynamic windowing 📏 (Expands/contracts based on volatility).
Adaptive smoothing using EMA, HMA, WMA, or VWAP 📊.
Multi-indicator confirmation (ADX, RSI, Volatility Bands) 🏆.
📍 2️⃣ Intelligent Trend Confirmation
The MLMA "learns" from recent price movements instead of blindly following a fixed-length average.
It incorporates ADX & RSI trend filtering to reduce noise & false signals.
📍 3️⃣ Dynamic Color-Coding for Trend Strength
Strong trends trigger more vivid colors, mimicking confidence levels in machine learning models.
Weaker trends appear faded, suggesting uncertainty.
🎯 Why Use the MLMA?
✅ Pros
✔ Combines multiple trend indicators (MA, ADX, RSI, BB).
✔ Automatically adjusts to market conditions.
✔ Filters out weak trends, making it more reliable.
✔ Visually intuitive (gradient colors & reversal arrows).
✔ Works across all timeframes and assets.
⚠️ Cons
❌ Not a standalone strategy → Best used with volume confirmation or candlestick analysis.
❌ Can lag slightly in fast-moving markets (due to smoothing).
Machinelearningmovingaverage
Machine Learning : Cosine Similarity & Euclidean DistanceIntroduction:
This script implements a comprehensive trading strategy that adheres to the established rules and guidelines of housing trading. It leverages advanced machine learning techniques and incorporates customised moving averages, including the Conceptive Price Moving Average (CPMA), to provide accurate signals for informed trading decisions in the housing market. Additionally, signal processing techniques such as Lorentzian, Euclidean distance, Cosine similarity, Know sure thing, Rational Quadratic, and sigmoid transformation are utilised to enhance the signal quality and improve trading accuracy.
Features:
Market Analysis: The script utilizes advanced machine learning methods such as Lorentzian, Euclidean distance, and Cosine similarity to analyse market conditions. These techniques measure the similarity and distance between data points, enabling more precise signal identification and enhancing trading decisions.
Cosine similarity:
Cosine similarity is a measure used to determine the similarity between two vectors, typically in a high-dimensional space. It calculates the cosine of the angle between the vectors, indicating the degree of similarity or dissimilarity.
In the context of trading or signal processing, cosine similarity can be employed to compare the similarity between different data points or signals. The vectors in this case represent the numerical representations of the data points or signals.
Cosine similarity ranges from -1 to 1, with 1 indicating perfect similarity, 0 indicating no similarity, and -1 indicating perfect dissimilarity. A higher cosine similarity value suggests a closer match between the vectors, implying that the signals or data points share similar characteristics.
Lorentzian Classification:
Lorentzian classification is a machine learning algorithm used for classification tasks. It is based on the Lorentzian distance metric, which measures the similarity or dissimilarity between two data points. The Lorentzian distance takes into account the shape of the data distribution and can handle outliers better than other distance metrics.
Euclidean Distance:
Euclidean distance is a distance metric widely used in mathematics and machine learning. It calculates the straight-line distance between two points in Euclidean space. In two-dimensional space, the Euclidean distance between two points (x1, y1) and (x2, y2) is calculated using the formula sqrt((x2 - x1)^2 + (y2 - y1)^2).
Dynamic Time Windows: The script incorporates a dynamic time window function that allows users to define specific time ranges for trading. It checks if the current time falls within the specified window to execute the relevant trading signals.
Custom Moving Averages: The script includes the CPMA, a powerful moving average calculation. Unlike traditional moving averages, the CPMA provides improved support and resistance levels by considering multiple price types and employing a combination of Exponential Moving Averages (EMAs) and Simple Moving Averages (SMAs). Its adaptive nature ensures responsiveness to changes in price trends.
Signal Processing Techniques: The script applies signal processing techniques such as Know sure thing, Rational Quadratic, and sigmoid transformation to enhance the quality of the generated signals. These techniques improve the accuracy and reliability of the trading signals, aiding in making well-informed trading decisions.
Trade Statistics and Metrics: The script provides comprehensive trade statistics and metrics, including total wins, losses, win rate, win-loss ratio, and early signal flips. These metrics offer valuable insights into the performance and effectiveness of the trading strategy.
Usage:
Configuring Time Windows: Users can customize the time windows by specifying the start and finish time ranges according to their trading preferences and local market conditions.
Signal Interpretation: The script generates long and short signals based on the analysis, custom moving averages, and signal processing techniques. Users should pay attention to these signals and take appropriate action, such as entering or exiting trades, depending on their trading strategies.
Trade Statistics: The script continuously tracks and updates trade statistics, providing users with a clear overview of their trading performance. These statistics help users assess the effectiveness of the strategy and make informed decisions.
Conclusion:
With its adherence to housing trading rules, advanced machine learning methods, customized moving averages like the CPMA, and signal processing techniques such as Lorentzian, Euclidean distance, Cosine similarity, Know sure thing, Rational Quadratic, and sigmoid transformation, this script offers users a powerful tool for housing market analysis and trading. By leveraging the provided signals, time windows, and trade statistics, users can enhance their trading strategies and improve their overall trading performance.
Disclaimer:
Please note that while this script incorporates established tradingview housing rules, advanced machine learning techniques, customized moving averages, and signal processing techniques, it should be used for informational purposes only. Users are advised to conduct their own analysis and exercise caution when making trading decisions. The script's performance may vary based on market conditions, user settings, and the accuracy of the machine learning methods and signal processing techniques. The trading platform and developers are not responsible for any financial losses incurred while using this script.
By publishing this script on the platform, traders can benefit from its professional presentation, clear instructions, and the utilisation of advanced machine learning techniques, customised moving averages, and signal processing techniques for enhanced trading signals and accuracy.
I extend my gratitude to TradingView, LUX ALGO, and JDEHORTY for their invaluable contributions to the trading community. Their innovative scripts, meticulous coding patterns, and insightful ideas have profoundly enriched traders' strategies, including my own.