XauUsd Nostradamus M5
- Experts
-
Andrey Kozak
Laboratory of Automatic Systems (LAS) - more than 10 years, we have been developing, testing and programming automatic trading robots for the forex market. - 버전: 1.0
- 활성화: 20
XauUsd Nostradamus M5 is an automated trading Expert Advisor (EA) for MetaTrader 5, specifically designed for trading gold XAUUSD on the M5 timeframe.
The robot operates according to an algorithmic approach: it analyzes completed price bars, determines the current market direction, and opens a position when a confirmed change in the trading state occurs. After a trade is opened, the position is managed using a dynamic stop-loss.
The EA does not use grid trading, martingale, or lot-size increases after losing trades. The position size is determined by the LotSize parameter and does not depend on the outcome of previous trades.
An important feature of XauUsd Nostradamus M5 is that it operates specifically on closed bars. Trading decisions are made when a new bar appears, so the robot does not use an unfinished candle to generate the primary trading signal.
The trading logic is based on an algorithmic analysis of price movement direction using smoothed price characteristics and an assessment of the local market structure.
For the user, this logic is represented by two states:
- BUY state — the market is in an upward trading state;
- SELL state — the market is in a downward trading state.
The robot does not attempt to remain in the market continuously. A new trade is considered only when a confirmed transition from one state to another occurs.
Thus:
SELL → BUY
→ close the existing Sell position, if any
→ open a Buy position.
BUY → SELL
→ close the existing Buy position, if any
→ open a Sell position.
If the current position already corresponds to the new signal, no additional trade is opened.
The internal formulas, calculation sequence, and specific conditions used to determine the trading state are not disclosed, as they are part of the product's proprietary trading logic.
After opening a trade, the robot manages the position using a dynamic trailing stop.
The Stop Loss is recalculated on every tick, rather than only when a new bar appears. As the market moves in a favorable direction, the protective level may move along with the price.
The EA takes the trading instrument's broker-specific limitations into account, including:
- minimum Stop Level distance;
- Freeze Level;
- number of decimal digits;
- minimum and maximum volume;
- volume step.
The trailing stop never moves in a direction that increases the potential loss: for a Buy position, the protective level can only move upward, while for a Sell position, it can only move downward.
Take Profit is not set by the EA. The primary mechanisms for protecting the position and locking in the trading result are the dynamic Stop Loss and the trading-state reversal logic.
Before sending a trading request, the robot performs a number of technical checks.
It verifies:
- whether automated trading is enabled in the terminal;
- whether trading is allowed on the account;
- whether Expert Advisors are allowed to trade;
- whether the instrument's trading mode is available;
- whether the maximum number of orders/positions has been exceeded;
- whether the volume complies with the symbol's requirements;
- whether sufficient free margin is available to open the position;
- whether the current spread exceeds the user-defined limit.
If any critical condition is not satisfied, the trading request is not sent.
Instrument
XAUUSD (Gold)
XauUsd Nostradamus M5 was developed and tested as a specialized algorithm for trading gold. Using the EA on other instruments or timeframes is not considered its standard intended use.
Timeframe
M5 — the primary recommended timeframe.
The EA operates using the current _Period, so technically it can be attached to another timeframe. However, the trading logic and parameter values are primarily designed for XAUUSD M5.
Using a different timeframe changes the nature of the signals and the effective trailing-stop distance relative to market volatility.
Spread
For XAUUSD, it is recommended to use an account and trading conditions where the spread remains low and stable.
The default robot setting is:
MaxSpreadPoints = 50
This means that when SYMBOL_SPREAD exceeds 50 points, a new signal is ignored.
It is important to understand that a point and the spread expressed in currency/price terms are not the same thing. The specific monetary or price value of one point depends on the broker's XAUUSD specification.
Therefore, before using the EA, check:
Market Watch → XAUUSD → Specification
and verify:
- Digits;
- Point;
- Spread;
- Contract Size;
- Tick Size;
- Tick Value;
- Volume Step.
The value 50 is a technical filter threshold and is not a universal guarantee of the same spread conditions across all brokers.
For practical use, it is preferable to choose a broker/account offering a tight and predictable XAUUSD spread, especially during periods of increased volatility.
Leverage
The EA does not require any specific leverage ratio in order to operate.
Before opening each trade, the robot calculates the required margin using MetaTrader 5's standard OrderCalcMargin() mechanism and checks whether sufficient free margin is available.
Nevertheless, for XAUUSD, leverage of at least 1:100 is recommended, and higher leverage may be preferable when available, as it reduces the margin requirement per unit of position size.
However, increasing leverage does not reduce the market risk of the position itself. The potential monetary result is primarily determined by the position size and the price movement.
It is recommended not to select the lot size solely based on the available leverage. The lot size should be appropriate for the account balance, acceptable drawdown, and the characteristics of the specific broker.
Account Type
An account with the following characteristics is preferable:
- low spread;
- high liquidity;
- fast execution;
- minimal latency;
- stable market-order execution;
- transparent XAUUSD trading conditions.
For algorithmic trading, using a VPS located geographically close to the broker's trading server is recommended.
Trading Conditions
Keep in mind that XAUUSD may experience significant spread widening during:
- major macroeconomic data releases;
- transitions between trading sessions;
- periods of low liquidity;
- market opening/closing;
- sharp price movements.
The MaxSpreadPoints filter prevents a new trade from being opened when the spread exceeds the configured threshold. However, it cannot prevent the spread from changing after a position has already been opened.
LotSize
Default value: 0.01
Defines the base volume of the position to be opened.
For example:
LotSize = 0.01 → the robot attempts to open a position of 0.01 lots.
LotSize = 0.10 → the position size is increased tenfold compared with 0.01.
Position size directly affects the monetary result of a trade: for the same XAUUSD price movement, a larger position results in a larger change in profit or loss.
The robot additionally checks whether the specified volume complies with the broker's restrictions:
- minimum volume;
- maximum volume;
- volume step;
- volume limit.
If the specified volume does not comply with the symbol's specification, the trading request is not executed.
Practical recommendation: start with the minimum available volume and independently evaluate the EA's behavior on the specific account.
Amplitude
Default value: 2
Determines the sensitivity of the internal algorithm used to identify the market direction.
The parameter is used when calculating smoothed price characteristics and forming the trading state.
In general:
- a lower Amplitude value makes the algorithm more sensitive to changes in the local price structure;
- a higher value makes the analysis more smoothed and requires a more pronounced price movement for the state to change.
Increasing Amplitude may make the signals less sensitive to short-term market fluctuations.
Decreasing Amplitude makes the algorithm respond faster, but also makes it more susceptible to local market noise.
Recommended value for the standard XAUUSD M5 scenario: 2.
Changing this parameter should be considered a change to the character of the trading system rather than simply a way to increase the number of trades.
TrailingStopPoints
Default value: 85
Defines the trailing-stop distance from the current price in points.
For Buy:
Stop Loss ≈ Bid − 85 points
For Sell:
Stop Loss ≈ Ask + 85 points
The actual distance may be increased if the broker requires a greater minimum distance for setting or modifying the Stop Loss.
A lower value:
- places the protective level closer to the current price;
- may cause the position to be closed more quickly by an adverse price movement;
- gives the trade less room for a correction.
A higher value:
- gives the position more room;
- places the protective level farther from the current price;
- allows the position to move farther away from the current price before the protection is triggered.
The parameter is specified in points, so its actual price-distance value depends on the number of digits used for XAUUSD by the broker.
MagicNumber
Default value: 123456
A unique identifier for trades generated by this Expert Advisor.
The Magic Number allows the robot to distinguish its own positions from positions opened by:
- another Expert Advisor;
- another instance of the same Expert Advisor;
- manual trades.
XauUsd Nostradamus M5 manages only positions for the current symbol whose Magic Number matches the configured value.
If multiple instances of the EA are running on the same account, it is recommended to use different Magic Numbers, especially when the instances use different settings.
SlippagePoints
Default value: 100
Defines the maximum permitted price deviation when sending a trading request through the CTrade mechanism.
The parameter is specified in points.
It is particularly relevant for XAUUSD during rapid price movements, when the price may change between the moment a trading decision is generated and the actual execution of the order.
A lower value:
- limits the permitted price deviation;
- may result in more execution rejections during rapid market movements.
A higher value:
- allows greater price deviation;
- increases the probability of execution in a rapidly changing market;
- may also result in an execution price that differs more significantly from the expected price.
SlippagePoints is not a commission and does not determine the spread size.
MaxSpreadPoints
Default value: 50
Maximum spread filter.
Before opening a new position, the EA checks the current spread of the instrument. If the spread exceeds the configured limit, the new order is not sent.
For example:
MaxSpreadPoints = 50
means that if the current SYMBOL_SPREAD > 50, the signal is skipped.
An important implementation detail is that the spread filter is applied when a new trading signal appears, immediately before opening the position.
It does not close an existing position if the spread subsequently widens.
If:
MaxSpreadPoints = 0
the maximum-spread filter is disabled.
For XAUUSD, it is recommended to keep the spread filter enabled.
After installing the EA on an XAUUSD M5 chart, the robot automatically:
- monitors the appearance of a new M5 bar;
- analyzes completed price data;
- identifies a change in the trading state;
- checks trading restrictions;
- checks whether the current spread is acceptable;
- checks available margin;
- checks whether the trading volume is valid;
- opens a Buy or Sell position when a new signal is generated;
- closes the opposite position before a reversal;
- manages the open position using a dynamic Stop Loss.
If there is no new signal, the robot does not open additional positions.
The EA is designed to operate with one logical position for its Magic Number and the current symbol.
When an opposite signal is received, the robot first attempts to close the existing position, then verifies that the position has actually been closed, and only after that sends a new order.
This helps prevent simultaneous opposite positions associated with the logic of this Expert Advisor.
However, the final behavior also depends on the type of MetaTrader 5 account and the broker's trading restrictions.
For proper operation, the following are recommended:
- MetaTrader 5;
- XAUUSD instrument;
- M5 timeframe;
- algorithmic trading enabled;
- a broker that supports XAUUSD trading;
- sufficient free margin;
- a stable connection to the trading server;
- preferably a VPS for continuous terminal operation.
The Expert Advisor uses the standard MetaTrader 5 trading interface and automatically determines the permitted order execution type according to the specification of the current symbol.
