Okay, here's a breakdown of what this MetaTrader MQL script does in plain language:
Overall Purpose
This script is designed to automatically place pending orders based on signals from the Parabolic SAR (SAR) indicator, and to manage existing open positions. It aims to automate parts of the trading process.
Key Components and Logic
-
Initialization:
- When the script is added to a chart, it first sets up some key information and tools it will need. This includes:
- Getting the current trading symbol (e.g., EURUSD).
- Setting up trading parameters: magic number (a unique identifier for its trades), slippage (acceptable price difference), etc.
- Calculating the correct lot size (trade volume) based on your settings (fixed lot size or a percentage of your account balance).
- Creating the SAR indicator: it takes parameters of step and maximum value to create the indicator that will be used to decide whether or not to place the next trade order.
- It makes sure the input settings are valid before starting (e.g., trailing stop settings).
- When the script is added to a chart, it first sets up some key information and tools it will need. This includes:
-
Tick-by-Tick Execution (Main Loop):
- The script constantly monitors the market (with every price update, or "tick") and checks for certain conditions.
- It also verifies if a signal for placing a new pending order has appeared.
- The most important condition is whether the profit reaches the amount specified by the user so as to close all existing position and delete all existing pending order, deleting the trades that this bot has created previously
-
Trailing Stop Logic:
- Trailing stop is the name given to automatically update the stop loss price as the price moves in our favour, to avoid our profits to be turned into loss.
- The script includes a mechanism to automatically adjust the stop-loss price of open positions as the price moves in a favorable direction. This helps to lock in profits.
- Trailing is done periodically (every few seconds), or with every new bar.
-
Trading Signal Detection:
- The script gets the reading from the SAR indicator, and determines if a "buy" or "sell" signal has appeared.
-
Pending Order Placement:
- When a trading signal is detected, the script places a pending order. A pending order is an instruction to buy or sell if the price reaches a specific level in the future.
- Before placing an order, the script checks if the current spread (the difference between the buy and sell price) is within acceptable limits to avoid trading in high volatility times.
- Orders include a stop-loss and take-profit level, if specified.
-
Order Management:
- If certain profit goals are reached, the script can automatically close all open positions and delete all pending orders.
- On each "tick" (price movement), the script checks if any existing pending orders should be deleted (e.g., if a buy stop order should be canceled).
-
Order Execution Monitoring:
- At order execution, this script manages the existing trade.
In Summary
This script automates a trading strategy that uses the Parabolic SAR indicator to generate trading signals, placing pending orders and it also manages your trades by trailing the stop, making money management more hands-free.
Price Data Components
Orders Execution
Indicators Used
Miscellaneous
14
Views
1
Downloads
0
Favorites
iSAR Pending Stop 2
ÿþ/ / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
/ / | i S A R P e n d i n g S t o p 2 . m q 5 |
/ / | C o p y r i g h t © 2 0 1 9 , V l a d i m i r K a r p u t o v |
/ / | h t t p : / / w m u a . r u / s l e s a r / |
/ / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
# p r o p e r t y c o p y r i g h t "