Trading Sistem Topgun Ultimate
- Experts
-
Juan Antonio Alvarenga Galindo
Creator, designer, and developer of trading platform bots, specializing in algorithmic trading, with expertise in data science, machine learning, and statistics. Five years of trading experience, creating my own trading bots on various platforms such as MetaTrader and TradingView. - Version: 4.0
- Activations: 5
TRADING SYSTEM TOPGUN, an advanced automated trading system. The strategy integrates artificial intelligence using the K-Nearest Neighbors (KNN) algorithm to predict price movements based on historical volume patterns and technical indicators. The system employs multiple layers of validation, including volatility filters, liquidity manipulation detection, and rigorous risk management that limits daily losses. Additionally, the software incorporates active position management functions, such as preventive partial closures, profit tracking via ATR, and automatic adjustments to protect capital. Collectively, the tool seeks to maximize trade accuracy by combining traditional technical analysis with real-time machine learning methods.
The K-Nearest Neighbors (KNN) algorithm is implemented as a custom prediction engine that compares the current market situation with historical patterns to anticipate price direction.
The process is performed within the GetKNNSignal function and operates through the following key steps:
1. Feature Vector Construction
The algorithm does not analyze price in isolation. It defines the "market state" using an 8-dimensional vector that combines momentum, volume, and trend. For each bar, it calculates the following normalized values:
- RSI: Normalized Relative Strength Index.
- ADX: Normalized Trend Strength.
- Distance to MA: The distance between the closing price and the moving average (EMA 200), scaled in ATR units.
- MFI (Money Flow Index): Volume validation.
- RVOL (Relative Volume): Current volume compared to the average of the last 20 periods.
- Force Index: Movement conviction based on volume and price.
- OBV Slope: The slope of the On-Balance Volume to detect accumulation/distribution.
- PVO (Percentage Volume Oscillator): Manually calculated volume oscillator.
2. Historical Search and Distance Calculation
The algorithm looks back in history (defined by knn_lookback, default 350 bars) to find past situations that resemble the current one.
To determine how "close" or similar a historical situation is, it uses a Weighted Euclidean Distance. This means it calculates the difference between current and historical values for each of the 8 indicators mentioned above, squaring the differences and multiplying them by a specific weight assigned to each indicator.
• Note: The weights are configurable (e.g., weight_rsi, weight_ma), allowing the algorithm to give more importance to certain indicators (like distance to MA or volume) over others.
3. Result Classification (Training)
Once the algorithm finds a historical neighbor (a past bar), it observes what the price did immediately after that pattern:
• If the next closing price was higher: Result = 1 (Up).
• If the next closing price was lower: Result = -1 (Down).
4. Selection and Voting (Majority Voting)
The system sorts all found historical neighbors from smallest to largest distance (with those at the smallest distance being most similar to the current market).
It selects the closest knn_neighbors (default 5, defined as K). Then it performs a simple vote among these 5 neighbors:
• If the majority of neighbors resulted in a price rise, the algorithm predicts Buy (1).
• If the majority resulted in a drop, it predicts Sell (-1).
• In case of a tie, it returns Neutral (0).
Integration with the Strategy
Finally, this KNN prediction does not act alone. It is used as a confirmation filter for the main trend direction (SuperTrend). A buy signal is only executed if the SuperTrend is bullish (st_direction == 1) AND the KNN predicts a rise (knn_prediction == 1).
The Anti-Hunt filter logic within the TopGun Ultimate system is designed to identify and exploit "liquidity sweeps." These occur when the price briefly breaks a key level (local low or high) to trigger stop-loss orders, only to immediately reverse. This logic works on two fronts: as entry confirmation and as a defense mechanism. Its operation is detailed below:
- Technical Detection of the Sweep (IsLiquiditySweepAndReversal)
The core of this strategy lies in the IsLiquiditySweepAndReversal function. The algorithm analyzes the last 20 candles (sweep_lookback = 20) to determine if a false breakout has occurred.
For a Bullish Sweep (Buy Opportunity):
1. Level Identification: The system looks for the lowest price (Low) of the 20 candles prior to the current one.
2. The Sweep: Verifies that the low of the newly completed candle has broken (gone lower) than that identified local low.
3. The Reversal (Rejection): To confirm it was a trap and not a real breakout, it requires two conditions:
◦ The closing price (Close) of the current candle must remain above the local low it broke.
◦ The close must show rejection, locating itself above the bottom 30% of the candle's range (close_pos > 0.3).
For a Bearish Sweep (Sell Opportunity):
1. Level Identification: Looks for the highest price (High) of the previous 20 candles.
2. The Breakout: Verifies that the high of the current candle has exceeded that local high.
3. The Reversal:
◦ The closing price must remain below the previous local high.
◦ The close must be in the bottom 70% of the candle's range (close_pos < 0.7), indicating rejection of high prices.
- Application in Entry Signals
If the use_antihunt_logic parameter is activated (true), the system uses this detection to enhance entries generated by the KNN model (K-Nearest Neighbors):
• Override (Enhancement): If a liquidity sweep is detected, the system can generate a buy or sell signal even if the main trend indicator has doubts, provided the KNN prediction is not contrary.
◦ Buy Signal: Activated if there is a confirmed "Bullish Sweep" and the KNN is neutral or bullish (knn_prediction >= 0).
◦ Sell Signal: Activated if there is a confirmed "Bearish Sweep" and the KNN is neutral or bearish (knn_prediction <= 0).
- Application in Smart Defense
The system also uses this logic to protect open positions via the ManageOpenPositions function. If the use_smart_defense parameter is activated, the EA reacts to sweeps that go against the operation:
• Partial Close: If you have a buy position and a "Bearish Sweep" occurs (price rises, breaks a high, and plummets), the system interprets this as imminent danger. It automatically closes a percentage of the position (default 50%) to secure profits or reduce risk.
• Stop Loss Adjustment: Immediately after the partial close, the system adjusts the Stop Loss to the extreme of the candle that caused the sweep (to the low of the previous candle for buys or to the high for sells), protecting the rest of the operation from a larger reversal.
Validation of the TOPGUN ULTIMATE Strategy on Gold / XAUUSD H1 timeframe from 2022-01-01 to 2025-12-31.
Based on the detailed report for the XAUUSD (Gold) pair on the 1-hour (H1) timeframe, here are the key points to interpret these results:
Trading optimization is the systematic process of adjusting strategy variables to find the combination that maximizes historical performance and statistical robustness. In the "ReportOptimizer-TOPGUN," we see how thousands of configurations (passes) are tested by varying technical indicators, machine learning parameters, and risk management rules.
The pillars of optimization based on the strategy data are detailed below:
1. Performance Evaluation Metrics
The optimizer seeks not only total profit but a balance between several key metrics to determine the quality of a "pass":
• Profit Factor: Indicates the ratio between gains and losses. Pass 1374, for example, shows an exceptional factor of 6.99, meaning that for every dollar lost, almost seven were gained.
• Sharpe Ratio: Measures risk-adjusted return. High values like the 7.85 of pass 1704 suggest high consistency with low volatility in returns.
• Drawdown (Equity DD %): Vital for account survival. The optimization seeks to reduce this percentage; pass 1612 achieved an outstanding result with a maximum drawdown of only 8.63%.
2. Machine Learning Parameter Tuning (KNN)
A central part of this optimization is configuring the Nearest Neighbors (KNN) algorithm to adapt to the market structure:
• Number of Neighbors (knn_neighbors): Different values are tested, such as 40 in pass 1457 versus 15 in pass 1971, to see how many similar past patterns are needed for a reliable prediction.
• History Window (knn_lookback): The depth of the past that the algorithm analyzes is adjusted, commonly varying between 400 and 500 candles to find the balance between relevance and data quantity.
3. Technical and Volatility Filters
The optimization determines under which market conditions it is preferable not to trade:
• Volatility Filters: The system evaluates whether to trade in low, normal, or high volatility (trade_in_high_vol). Many of the best passes specifically activate trading in high volatility.
• Trend Indicators: Periods and multipliers of tools like SuperTrend (st_period, st_multiplier) and RSI are optimized to filter false entries.
4. Risk Management and "Smart" Defense
The report shows that exit optimization is as important as entry optimization:
• ATR Multipliers: Stop Loss and Take Profit levels are adjusted based on volatility. For example, pass 1457 uses a Stop Loss of 3.3 ATR and a wide Take Profit of 29.7 ATR.
• Capital Protection: The effectiveness of activating Trailing Stop, Breakeven, and Scale Out (partial exit) logic is tested to secure profits as the price moves in favor.
5. The Trade-off between Profit and Risk
The results show that the pass with the highest net profit (Pass 1722 with $177,254.05) is not necessarily the best "Result" (70.73) due to its 29.74% drawdown. In contrast, Pass 1457 obtains a score of 97.53 (the highest in the report) by combining solid profit with a much more controlled drawdown of 14.80%.
6. Profitability and Efficiency
The report shows exceptional performance starting from an initial deposit of 500.00, with the highest net profit pass (Pass 1722) reaching a net profit of $177,254.05.
• Profit Factor (4.44): For every dollar lost, the system earned 4.44 dollars, which indicates very high efficiency for an algorithmic trading system.
• Sharpe Ratio (2.35): This value suggests that the return obtained is very good in relation to the risk (volatility) assumed during the test period.
7. Risk Management (Drawdown)
A critical analysis of backtesting must always look at "drops" or drawdowns:
• Maximum Equity Drawdown: Stood at 29.74% (42,986.44). Although the profit is massive, this percentage indicates that the user must be prepared to see significant fluctuations in their account value in real-time.
• Recovery Factor (4.12): Indicates that the system is capable of recovering losses from a maximum drawdown relatively quickly and effectively.
8. Operational Statistics
The system executed a total of 682 operations, offering a robust statistical sample.
• Win Rate: with 50.15% profitable positions.
• The key to success: the average profitable transaction ($669.03) is much larger than the average unprofitable transaction ($-151.63). This confirms that the strategy lets profits run and cuts losses quickly.
9. Seasonal and Hourly Analysis
Backtesting reveals when the algorithm is most effective:
• Entries by hour: A clear concentration of activity and profits is observed during the London open (08:00 - 10:00) and the New York session (15:00 - 18:00).
• Monthly Performance: Although most months are positive, September and October stand out with the highest accumulated gains, while other months like May show much flatter activity.
RISK AND IMPORTANT NOTICE:
TRADING SYSTEM TOPGUN must be evaluated strictly as a long-term trading system. Short-term performance observations, limited trade samples, or brief equity curve analyses do not reflect the system's intended operational profile. Market conditions evolve continuously, and the strength of TRADING SYSTEM TOPGUN lies in its adaptability and structural resilience over time. This system is not designed for a short-term presentation; it is designed for sustained deployment.
Trading carries considerable financial risk, and past performance does not guarantee future results. Users should only trade with capital they can afford to lose, and it is strongly recommended to start with conservative configurations, especially during the initial implementation period. No automated trading system can eliminate risk completely; TRADING SYSTEM TOPGUN is designed to manage and control risk exposure, not to eliminate it.
If any system behavior, parameter, or configuration is unclear, users should not guess or arbitrarily modify settings. Incorrect configuration can significantly affect system performance and risk exposure. If you need help, please contact us. Proper understanding of the system allows for appropriate use and more consistent results.
TRADING SYSTEM TOPGUN is not designed for speculative short-term operations or promotional performance metrics. It is designed to function as a disciplined, selective, and adaptive trading system, reflecting professional standards of risk management and long-term capital investment. For traders seeking a solid solution for trading, based on robust logic, controlled risk, and long-term viability, TRADING SYSTEM TOPGUN is designed to fulfill that objective.
Trading in financial markets carries a high level of risk and may not be suitable for all investors. High leverage can be detrimental or beneficial to you. Past performance does not guarantee future results. The use of TRADING SYSTEM TOPGUN is at the sole discretion and risk of the user/client.
INVERJAAG is not responsible for financial losses derived from the use of this software.
