Instructions
EA Super Trend XAUUSD PROHow the Expert Advisor Makes Decisions
First Model: Determining the Trading Signal
The Expert Advisor (EA) utilizes two built-in ONNX models. The first generates a score, which the code interprets as the direction of a trading signal. With `main_threshold` set to 0.5, a signal value below 0.5 identifies a potential buy, while a value above 0.5 identifies a potential sell. If the value is exactly equal to the threshold, no entry is triggered.
Increasing the `main_threshold`—for example, to 0.6—shifts the criteria: a buy is now considered only below 0.4, and a sell only above 0.6, creating a "no-entry" zone between these thresholds. While this alters how signals are selected, it does not inherently guarantee better performance. A model’s score is neither a guarantee of success nor a proven probability of profit for any specific trade.
Second Model: Additional Entry Filter
The second model—a "meta-model"—acts as a filter. A new trade can only be opened if `meta_sig` exceeds the `meta_threshold` (which defaults to 0.5). Even if the first model generates a signal and the trend appears favorable, the trade will not be opened unless this filter condition is met. In the diagnostic output, the `filter=N` parameter indicates the number of times the filter has rejected a potential trade (it does not refer to a specific operating mode).
Data Analyzed
The input features are derived from 300 completed H1 (one-hour) candles; the current, incomplete candle is excluded. The model receives a comprehensive description of market conditions, rather than just the color or direction of a line displayed on the panel.
The set of 20 features includes: relative volatility over 30, 90, 180, and 270 candles; price deviation from moving averages calculated over 20, 50, 100, and 200 candles; the slope of the 50-period SMA (SMA50) over a five-candle span; and logarithmic price changes over 3, 6, 12, 24, and 48 candles. ...the body and shadows of the most recently closed candle; its range relative to the average range over the last 14 candles; the body of the previous candle relative to the price; and the position of the close within the range of the last 24 candles.
In the meta-model, two elements of this set are replaced by the sine and cosine of the hour of the most recently closed H1 candle. This incorporates information about the time of day. The windows, formulas, and the sequence of features are specific to these models; they cannot be altered without performing a corresponding retraining of the models.
When analysis is performed
The primary analysis is triggered whenever a new candle appears on the chart. Therefore, the H1 timeframe is significant beyond mere display purposes—using a different timeframe would change the frequency at which these same H1-based features are evaluated. The management of existing open positions, however, is carried out based on incoming ticks.
PRO • TEST VERSION |EA SUPER TREND / XAUUSD PRO
Trend and additional constraints
SuperTrend: a dedicated filter for new entries
The `UseTrendFilter` parameter is enabled by default. This filter calculates the SuperTrend based on closed H1 candles, using an ATR period of 10, a multiplier of 3.0, and a historical lookback of 300 candles. It utilizes the candle range, the ATR, and trailing upper and lower boundaries; the price crossing these boundaries triggers a change in direction.
When the trend is upward, only BUY entries are permitted; when downward, only SELL entries are allowed. If the necessary H1 data is unavailable, new entries are blocked. This filter operates independently of the panel display, the SuperTrend line, or the visual mode in the strategy tester. If `UseTrendFilter` is set to `false`, the SuperTrend direction no longer restricts entry signals.
This serves as an enabling filter rather than an independent command to buy or sell. Opening a position still requires signals from the models and the fulfillment of all other conditions. A reversal in the SuperTrend does not, by itself, close an existing position; the filter applies exclusively to new entries. Why it is important to monitor the "Entry trend"
The "Entry trend" line on the panel displays one of the following: "H1 BUY ONLY," "H1 SELL ONLY," "H1 WAITING," or "OFF." While the visual SuperTrend line is calculated based on the current chart timeframe, the entry filter is always based on the H1 (one-hour) timeframe. On an H1 chart, these timeframes align; however, on other timeframes, the direction indicated by the visual indicator may differ from that of the filter.
Spread, timing, and news
For a new position to be opened, the spread must be strictly less than `max_spread × _Point`. The default value for `max_spread` is 250. The trading time filter is disabled by default; if enabled, the correct server time must be configured. The legacy value `EndHour = 29` is invalid and must be replaced with a value between 0 and 23.
The news filter is enabled by default, tracking significant USD-related events. It restricts new entries during the period starting 60 minutes before an event and ending 30 minutes after it. Data is sourced from the MetaTrader economic calendar, with checks updated every 300 seconds. Note that this filter does not function within the MetaTrader Strategy Tester. As the absence of calendar data does not trigger a protective block, you must verify the availability of the calendar separately.
Multiple positions — additional risk
The default limit for positions is `max_orders = 3`. An additional BUY order is permitted only if the price is at least 250 points below the previous BUY order; similarly, an additional SELL order is permitted only if the price is at least 250 points above the previous SELL order. All original conditions—including signals, trend direction, and time delays—must still be met. The `orders_time_delay = 3` parameter sets a delay in hours; since this check is tied to the opening time of a candle, an entry will not necessarily occur exactly three hours later.
Adding positions against the direction of price movement increases the overall exposure. Limiting the number of entries does not render a series of trades risk-free, nor does it guarantee the recovery of any losses.
Focusing on the Long Term Rather Than Daily Expectations
Evaluating System Performance
A single day or a handful of trades cannot provide a complete picture. While an initial observation period of one to two months is more informative than drawing conclusions from an individual stop-loss, it still does not guarantee statistical reliability; a sufficient number of trades across various market conditions is required.
Key metrics include the net result (after accounting for commissions and swaps), maximum drawdown, consecutive losses, average profit and loss, the win rate, and the risk exposure from multiple open positions. A high win rate alone does not prove a system’s robustness. Since the equity curve on the dashboard reflects the entire account, evaluating the "PRO" component specifically requires a separate report filtered by its symbol and "Magic" number.
A long-term approach does not mean "waiting at any cost." Define your maximum allowable drawdown and the specific conditions under which you will halt trading. Unexpected trade volumes, recurring execution errors, entries that deviate from your defined settings, or exceeding risk limits are all signals to stop opening new positions and review the system—rather than increasing lot sizes in an attempt to recover losses.
Why Backtesting Differs from Live Trading
Live trades are influenced by spreads, commissions, swaps, price quotes, server time, historical data availability, and broker execution. When comparing results, ensure you are using the same version, settings, and time period. In this build, the news filter does not function within the backtester; this alone can cause the set of live trades to differ from those seen in historical testing.
If you are comparing performance against a public signal, account for any manual interventions or trades separately. The proportion of algorithmic trading does not, by itself, explain specific discrepancies—a detailed reconciliation of the trade history is necessary. Furthermore, reviewing the source code does not confirm the profitability of the models, the absence of curve-fitting, or whether the results align with the published statistics. Optimization Without Self-Deception
The PRO version unlocks custom settings: BUY/SELL tolerances, model thresholds, lot size, number and spacing of positions, distances, spread, SL/TP, partial closing, trailing, trend filters, news handling, time constraints, and visual/formatting options. Logical and numerical parameters are available for optimization; text-based parameters are visible but are not included in the optimization process. Model configurations, feature windows, and internal states are not exposed as adjustable settings.
Select your parameters using one segment of historical data, then validate them—without further adjustment—on a different historical segment and on a demo account. Compare the results of using the trend filter (`UseTrendFilter = true` vs. `false`) on the same dataset. Achieving the best performance on past data does not guarantee suitability for future trading.