Moving Average Cross and/or Bbands bot
Sep 25, 2017

The Moving Average Cross and/or Bbands bot indicator provides a customizable framework for automating and backtesting strategies based on Moving Average crossovers and Bollinger Band breakouts. This tool combines trend-following and mean-reversion logic, allowing users to toggle between individual or combined signal conditions for streamlined market analysis.
Usage
The Usage section describes how the script can be used, examples should be provided in this section. This section also focuses on how main settings affect the indicator interpretation and output.
The script functions as a dual-logic strategy builder. Users can select between two primary methodologies:
- Moving Average Cross: Generates trend signals when the price is above/below a fast Moving Average and the fast Moving Average is above/below a slow Moving Average.
- Bollinger Bands: Generates mean-reversion signals when the price crosses outside the upper or lower bands.
By enabling both strategies, the indicator acts as a filter, requiring both conditions to be met simultaneously (e.g., price below the lower Bollinger Band while the Moving Average trend is bullish). The tool also features a "Market Type" toggle to adjust trade quantities automatically for Altcoins, Forex, or Commodity markets.
Details
The strategy execution logic includes advanced trade management features:
- Pyramiding Logic: Users can control how many additional entries are taken based on specific frequency rules (Less than, Equal to, or Greater than a set value).
- Exit Mechanisms: The script calculates and plots Trailing Stops, Take Profits, and Stop Losses directly on the chart.
- Margin Monitoring: A Margin Call feature calculates potential liquidation points based on user-defined leverage settings.
- Visual Performance: When pyramiding is active, the script calculates the average entry price and shades the area between the average price and the current market price to visualize unrealized profit or loss in real-time.
Settings
General Settings
- Altcoin / Forex Toggle: Adjusts the contract/lot size to match the specific requirements of these asset classes.
- Backtest Period: Sets the start and end dates (Year, Month, Day) for historical strategy evaluation.
Strategy Logic
- Use Moving Average Cross: Enables/Disables MA-based entry signals.
- Moving Average 1 & 2: Sets the lookback period for the fast and slow Moving Averages.
- Use Bollinger Bands: Enables/Disables BB-based entry signals.
- BB Length & Multiplier: Adjusts the period for the basis line and the standard deviation multiplier for the bands.
Trade Management
- Pyramiding Rules: Configures the logic for adding to existing positions.
- Trailing Stop Settings: Includes a toggle to activate the stop and a price offset for the trigger and the trail distance.
- Risk/Reward: Individual toggles and price inputs for Take Profit and Stop Loss.
- Leverage: Sets the leverage amount used to calculate the Margin Call visualization.
FAQ
How do I combine both the Moving Average and Bollinger Band signals? In the settings menu, check both "Use Moving Average Cross" and "Use Bollinger Bands." This configuration ensures that a signal is only triggered when both technical conditions align.
What does the shading between the line and the price represent? The shading indicates your current trade status. When pyramiding is used, the script calculates your average entry price; green shading indicates the trade is in profit, while red shading indicates it is in a loss.
How do I access Moving Average Cross and/or Bbands bot? 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.