Manual Three rectangles
Download scriptThis script is designed to automate the identification and management of specific price levels on a trading chart, specifically focusing on three distinct rectangular zones (Up, Middle, and Down). It acts as an intelligent overlay that helps traders visualize key support and resistance areas while automatically adjusting trade protections like Stop Loss levels.
Core Functionality
1. Zone Identification & Dynamic Tracking The logic relies on three user-defined rectangles on your chart. Instead of just acting as static boxes, the script actively "reads" the price boundaries of these shapes. It captures the upper and lower prices of each rectangle to understand the current market context. If you move or resize these rectangles on your chart, the script detects those changes in real-time and updates its internal calculations accordingly.
2. Smart Price Sorting & Level Generation To ensure the logic remains consistent regardless of how the rectangles are arranged, the script takes all six boundaries (the top and bottom edges of the three rectangles) and sorts them from lowest to highest. It then calculates a series of intermediate "sub-levels."
- It identifies the absolute minimum price.
- It calculates mid-points between neighboring price boundaries.
- It identifies the absolute maximum price.
Based on these calculated points, it generates a sequence of seven visual markers (arrows) on your chart. These arrows represent refined "right price" levels that provide a more granular view of the trading environment than the rectangles alone.
3. Automated Trade Protection (Trailing & Stop Management) The script contains a sophisticated mechanism for managing open positions:
- Freeze Levels: It checks the broker's "Freeze Level" and "Stops Level" to ensure that any requested trade modifications are valid and won't be rejected by the server.
- Dynamic Stop Loss Adjustments: For active trades, the script constantly monitors the current market price against the calculated sub-levels.
- For Buy positions, it looks for opportunities to move your Stop Loss higher as price moves into favor, ensuring you lock in profits.
- For Sell positions, it looks for opportunities to move your Stop Loss lower.
- Safety Logic: It only modifies a trade if the new level provides an actual improvement (e.g., moving the stop loss further away from the risk) and ensures that the move is large enough to be meaningful, preventing constant, unnecessary modifications to your broker.
Technical Safety & Performance
- Execution Throttle: To keep the trading platform running smoothly, the script includes a "heartbeat" logic. It limits its heavy calculations (like searching for signals and updating labels) to once every 10 seconds, preventing CPU lag.
- Data Integrity: Before performing any calculations, the script verifies that it has a valid connection to the market by refreshing price quotes and ensuring the data isn't "zeroed out."
- Visual Cleanup: When you remove the script from the chart, it automatically clears the generated markers (arrows) to leave your workspace clean.
ÿþ/ / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
/ / | M a n u a l T h r e e r e c t a n g l e s 2 . m q 5 |
/ / | C o p y r i g h t © 2 0 2 0 , V l a d i m i r K a r p u t o v |
/ / | h t t p s : / / w w w . m q l 5 . c o m / r u / m a r k e t / p r o d u c t / 4 3 5 1 6 |
/ / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
# p r o p e r t y c o p y r i g h t "