OPEN-SOURCE SCRIPT

Enhanced MA Crossover Pro

73
📝 Strategy Summary: Enhanced MA Crossover Pro
This strategy is an advanced, highly configurable moving average (MA) crossover system designed for algorithmic trading. It uses the crossover of two customizable MAs (a "Fast" MA 1 and a "Slow" MA 2) as its core entry signal, but aggressively integrates multiple technical filters, time controls, and dynamic position management to create a robust and comprehensive trading system.

💡 Core Logic
Entry Signal: A bullish crossover (MA1 > MA2) generates a Long signal, and a bearish crossover (MA1 < MA2) generates a Short signal. Users can opt to use MA crossovers from a Higher Timeframe (HTF) for the entry signal.

Confirmation/Filters: The basic MA cross signal is filtered by several optional indicators (see Filters section below) to ensure trades align with a broader trend or momentum context.

Position Management: Trades are managed with a sophisticated system of Stop Loss, Take Profit, Trailing Stops, and Breakeven stops that can be fixed, ATR-based, or dynamically adjusted.

Risk Management: Daily limits are enforced for maximum profit/loss and maximum trades per day.

⚙️ Key Features and Customization
1. Moving Averages
Primary MAs (MA1 & MA2): Highly configurable lengths (default 8 & 20) and types: EMA, WMA, SMA, or SMMA/RMA.

Higher Timeframe (HTF) MAs: Optional MAs calculated on a user-defined resolution (e.g., "60" for 1-hour) for use as an entry signal or as a trend confirmation filter.

2. Multi-Filter System
The entry signal can be filtered by the following optional conditions:

SMA Filter: Price must be above a 200-period SMA for long trades, and below it for short trades.

VWAP Filter: Price must be above VWAP for long trades, and below it for short trades.

RSI Filter: Long trades are blocked if RSI is overbought (default 70); short trades are blocked if RSI is oversold (default 30).

MACD Filter: Requires the MACD Line to be above the Signal Line for long trades (and vice versa for short trades).

HTF Confirmation: Requires the HTF MA1 to be above HTF MA2 for long entries (and vice versa).

3. Dynamic Stop and Target Management (S/L & T/P)
The strategy provides extensive control over exits:

Stop Loss Methods:

Fixed: Fixed tick amount.

ATR: Based on a multiple of the Average True Range (ATR).

Capped ATR: ATR stop limited by a maximum fixed tick amount.

Exit on Close Cross MA: Position is closed if the price crosses back over the chosen MA (MA1 or MA2).

Breakeven Stop: A stop can be moved to the entry price once a trigger distance (fixed ticks or Adaptive Breakeven based on ATR%) is reached.

Trailing Stop: Can be fixed or ATR-based, with an optional feature to auto-tighten the trailing multiplier after the breakeven condition is met.

Profit Target: Can be a fixed tick amount or a dynamic target based on an ATR multiplier.

4. Time and Session Control
Trading Session: Trades are only taken between defined Start/End Hours and Minutes (e.g., 9:30 to 16:00).

Forced Close: All open positions are closed near the end of the session (e.g., 15:45).

Trading Days: Allows specific days of the week to be enabled or disabled for trading.

5. Risk and Position Limits
Daily Profit/Loss Limits: The strategy tracks daily realized and unrealized PnL in ticks and will close all positions and block new entries if the user-defined maximum profit or maximum loss is hit.

Max Trades Per Day: Limits the number of executed trades in a single day.

🎨 Outputs and Alerts
Plots: Plots the MA1, MA2, SMA, VWAP, and HTF MAs (if enabled) on the chart.

Shapes: Plots visual markers (BUY/SELL labels) on the bar where the MA crossover occurs.

Trailing Stop: Plots the dynamic trailing stop level when a position is open.

Alerts: Generates JSON-formatted alerts for entry ({"action":"buy", "price":...}) and exit ({"action":"exit", "position":"long", "price":...}).

Wyłączenie odpowiedzialności

Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.