Bollinger Band Two MA and Zig-Zag
Download scriptThis script is an automated trading system designed to execute trades based on a combination of three major technical analysis tools: Moving Averages (MA), Bollinger Bands, and the ZigZag indicator.
Instead of relying on just one signal, it uses a multi-layered logic to confirm market trends before entering or exiting positions. Here is a breakdown of how the system operates in plain English:
Core Components & Logic
The script continuously monitors three specific indicators to decide what to do with your trades:
- Two Moving Averages (MA1 & MA2): The system tracks two different moving averages (which can be set to different timeframes). It uses these to identify the primary trend of the market—essentially looking for "support" and "resistance" levels based on historical price averages.
- Bollinger Bands: This tool helps the script understand volatility and overextended price movements. It looks at the upper and lower boundaries of price action to determine if the market is stretched too far in one direction or if it is returning to its mean.
- ZigZag Indicator: This is used to identify significant "swing highs" and "swing lows." The script uses this to find major structural turning points in the market, helping it distinguish between minor price noise and actual trend reversals.
How the Trading Works
1. Entry Signals (Buying and Selling)
The script looks for a specific "confluence" of events to trigger a trade:
- Buy Signal: For a Buy order to be placed, the current price must be above both Moving Averages while simultaneously showing that previous prices have crossed through specific Bollinger Band levels. It essentially waits for the trend to be confirmed by all three tools before opening a "Buy" position.
- Sell Signal: Conversely, for a Sell order, it looks for the price to drop below the Moving Averages and interact with the upper Bollinger Bands in a specific way, signaling a downward shift.
2. Smart Trade Management
Once a trade is opened, the script doesn't just leave it alone; it actively manages the risk:
- Dynamic Take Profit (TP): Rather than using a fixed number, the system calculates a target profit level based on the distance between current prices and the historical "Min/Max" levels identified by the ZigZag indicator.
- Automatic Stop Loss (SL): It includes a safety net that can be turned on or off. If enabled, it automatically places a limit on how much money you can lose on a single trade.
- Trailing Stop: This is one of the script's key features. As your trade moves into profit, the system "trails" your stop loss behind the price. This allows the script to lock in profits while still giving the trade room to keep moving in your favor.
3. Safety and Reliability
- Volume Verification: Before placing any trade, the script checks with the broker to ensure the requested lot size is allowed. If you try to trade a volume that is too small or too large for that specific asset, it will alert you rather than trying to force the trade.
- Execution Logging: Every action—successes and failures alike—is recorded in the terminal. This allows you to see exactly why a trade was opened, where the profit target was set, or why a broker might have rejected a request.
- Error Handling: The script is designed to be robust; if it fails to load an indicator or loses connection to price data, it will stop and print a clear error message rather than making erratic trades on bad information.
Price Data Components
Indicators Used
Miscellaneous
15
Views
0
Downloads
0
Favorites
Bollinger Band Two MA and Zig-Zag
ÿþ/ / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
/ / | B o l l i n g e r B a n d T w o M A a n d Z i g - Z a g ( b a r a b a s h k a k v n '