Scripting Tutorial A - TManyMA - Stops
Nov 7, 2019

The Scripting Tutorial A - TManyMA - Stops indicator provides a comprehensive framework for triple moving average analysis, offering flexible smoothing options, forecasting, and automated strategy components.
Usage
The Usage section focuses on how to interpret the triple moving average system and its associated visual and strategic features. Users can apply this tool to identify trends, forecast potential price paths, and simulate trading performance based on moving average crossovers.
Moving Average Configuration
The script allows for three independent moving averages (MA1, MA2, MA3). Users can customize the smoothing type (SMA, EMA, WMA, RMA, HMA, DEMA, TEMA, or VWMA), the lookback period, the price source, and the timeframe resolution for each. This flexibility enables cross-timeframe analysis (e.g., viewing a daily MA on a 1-hour chart).
Forecasting and Bias
The indicator projects moving average values five bars into the future. This is calculated using a "Forecast Bias" setting:
- Neutral: Projects based on current price action.
- Bullish/Bearish: Adjusts the projection based on the Average True Range (ATR) multiplied by a user-defined magnitude to simulate anticipated market directions.
Ribbons and Crosses
When MA types, resolutions, and sources match, the script can plot alpha-color coded ribbons between the lines. These ribbons represent intermediate MA periods, providing a visual "gradient" of the trend. Additionally, crossover and crossunder events can be highlighted with labels on the chart for easier identification of signal points.
Strategy Execution
The script includes built-in strategy logic that enters long positions on MA crossovers. Users can specifically toggle which crosses trigger trades (1-2, 1-3, or 2-3). The strategy includes risk management parameters for percentage-based Take Profit and Stop Loss levels.
Details
The script is constructed to be an educational resource for Pine Script development. It utilizes request.security() for multi-timeframe calculations and incorporates a custom function to handle various moving average types within a single logic block.
The forecasting logic estimates future MA values by substituting future unknown price points with current prices adjusted by the calculated bias. The ribbons are dynamically calculated by determining the period difference between two primary MAs and dividing that difference into five equal steps.
Settings
MA Settings (MA1, MA2, MA3)
- Period: The lookback length for the moving average calculation.
- Type: The smoothing method (e.g., SMA, EMA, HMA).
- Source: The price data used for the calculation (e.g., Close, Open, HL2).
- Resolution: The timeframe from which the MA data is pulled.
- Visible: Toggles the visibility of the specific moving average on the chart.
Forecast Settings
- Forecast Bias: Determines the directional assumption for projections (Neutral, Bullish, Bearish).
- Forecast Bias Period: The ATR period used to calculate the magnitude of the bias.
- Forecast Bias Magnitude: A multiplier for the ATR to increase or decrease the intensity of the forecast bias.
- Show Forecasts: Toggles the visibility of the projected MA circles.
Strategy & Visuals
- Show Crosses: Displays labels when moving averages cross each other.
- Show Ribbons: Enables the filling between MAs if their settings are compatible.
- Trade MA Crosses: Boolean toggles to enable or disable trading signals for specific MA pairings.
- Take Profit / Stop Loss Percent: Defines the exit thresholds for the strategy based on a percentage of the entry price.
FAQ
How do I enable the ribbons between the moving averages? To see the ribbons, ensure that the two MAs you are comparing (e.g., MA1 and MA2) have the same Type, Resolution, and Source. The "Show Ribbons" setting must also be enabled.
What does the Forecast Bias Magnitude do? It scales the forecasted price movement. A higher magnitude will push the projected moving average lines further up (in Bullish mode) or further down (in Bearish mode) based on market volatility.
How can I access the Scripting Tutorial A - TManyMA - Stops? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.