OPEN-SOURCE SCRIPT
MA Signal Indicator

MA Signal Indicator
The MA Signal Indicator is a customizable designed to identify potential trading opportunities based on price interactions with a Simple Moving Average (SMA). It incorporates risk management features such as stop-loss (SL), take-profit (TP), and breakeven levels, calculated using the Average True Range (ATR). The indicator is visually intuitive, overlaying trade signals, price levels, and colored zones directly on the chart.
Key Features:
1. Moving Average-Based Signals:
• Generates buy (long) signals when the price crosses above a user-defined SMA (default: 55 periods).
• Generates sell (short) signals when the price crosses below the SMA.
• Long and short trades can be independently enabled or disabled via input settings.
2. Risk Management:
• Stop-Loss (SL): Set as a multiple of the ATR (default: 1x ATR) below the entry price for long trades or above for short trades.
• Take-Profit (TP): Set as a multiple of the ATR (default: 5x ATR) above the entry price for long trades or below for short trades.
• Breakeven Level: A trigger level (default: 2x ATR) where traders may choose to move their stop-loss to breakeven, optionally displayed on the chart.
3. Visual Feedback:
• SMA Line: Plotted in orange (default: 55-period SMA) for trend reference.
• Trade Zone: Highlights the area between the stop-loss and take-profit levels with a semi-transparent green (long) or red (short) background.
• Price Lines: Displays entry price (white), stop-loss (red), take-profit (green), and breakeven level (gray, optional) as horizontal lines during active trades.
• Signal Markers: Triangular markers indicate entry points (green triangle up for long, red triangle down for short).
• Exit Markers: Labels show when a trade hits the take-profit (green checkmark) or stop-loss (red cross).
4. Trade Logic:
• Only one trade is active at a time (long or short).
• Trades are exited when either the stop-loss or take-profit is hit, resetting the indicator for the next signal.
• Ensures signals are only triggered when not already in a trade, avoiding duplicate entries.
Inputs:
• MA Period: Length of the SMA (default: 55).
• ATR Period: Period for ATR calculation (default: 5).
• SL Multiplier: ATR multiplier for stop-loss (default: 1.0).
• TP Multiplier: ATR multiplier for take-profit (default: 5.0).
• Move to Breakeven After: ATR multiplier for breakeven trigger (default: 2.0).
• Show Break Even Line: Option to display the breakeven level (default: true).
• Allow Long Trades: Enable/disable long signals (default: true).
• Allow Short Trades: Enable/disable short signals (default: true).
Use Case:
This indicator is ideal for trend-following traders who want a clear, visual system for entering and exiting trades based on SMA crossovers, with predefined risk and reward levels. It suits both manual and automated trading strategies, providing flexibility to adjust parameters for different markets or timeframes.
Notes:
• The indicator is overlaid on the price chart for easy integration with other analysis tools.
• Users should test and adjust parameters (e.g., MA length, ATR multipliers) to suit their trading style and market conditions.
• The breakeven line is a visual guide; manual adjustment of stops is required as the indicator does not automatically modify trade positions.
This indicator provides a robust framework for disciplined trading with clear entry, exit, and risk management visuals.
The MA Signal Indicator is a customizable designed to identify potential trading opportunities based on price interactions with a Simple Moving Average (SMA). It incorporates risk management features such as stop-loss (SL), take-profit (TP), and breakeven levels, calculated using the Average True Range (ATR). The indicator is visually intuitive, overlaying trade signals, price levels, and colored zones directly on the chart.
Key Features:
1. Moving Average-Based Signals:
• Generates buy (long) signals when the price crosses above a user-defined SMA (default: 55 periods).
• Generates sell (short) signals when the price crosses below the SMA.
• Long and short trades can be independently enabled or disabled via input settings.
2. Risk Management:
• Stop-Loss (SL): Set as a multiple of the ATR (default: 1x ATR) below the entry price for long trades or above for short trades.
• Take-Profit (TP): Set as a multiple of the ATR (default: 5x ATR) above the entry price for long trades or below for short trades.
• Breakeven Level: A trigger level (default: 2x ATR) where traders may choose to move their stop-loss to breakeven, optionally displayed on the chart.
3. Visual Feedback:
• SMA Line: Plotted in orange (default: 55-period SMA) for trend reference.
• Trade Zone: Highlights the area between the stop-loss and take-profit levels with a semi-transparent green (long) or red (short) background.
• Price Lines: Displays entry price (white), stop-loss (red), take-profit (green), and breakeven level (gray, optional) as horizontal lines during active trades.
• Signal Markers: Triangular markers indicate entry points (green triangle up for long, red triangle down for short).
• Exit Markers: Labels show when a trade hits the take-profit (green checkmark) or stop-loss (red cross).
4. Trade Logic:
• Only one trade is active at a time (long or short).
• Trades are exited when either the stop-loss or take-profit is hit, resetting the indicator for the next signal.
• Ensures signals are only triggered when not already in a trade, avoiding duplicate entries.
Inputs:
• MA Period: Length of the SMA (default: 55).
• ATR Period: Period for ATR calculation (default: 5).
• SL Multiplier: ATR multiplier for stop-loss (default: 1.0).
• TP Multiplier: ATR multiplier for take-profit (default: 5.0).
• Move to Breakeven After: ATR multiplier for breakeven trigger (default: 2.0).
• Show Break Even Line: Option to display the breakeven level (default: true).
• Allow Long Trades: Enable/disable long signals (default: true).
• Allow Short Trades: Enable/disable short signals (default: true).
Use Case:
This indicator is ideal for trend-following traders who want a clear, visual system for entering and exiting trades based on SMA crossovers, with predefined risk and reward levels. It suits both manual and automated trading strategies, providing flexibility to adjust parameters for different markets or timeframes.
Notes:
• The indicator is overlaid on the price chart for easy integration with other analysis tools.
• Users should test and adjust parameters (e.g., MA length, ATR multipliers) to suit their trading style and market conditions.
• The breakeven line is a visual guide; manual adjustment of stops is required as the indicator does not automatically modify trade positions.
This indicator provides a robust framework for disciplined trading with clear entry, exit, and risk management visuals.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.